Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tammorgan_flint wrote:Is there any command in the Tuya protocol to change the polling time? If this is the case, we could try to see if it's implemented in the MCU's firmware
Send module command
Note:
“Send command” is an asynchronous processing protocol. When the MCU receives the control packet, it responds to the module about the reception and controls the device according to the command. The MCU status response is shown in the status reporting of the MCU.
For example, the module sends the following command:
Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command word 1 0x09
Data length 2 It depends on the type and number of the “command data unit”
Data N See the “Status data unit” section
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder
The module sends the control command: (The system switch corresponds to DP 3, uses Boolean data type, and the value of 1 indicates power-on)
55 aa 00 09 00 05 03 01 00 01 01 13
Response from the MCU:
Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command word 1 0x09
Data length 2 0x0000
Data 0 None
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder
ACK response form the MCU:
55 aa 03 09 00 00 0b
morgan_flint wrote:Regarding battery discharging, let's see if @p.kaczmarek2 can take a look at the information in my previous post to see if the "closing message" that the WiFi module is sending to the MCU is adequate.
auntlydia wrote:I have tested now with fully charged 1.2V AAA rechargeable batteries. After only 3 days the device was out of sufficient power and kept then rebooting every now and then, and in consequence lost its time setting. I suppose at some point the power is enough to supply the display and sensor, but not to establish a frequent WiFi connection. Have others similar results? I will test with the same batteries with original Tuya firmware and see if there is a difference. Compared to TH01 sensor, which lasts several weeks or even months with fresh batteries with openbk, this is a huge difference.
morgan_flint wrote:I finally could repair my scope yesterday, so I'll take a new look at the communication between U3 and U8.
spin55 wrote:Unless there is an error, the command to send would be: 55aa00090008110200040000000524 for a reporting interval of 5 minutes.
And TuyaMCU should answer with: 55aa030900000b.
spin55 wrote:The problem of battery depletion seems to be related to the type of base technology, which is why Zigbee is much more efficient for battery-powered devices because this type of module consumes much less in Tx mode than conventional WiFi.
morgan_flint wrote:I agree Zigbee would be more efficient, but I also think there's a problem with the terminating sequence sent by OBK to the MCU, as I said here, because with OBK the module remains connected for a long time each time it's powered on by the MCU (more than a minute) while with the original FW it goes off just after the communication with the MCU ends (about 10 seconds).
morgan_flint wrote:I also have looked WiFi for low power protocol for the last message sent to the module (55AA000B00000A) and it's response (55AA000B000201505D). The first one is "MCU obtains the strength of the connected router" (I understand the MCU asks the module for the signal strength) and the response from the module is "Module returns current value of strength (80)". None of these seem to have any meaning in the "normal" protocol, nor could I find the meaning of the last answer (repeated three times) of the module with the OBK FW (55AA000800010008), being this one the more similar one (55 aa 00 08 00 00 07, Query DP status).
So, probably, the MCU is waiting for the strength signal data and receives instead a query it doesn't understand, so remains a long time waiting for the answer without disconnecting the module, until it finally gives up
morgan_flint wrote:I had tried also that, but if I hit "send numbers" nothing happens, and if I hit "send ascii" I get the same result as of pasting directly to the terminal...
I must have something wrong with my configuration
spin55 wrote:Como conectas UART Usb con placa??
Conectas Tx y Rx de USB a Tx y Rx de módulo WiFi??.
spin55 wrote:I forgot to tell you that to prevent the WiFi module from interfering with the USB connection when you want to carry out the test with batteries inserted, you have to set the CEN pin of the module to GND.
p.kaczmarek2 wrote:So it seems that we have to send one extra packet to get sleep earlier?
spin55 wrote:Unless there is an error, the command to send would be: 55aa00090008110200040000000524 for a reporting interval of 5 minutes.
And TuyaMCU should answer with: 55aa030900000b.
p.kaczmarek2 wrote:it's 1.17.302
TL;DR: “Flashing succeeds 100 % when CEN, RX and TX are isolated” and the Wi-Fi module stays powered just 18 s per cycle [Elektroda, spin55, post #20804765] Unit switch is dpID 9; send
55AA001000070101090400010026to force °C [Elektroda, smoeller95s, post #21550660] Battery life rises from 3 days to 6 weeks after v1.17.302 fix [Elektroda, morgan_flint, post #20796796]
Why it matters: correct pinout, dpIDs and flags avoid soft-brick loops and halve power drain.
• MCU board rev V3.7 (2023-11-06) uses step-down RT8008-like regulator, 2.3–3.6 V out [Elektroda, bogovik, post #21007162] • Default Tuya baud: 9 600 bps; do not force 115 200 on battery models [Elektroda, bogovik, post #21007162] • Wi-Fi on-time: 10–18 s (after dpCache fix) [Elektroda, p.kaczmarek2, post #20796796] • Battery thresholds: High ≥ 4 V, Medium 4–3.1 V, Low < 3.1 V [Elektroda, morgan_flint, post #20804228] • dpIDs: 1 Temp, 2 RH, 3 Batt-state, 4 Batt-%, 9 Unit, 10–13 limits, 14–15 alarms, 17–20 report/sensitivity [Elektroda, divadiow, post #21357234]
ntp_setServer 217.147.223.78 and keep ntp_timeZoneOfs correct. Each failed packet logs NTP_SendRequest: Unable to send message [Elektroda, spin55, post #21074156]delay_s 2uartSendHex 55AA00100007010109040001002600 gives °C; 01 gives °F [Elektroda, smoeller95s, post #21550660]temperature_div10 splits the MCU value and HA divides it again, giving 2.2 °C instead of 22 °C [Elektroda, p.kaczmarek2, post #21377733]setChannelType 4 BatteryLevelPercentlinkTuyaMCUOutputToChannel 4 val 4SetStartValue <ch> -1 and add 1 at the end of linkTuyaMCUOutputToChannel … to include it in the dpCache reply packet 0x10 [Elektroda, p.kaczmarek2, post #21385904]