nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

Light sleep while connected, any advice appreciated #1061

Open karelchik opened 3 years ago

karelchik commented 3 years ago

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:

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 void BLEServer::updateConnParams(esp_bd_addr_t remote_bda, uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t timeout) 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 ... etc. Thanks!