Hall sensor readout during ULP and normal power mode

isluca
Posts: 2
Joined: Wed Apr 15, 2020 9:48 pm

Hall sensor readout during ULP and normal power mode

Postby isluca » Wed Apr 15, 2020 9:59 pm

Hi
I'm trying to use the hallsensor to wake up my esp32 from deepsleep. For this I use this example https://github.com/espressif/esp-iot-so ... all_sensor

On it's own this works fine.


However, as soon as I've read out the hall sensor when the esp32 is awake using the hall_sensor_read() function the device no longer wakes up if it goes to sleep a second time.


What am I doing wrong?

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Hall sensor readout during ULP and normal power mode

Postby chegewara » Thu Apr 16, 2020 9:03 am

Try to add this call before enter deep sleep:

Code: Select all

adc1_ulp_enable();

isluca
Posts: 2
Joined: Wed Apr 15, 2020 9:48 pm

Re: Hall sensor readout during ULP and normal power mode

Postby isluca » Thu Apr 16, 2020 6:53 pm

Hi
Thanks for the tip.
I tried to add the

Code: Select all

adc1_ulp_enable();

Code: Select all

adc1_config_width(ADC_WIDTH_BIT_12);
printf("Hall Sens: %d\n", hall_sensor_read());  
adc1_ulp_enable();
esp_deep_sleep_start();
works fine.
The ulp wake up will reliably work for >20 sleep-wake cycles

However if I use the following code the ulp wakeup stops working after 1-7 sleep wake cycles. The sensor will then no longer react to changes in the magnetic field.
This behavior is reproducible over multiple esp32 dev boards.

Code: Select all

  
 while(hall_sensor_read()>0)
  {
    printf("Hall Sens: %d\n", hall_sensor_read());
    vTaskDelay(5000/portTICK_PERIOD_MS);
  }
  
  adc1_ulp_enable();
  esp_deep_sleep_start();
  
I'm using the hall sensor of the esp32 to detect if a door has been opened and go back to sleep again once the door has closed again.
Is there a different method to achieve this?

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Hall sensor readout during ULP and normal power mode

Postby chegewara » Mon Apr 20, 2020 6:49 am

Hard to say, maybe try to add small delay just before deep sleep command.

Who is online

Users browsing this forum: No registered users and 100 guests