Page 1 of 1

Hall sensor readout during ULP and normal power mode

Posted: Wed Apr 15, 2020 9:59 pm
by isluca
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?

Re: Hall sensor readout during ULP and normal power mode

Posted: Thu Apr 16, 2020 9:03 am
by chegewara
Try to add this call before enter deep sleep:

Code: Select all

adc1_ulp_enable();

Re: Hall sensor readout during ULP and normal power mode

Posted: Thu Apr 16, 2020 6:53 pm
by isluca
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?

Re: Hall sensor readout during ULP and normal power mode

Posted: Mon Apr 20, 2020 6:49 am
by chegewara
Hard to say, maybe try to add small delay just before deep sleep command.