atc1441 / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter
2.82k stars 472 forks source link

save battery: sleep time for sensor #63

Closed michapr closed 3 years ago

michapr commented 4 years ago

Hi,

what do you think, does it make sense to extend the interval for reading temperature/humidity?

Loop delay time is 7 seconds as I have seen (tested) - readsensor() with wakeup / sleep sensor will be called in every loop.

Will it save battery if check the sensor values only once per minute as sample?

atc1441 commented 4 years ago

That would definitely save a lot of battery power 👍

The reading of the sensor is the longest time waiting as the i2c uses clockstretching which takes around 10ms where the mcu just waits

michapr commented 3 years ago

PR: https://github.com/atc1441/ATC_MiThermometer/pull/73

As I have seen the usage of the sensor will take much battery if wakeup if frequently. Because there are no needs to check the temperature every 6-7 seconds I have inserted a loop counter for sensor usage.

Advertising package (one unit 20ms, take the Voltage/10 = mA): ATC_sensor_default

Sensor usage(one unit 20ms, take the Voltage/10 = mA): ATC_sensor_default_measure

adv_count will count the number of the loops in the main procedure until meas_count was reached.

So the delay could be set to a measurement once per minute as sample instead of every loop, it will save much battery.

second: Additional was fixed the overflow inside the advertising time condition for now with a counter inside ;)

atc1441 commented 3 years ago

This is great :)

Will merge it