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?
  1. static bool IRAM_ATTR monitor_event(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data)
  2. {
  3.     ESP_LOGI(TAG, "Monitor event triggered");
  4.     return true;
  5. }

Setting up the monitor
  1.     // Set up the monitor
  2.     adc_monitor_handle_t monitor_handle = NULL;
  3.     adc_monitor_config_t monitor_config = {
  4.         .adc_unit = ADC_UNIT_1,
  5.         .channel = ADC_CHANNEL,
  6.         .h_threshold = 3400,
  7.         .l_threshold = 3200,
  8.     };
  9.     adc_monitor_evt_cbs_t cbs_monitor = {
  10.         .on_over_high_thresh = monitor_event,
  11.         .on_below_low_thresh = monitor_event,
  12.     };
  13.  
  14.     ret = adc_new_continuous_monitor(handle, &monitor_config, &monitor_handle);
  15.     if (ret != ESP_OK) {
  16.         ESP_LOGE(TAG, "Failed to create new monitor: %s", esp_err_to_name(ret));
  17.     }
  18.  
  19.     ret = adc_continuous_monitor_register_event_callbacks(monitor_handle, &cbs_monitor, NULL);
  20.     if (ret != ESP_OK) {
  21.         ESP_LOGE(TAG, "Failed to register monitor event callbacks: %s", esp_err_to_name(ret));
  22.     }
  23.  
  24.     ret = adc_continuous_monitor_enable((adc_monitor_handle_t)monitor_handle);
  25.     if (ret != ESP_OK) {
  26.         ESP_LOGE(TAG, "Failed to enable ADC monitor: %s", esp_err_to_name(ret));
  27.     }
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: No registered users and 111 guests