-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ultra low power #4
Comments
Tasks:
|
I didn't though it was this low, nonetheless the fact that the device always responds to read commands withing 10 seconds, while with the original tuya firmware the device responded to commands only if wake up with an hardware event make me feel that we can achieve far greater lifetime (> 1 year) by preventing most of the wakes. |
Looking to power histogram i can see two types of events - smaller around 7 mA, happens every seconds and larger, up to 26 mA, happens every 3 seconds. PS: we have channel for zigbee developers in Telegram, for fast discussions https://t.me/zigdev |
Just to add - POLL_CONTROL cluster need to be disabled, because missing support for POL_Control check-ins in z2m does not allow to switch from fast poll mode to more energy-friendly mode. |
WOW you did A LOT in just a few hours! I'm going to join the telegram group in a moment, thank you! I wish I had the energy profiler, it really helps in this kind of situation. Any change you could profile the original firmware to have a baseline? I saw your commit 70d3c1b, unfortunately it doesn't highlight relevant changes because the whole folder was renamed at the same time, any change you can split the 2 commits? I would like to port your optimizations to my motion sensor firmware (btw, now that you renamed the contact sensor to iasSensor, my firmware don't make much sense anymore :D still I'll show you when it's done, maybe we could add it to the repo). About the POLL_CONTROL cluster in z2m, I think that this can be done here, am I right?
Can you please explain this phrase? I know the fast poll mode, but why you think z2m put the device in fast poll mode? Finally (a bit unrelated, sorry) I would highlight that while the traditional method of flashing the firmware with the 1...1kohm resistor to the SWS pin is, in fact, unreliable, I found that you can use SWS, TX and RX pins together in this configuration
and use the https://github.com/Ai-Thinker-Open/TBXX_Flash_Tool/blob/master/Telink_Tools.py to reliably (100% of the times with a very cheap FTDI usb converter) and quickly flash new firmwares into the telink board: |
Ok I found relevant changes for power optimizations by diffing the old repo with the new one. btw I joined the telegram group but I don't speak your language unfortunately :( |
Yes, you are right about additional changes, i will add this. Thank you, missed it. |
You're welcome!
I did my best understanding the specs, that I said it seems to me that the ED switches to the fast poll mode only if the parent (coordinator) answers to the check-in request saying that communication is needed. So in this case (z2m missing check-in support) I don't think ED would enter the fast poll modem, am I wrong?
I agree with you in keeping the interval low for development, but yes I think that for this kind of devices battery life is a very important thing for end users so it's critical to choose it wisely (it seems to me that tuya choose a 4hrs interval!)
Didn't know it was that cheap! I will buy it (do you have any link to order it at that price?), in the meantime maybe I will ask you to take some measurements :D (sorry for pushing, but did you have time to measure the tuya original firmware?)
The "new" serial method is very reliable for me, I will make the PR!
Gotcha, thanks! |
Thank you for the profiles! The new serial method supports read flash, but due to a small software issue by Ai-Thinker, that not yet supported (i did found a way to actually read it but it's too involved). I asked for the source code (Ai-Thinker-Open/TBXX_Flash_Tool#5), if they provide it to me I will fix it. But for erasing and flashing it works perfectly. As a side note...I'm trying to ask a question in the zigdev telegram channel but it says that administrators have blocked me to send messages in the channel, can you please allow me? My telegram Nickname is Suxsem, thank you! |
Done! https://github.com/Suxsem/TS0202-PIR-Sensor-Zigbee-firmware |
hi @doctor64 ! |
Enormous Energy Consumption. Firmware: switch. With a short press of the button: No pressing: Calculation for CR2032. Many unnecessary timers are enabled, POLL_CTRL*** is active for 6 sec. The TX level is set to a limit that is incompatible with the current for the CR2032. *** POLL_CTRL are enabled by ZHA and other software. However, ZHA does not look at the settings offered by the device, as required by the Zigbee 3.0 documentation. LONG_POLL = 6 * 4 # 6s
|
Original firmware from Tuya. https://pvvx.github.io/TS0041_TZ3000_fa9mlvja/ The firmware processes two events - single and double button presses. With a short press of the button: Overage 2.3 uA (period of 240 sec), Sleep 1.8 uA. The proposed firmware has a consumption 25 times higher! |
Elementary - done by replacing several files in the SDK.
ADC in Telink's Zigbee SDK is always enabled. Each Flash call checks the battery level, which results in additional battery consumption. It is more difficult to fix - by replacing several files from the SDK and bypassing some functions and variables for lib. That is, by rewriting all calls to Flash and some initialization functions. |
@pvvx - I'm really impressed with your deep knowledge. But please, my firmware still not reach ever a beta status and not intended for end-users right now. Moreover, switch firmware completely lacks optimization in power part.
Only if we have VOLTAGE_DETECT_ENABLE, isn't it? |
I haven't fully analyzed the options of the original Telink SDK. But ADC checks are written in libzb_coordinator.a, libzb_ed.a, libzb_router.a. And ADC is used to initialize "Random". I just immediately changed everything related to VOLTAGE_DETECT_ENABLE in the SDK to my own. Also, why do need a bunch of extra code to determine the Flash type if it is intended for chips with external SPI-Flash? The same with assigning a bunch of additional timers in "reporting". And a bunch of duplicate checks before that. Sending "report" and other messages is placed in the buffers array and if the transmitter is busy, then its own timer is set. But in the example, an additional timer is also set. As a result, there may not be enough timers if the device uses more than one "report". In the SDK examples, only one "report" is used... As a result, there is a lot of unnecessary stuff in the Telink SDK, which not only causes problems, but also increases consumption. This is especially true when the network is lost. If the coordinator is disconnected or the device is not connected, then the network is continuously searched until the battery is completely discharged. |
@pvvx I think you are little exaggerating the level of consumption. Even if the ADC consumes energy to read the battery level on every flash write operation, regular devices rarely write to flash memory. I understand the importance of this for your project, with logging sensor states to flash, but for most devices, writing and checking the ADC happens very rarely—only during joining and configuring the device. I don't think this will constitute a significant part of the power budget. I completely agree with you that the Telink Zigbee SDK is not the best example, but what can we do about it? I'm not ready to write a Zigbee stack from scratch or port ZBOSS to Telink, especially for free. |
The problem is not that ADC polling consumes anything, but that it cannot be used. And in terms of consumption, it turns out to be 25 times more, if you do not get into the user part of the SDK. The Zigbee stack has nothing to do with it. These files - https://github.com/doctor64/tuyaZigbee/tree/master/switch have nothing to do with the Zigbee stack. This is all user configuration. That is, you wanted to use the Zigbee stack so much.
I don't write anything to Flash in Zigbee. Tuya uses a analogical SDK, but different settings. |
You mean this part from apps/common/main.c ?
|
Hi, thank you for this project!
I noticed in the source code that there are a lot of timers (ex. long poll 20s, short poll 2s, ota checks) that I think will consume the battery too soon.
The tuya firmware basically does NOTHING until an hardware event is detected (other than a 4 hours ping). This is perfect for a sensor-only device such as switches, contact sensors and so on.
How can we ensure the device always sleeps until an actual event is detected (other than a 4 hours or so ping for reporting battery value maybe)?
The text was updated successfully, but these errors were encountered: