pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
2.89k stars 201 forks source link

Battery consumption/drain #204

Open JGeeforce opened 2 years ago

JGeeforce commented 2 years ago

I installed your firmware on the 8th of March, also because it could function longer on a battery. Some days before that I installed 2 others with the other 1441 firmware. I use default settings and custom advertising. It is working fine, but the battery went from 100% (brand new out of the box) to 77%. With that speed it will take 4 weeks to replace batteries. So it seems, the pvvx consumes more.

With the 1441, which are running several days longer, are on 84% at the moment. So also fast to my opinion, but one of them is set to advertise every 1 minute. So it seems, the pvvx consumes more.

Why does it use so much battery? Do I need to adjust some settings? Or are the batteries supplied by Xiaomi bad ones?

pvvx commented 2 years ago

For compatibility with third party software, the atc1441 battery percentage formula is used.

For example, HA custom_components ble_monitor, this is how voltage is calculated:

volt = 2.2 + (3.1 - 2.2) * (batt / 100)

Battery voltage from start: image

And the voltage of CR2032 is highly dependent on temperature. All this has already been described many times. And I repeat for you personally, since you do not want to find information on this topic before posting questions.

pvvx commented 2 years ago

image In this graph, most devices have an operating time of about 1 year. Several devices operate in sub-zero temperatures and show low battery percentage. The smallest value on the graph is the original LYWSD02 using 2 CR2032 batteries (7 months).

JGeeforce commented 2 years ago

Sorry and thank you for your reply. It is clear for me now.

nagyrobi commented 2 years ago

And the voltage of CR2032 is highly dependent on temperature.

How about using a compensation coeficient when calculating percentage, since the temperature is always known?

https://uncannier.com/cr2032-lithium-battery-charge-level-measurement/

Protoncek commented 2 years ago

That would be wrong information. If cell has, say, 2.5V at -20 degrees it's correct that it shows very low percentage, since at that temperature it will die very soon. If it would show, say 80% at that point it would mislead the user thinking that battery is still pretty good (at that temperature), while it wouldn't be true. The circuit works on real voltage, not on compensated one...

But you CAN still use a battery which died outside for inside modules, since it will recover when heated back to room temperature.

pvvx commented 2 years ago

Readings of LYWSD03MMC installed outdoors with a new battery (from December 10, 2021). And that is how it works to this day. image

50494554524F commented 1 year ago

writing here without opening a new 3d... my stats and a question

currently i'm using LYWSD03MMC + v3.1 + atc1441 unencrypted + 10000ms adv + 6x measurement... all other settings are on default or disabled

with these settings i'm hitting 2 years with branded batteries (probably even more) and 13-14 months with cheap batteries

now that winter season is ending i'm going to update to the latest version (successfull tested on a thermometer, same settings) with bt home + encryption

are there any stats on these settings?! still 12+ months?! just to know when i have to care about battery level...

thanks

pvvx commented 1 year ago

There is a very large dependence on the battery manufacturer and operating conditions. The difference reaches more than 2 times. If we add the storage time of the battery before sale and the absence of elements (capacity for power supply) in the cheap version of the LYWSD03MMC and the new CGDK2, then the difference can reach up to 4 times.

For outdoor work and with default settings, there is only this schedule so far: https://raw.githubusercontent.com/pvvx/pvvx.github.io/master/ATC_MiThermometer/img/Weather.gif And there is already a second battery. The first battery has passed into another thermometer with a capacitor in the power supply used in the home temperature and continues to work.

For example, the difference in batteries in two identical CGPR1 with batteries from the kit after a year: street shows 5%, home 100%. CGPR1 uses 2 pieces of CR2450 batteries in parallel connection...

pvvx commented 1 year ago

LYWSD03MMC has different LCD controllers. They have different current consumption. Plus, it depends on the type of sensor and the installed ratings of the capacitors in the power supply.

The version is determined by the addresses of the display and sensor on I2C:

HW LCD I2C addr SHTxxx I2C addr Note
B1.4 0x3C 0x70 (SHTC3)  
B1.6 UART! 0x44 (SHT4x)  
B1.7 0x3C 0x44 (SHT4x) Test original string HW
B1.9 0x3E 0x44 (SHT4x)  
B2.0 0x3C 0x44 (SHT4x) Test original string HW

Version 4.2 has several changes for less consumption. And uses a different calculation of statistics as a percentage of the battery.

pvvx commented 1 year ago

The CR2016 is used for faster battery run time determination. But after 6 months they are still working...

CGDK2

image image

image Various experiments were performed on it, and not everything is exactly on the graph ...

jddonovan commented 1 year ago

Thank you @pvvx for the detailed work. Did I understand correctly that the LCD driver has practically no difference in battery consumption? And biggest difference would be between the sensors: SHTC3/SHT4x.

I have some B1.5 sensors, and these have probably the worst power consumption (uart LCD driver & SHTC3). What would you estimate the power consumption difference to be between most efficient (B1.9/B2.0) vs worst (B1.5)? Around 15%, or a more noticable ~50% more?

pvvx commented 1 year ago

Version B1.9 uses an outdated LCD controller - BU9792 - Has the highest consumption of other LCD controllers. The LCD controller in 1.4 seems to be the most economical. Sensors, since they are rarely polled, do not have a strong difference in consumption.

The newer the version, it is usually worse because of the maximum reduction in price.

But the presence of a capacitor in the power supply has a greater impact on battery life (up to 40%). And in LYWSD03MMC and the new CGDK2, they are not soldered. The difference between CRxxxx batteries from different manufacturers and the price reaches up to 2 times.

50494554524F commented 1 year ago

as you asked i can give you updated stats about batteries...

B1.4, firmware v3.1, 10s advertising, no encryption, no additional features enabled, inside home: xiaomi battery that cames with the thermometer is still running after 722 days and 27% charge available.... cheap pkcell died after 14 months, i can reuse them in xiaomi window sensors for additional 4-6 months....

thermometers with v4.2 firmware have been running for two months now and the voltage is sitting always around 2.80v...

so we can heat easily a year and no need to care about changing them :D

pvvx commented 1 year ago

Another test of Xiaomi LYWSD03MMC B1.9 with CR2025 was completed - a cheap CR2025 battery from a set of 8 batteries for $1 finally died - the SoC of the thermometer went into deep-sleep with the latest readings of the operating voltage in millivolts: image and the expectation of a 2.2V boost for a fresh start...

image

Almost 9 months...

PS: image

Of these sets, the CR2032 usually works 2 times less than what original Panasonic CR2032

nagyrobi commented 1 year ago

2 times less means half?

50494554524F commented 1 year ago

i upgraded to the latest home assistant version to use new features + i installed firmware v4.3. so, i'm using the new bluetooth integration and i can't put it in passive mode because i have a bluetooth bot.

to reduce battery drain i did:

after two months of tests battery drain seems a lot higher compared to the deprecated passive ble monitor...

is there anything else i can do?! have i missed any of your tips?! could it help going back to firmware v3.1?!

thanks

pvvx commented 1 year ago

1.

https://bluez-cheat-sheet.readthedocs.io/en/latest/

activate experimental mode for bluetooth service :
$ sudo nano /lib/systemd/system/bluetooth.service

Add --experimental at the end of the following line :
ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental

2.

image image

3.

https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html

image

bam80 commented 9 months ago

And I repeat for you personally, since you do not want to find information on this topic before posting questions.

This information is scattered around. Could we put it in a Wiki here maybe, so one don't have to look for it in the future?

brotaxt commented 2 weeks ago

After reading all replies, which advertising type should I choose to get minimal battery drain? Mijia?

50494554524F commented 1 week ago

After reading all replies, which advertising type should I choose to get minimal battery drain? Mijia?

https://github.com/pvvx/ATC_MiThermometer/issues/204#issuecomment-1475350644

i switched to mijia to use xiaomi integration as i use other xiaomi devices, passive mode disabled... i can confirm cheap batteries (pkcell) should hit 14 months, branded batteries (panasonic) can reach very easily 18 months (probably close to 24 months)

pvvx commented 1 week ago

Mijia has more consumption than BTHome.

brotaxt commented 1 week ago

And compared to the other custom protocols? bthome with esp32 does only work with this custom component, correct? https://github.com/afarago/esphome_component_bthome/blob/master/components/docs/bthome_ble_receiver.rst

pvvx commented 1 week ago

I don't use ESP32 because it works poorly in both BLE and WiFi. Especially since it only has version BT4.2. It's outdated, always glitchy, and consumes a lot. Connecting to any device in BLE ESP32 causes increased battery consumption (ten times) due to slow processing and frequent loss of packet reception in BLE. When connected to BLE, the device has to duplicate responses and confirmations dozens of times, which kills the batteries.

brotaxt commented 1 week ago

I'm using sonoff t5 switches which have an esp32 included. Thats why i'm using the esp32 :) It works for me but I struggle to decide which is the best protocol to use.

pvvx commented 1 week ago

On ESP32-C3, BLE advertising reception is significantly (!) better, but with WiFi disabled. Supports BT5.0+, including LE long Range. And BLE reception works up to -110 dBm. Zigbee and WiFi at maximum up to -90..95 dBm. LE Long Rage at -105 dBm is 500..1500 meters...