BLE + light sleep, any tips appreciated
Posted: Sun Mar 28, 2021 4:13 pm
Hi guys! We are new to ESP32. Our aim is to develop a system of one central device and multiple peripheral devices, each p. device making measurements with sensors and sending those values to the central device (about once per second). Since peripheral devices are running on batteries, their current consumption has to be as low as possible.
How we think the problem should be solved:
*using BLE
*so-called peripheral devices are servers and the central device is a client
*servers go to light sleep as much as possible
*client connects to servers once and remains connected
*client gets data from servers' characteristics
We have tried using Neil Kolban's library (https://github.com/nkolban/ESP32_BLE_Arduino)
The problem is that once a server is put to light sleep the connection is immediately lost. We suppose that the problem is related to latency and connection interval, because it seems that by default latency is 0 and connection interval is 7.5 ms. We have tried setting higher latency and connection interval by using this function
but it seems to not do anything and nRf Connect app still shows the default parameters (interval 7.5 ms, latency 0) when connecting to the server.
We would appreciate it a lot when somebody could point us in the right direction, for example mentioning whether our logic is faulty to begin with or providing some example codes / sources, recommending another library ... etc. Thanks!
PS. We are aware of the automatic light sleep on ESP32 (https://github.com/espressif/esp-idf/is ... -500312453), and got it working. But we haven't been able to fully understand any of esp-idf BLE examples as they are veery long. So any tips on getting a BLE communication going with esp-idf would be very much appreciated.
How we think the problem should be solved:
*using BLE
*so-called peripheral devices are servers and the central device is a client
*servers go to light sleep as much as possible
*client connects to servers once and remains connected
*client gets data from servers' characteristics
We have tried using Neil Kolban's library (https://github.com/nkolban/ESP32_BLE_Arduino)
The problem is that once a server is put to light sleep the connection is immediately lost. We suppose that the problem is related to latency and connection interval, because it seems that by default latency is 0 and connection interval is 7.5 ms. We have tried setting higher latency and connection interval by using this function
Code: Select all
void BLEServer::updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t timeout)
We would appreciate it a lot when somebody could point us in the right direction, for example mentioning whether our logic is faulty to begin with or providing some example codes / sources, recommending another library ... etc. Thanks!
PS. We are aware of the automatic light sleep on ESP32 (https://github.com/espressif/esp-idf/is ... -500312453), and got it working. But we haven't been able to fully understand any of esp-idf BLE examples as they are veery long. So any tips on getting a BLE communication going with esp-idf would be very much appreciated.