Hi,
I'm using an ESP32 with the latest version of MicroPython. This is a client for a bluetooth sensor. Everything works fine. I can read values from the remote bluetooth-sensor. I can even disconnect and connect again (my client is based on the ble_sample.py from the MicroPython examples).
Now the problem starts: Once the reading is done I put the machine into deepsleep for 60 seconds. The ESP32 wakes up from sleep, it initialises Bluetooth in the exact same way like before. It scan for devices, find the sensor, trying to connect, but the connection never succeeded.
This is reproducible and repeat as long as I'm waking up from deepsleep. As soon as I power-cycle the ESP32 or press the reset button everything works fine. Until it got trapped in the deepsleep-not-working-cycle again.
Any ideas?
Thanks, Carsten
Bluetooth not connecting after waking up from deepsleep...
Re: Bluetooth not connecting after waking up from deepsleep...
Could you do a machine.reset() after wake-up, maybe that is different than a wake from deepsleep()?
Maybe ...
https://lastminuteengineers.com/esp32-d ... p-sources/
Maybe ...
https://lastminuteengineers.com/esp32-d ... p-sources/
Seems to suggest that a reset should start at the beginning. Hmmm ...However, the RTC memory is kept powered on. So, its contents are preserved during deep sleep and can be retrieved after we wake the chip up. That’s the reason, the chip stores Wi-Fi and Bluetooth connection data in RTC memory before disabling them.
So, if you want to use the data over reboot, store it into the RTC memory by defining a global variable with RTC_DATA_ATTR attribute. For example, RTC_DATA_ATTR int bootCount = 0;
In Deep sleep mode, power is shut off to the entire chip except RTC module. So, any data that is not in the RTC recovery memory is lost, and the chip will thus restart with a reset. This means program execution starts from the beginning once again.
Re: Bluetooth not connecting after waking up from deepsleep...
Well, I can give it a try. But I also need to save data to the RTC memory and load it after I wake up again. So a machine.reset() - if it works - doesn’t really solve my problem…
Re: Bluetooth not connecting after waking up from deepsleep...
My thinking was maybe the different reset modes leave the machine in different states. Then I'd need an expert to fix it!