adc_monitor example

xelaim
Posts: 1
Joined: Mon Jun 03, 2024 9:08 pm

adc_monitor example

Postby xelaim » Mon Jun 03, 2024 9:31 pm

I'm trying to use the esp32-h2 with an adc.
According to https://docs.espressif.com/projects/esp ... nuous.html i should be able to use a adc_monitor.

I've written an example, it doesn't give any error, but it doesn't work. Does anyone have a working example?

Code: Untitled.c Select all


static bool IRAM_ATTR monitor_event(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data)
{
ESP_LOGI(TAG, "Monitor event triggered");
return true;
}

Setting up the monitor

Code: Untitled.c Select all


    // Set up the monitor
adc_monitor_handle_t monitor_handle = NULL;
adc_monitor_config_t monitor_config = {
.adc_unit = ADC_UNIT_1,
.channel = ADC_CHANNEL,
.h_threshold = 3400,
.l_threshold = 3200,
};
adc_monitor_evt_cbs_t cbs_monitor = {
.on_over_high_thresh = monitor_event,
.on_below_low_thresh = monitor_event,
};

ret = adc_new_continuous_monitor(handle, &monitor_config, &monitor_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to create new monitor: %s", esp_err_to_name(ret));
}

ret = adc_continuous_monitor_register_event_callbacks(monitor_handle, &cbs_monitor, NULL);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to register monitor event callbacks: %s", esp_err_to_name(ret));
}

ret = adc_continuous_monitor_enable((adc_monitor_handle_t)monitor_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to enable ADC monitor: %s", esp_err_to_name(ret));
}
I get no errors, and i can see using my continious monitor that the values are being read.

3w3rt0n
Posts: 3
Joined: Thu Nov 01, 2018 2:34 pm

Re: adc_monitor example

Postby 3w3rt0n » Fri Nov 01, 2024 5:47 pm

I'm having the same problem, did you manage to solve it? Can you share the solution?

3w3rt0n
Posts: 3
Joined: Thu Nov 01, 2018 2:34 pm

Re: adc_monitor example

Postby 3w3rt0n » Tue Nov 05, 2024 1:35 pm

The correction is in the link if anyone needs it: https://github.com/espressif/esp-idf/issues/14769

Who is online

Users browsing this forum: Bytespider, PerplexityBot, PetalBot and 8 guests