Is it possible to save battery life via this code - example

I'm programming an esp32 as a BLE server providing sensor data to clients. I was wondering if it would save battery life if I only notify the client when there is a change in value.

for example, I store the previous sensor value, compare it to current value and only send the notification if I find a delta value. (The notifications drop down by 1000%.)

I mean, yea. Since you neither posted your Code nor details about your setup, all we can do is an uneducated guess...

In General, not executing a Code requires less energy than executing a Code... The question is, how significant your Power save will be.

Afaik the whole idea of ble is, that you do already handshakes etc. but a communication between devices only occurs when explicitly needed.

Tl;dr: try it out mate.

Transmitting data less often will save energy as most transceiver use considerably more energy when actually transmitting.

However sending data at a regular interval (maybe once per second), even if unchanged, can be useful as a means for the receiver to detect when there is a communication failure.

I believe the ESP32 has sleep modes for the most economical use of battery power.


PS ... referring to Reply #1, this is not correct "not executing a Code requires less energy than executing a Code... " A microprocessor works at the normal clock rate and consumes the same energy even if it is just waiting.

If you can wait some time between aquiring the data from the sensor you can put the ESP32 into deepsleep-mode
You can setup a timer that wakes up the ESP32 in interval like every 10 seconds or every 5 minutes or what you like.

deep-sleep-mode will lowers down current to something like 200µA if the USB-adapter-chip and the voltage-regulator is a standard one. If these compenents are optimized for low-power the current will go down to 15µA = 0,015mA.

Though I don't know if an established BLE-connection keeps working when you wake-up from deep-sleep-mode.

Are all the clients ESP32's or ESP8266 too? If yes you could use the ESP-NOW-protocol for wireless data-exchange.
I have successfully coded a temperatursensor with an ESP32 that wakes up once every 20 seconds aquire temparturdata from a DS18B20 sensor sends the data over ESP-NOW and goes to sleep again. With ESP-NOW this needs 0,1 seconds awake-time.

If deep-sleep would not work with BLE and you could use another ESP32 as some kind of relay-station that can be connected to a powersupply-unit instead of a battery you could use ESP-NOW to collect the data and the second ESP32 for the BLE-connection.

google is your friend

best regards Stefan

Thank you,guys. I will research your varied suggestions.