logo elektroda
logo elektroda
X
logo elektroda

PIR motion detector Tuya P01 - TuyaMCU - identification and configuration - CB3S/BK7231N

burba 1983 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21076983
    burba
    Level 9  
    Still a bit off the fringe of this thread: is that board from another (battery-powered) PIR sensor, whose photo I pasted earlier, surely it could be a TuyaMCU? That extra chip on the board (without any lettering) has only 8 legs. In all the threads about tuyaMCUs, however, these are quite large chips.
    Image of an electronic module with components on a circuit board, including a CB3S module. .
    But undoubtedly the device puts you to sleep somehow, because as I mentioned, even the flashing was intermittent until I plugged directly into the CB3S.
    Electronic module and packaging of a PIR sensor. .


    working configuration (already after uploading OpenBeken)

    1. so that the sensor does not go to sleep every few seconds, we lock the reset button in the pressed position
    2. we do not configure any pins directly in OpenBeken, as everything is controlled by the external TuyaMCU chip
    3. via WebApp we upload autoexec.bat
    startDriver TuyaMCU
    startDriver tmSensor
    
    // linkuje dpID 1 TuyaMCU na channel 1
    linkTuyaMCUOutputToChannel 1 val 1
    
    // linkuje dpID3 TuyaMCU na channel 3
    // dpID 3 is battery state - low(0), mid(1) and high(2)
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 Battery
    linkTuyaMCUOutputToChannel 3 enum 3
    
    //tworzy reverse mirror ch1 na ch2
    addChangeHandler Channel1 == 0 setChannel 2 1
    addChangeHandler Channel1 != 0 setChannel 2 0
    

    4. set flags 10, 37, 43
    5. set all other parameters for our system: wifi, ip, mqtt, etc.
    Screenshot of initial start value settings for channels in the OpenBeken system. List of available configuration flags in OpenBeken system for TuyaMCU devices. OpenBeken web interface with autoexec.bat file editing. Screenshot of pin configuration in OpenBeken software. .
  • ADVERTISEMENT
  • #2 21076988
    p.kaczmarek2
    Moderator Smart Home
    It could be the TuyaMCU, but more testing would need to be done:
    - is the UART RX1 and TX1 connected to this circuit in SO8? If so, it's probably TuyaMCU
    - does this transistor Q1 switch on the power supply to the WiFi module? If so, it's probably TuyaMCU turning off the WiFi module with it
    - does the read 2MB config (or just the Tuya config partition) have a baud setting in Tuya JSON, or regular pins?
    - if you leave the device without moving it, is 3.3V is still on the VDD of the WiFi module, or does it disappear (see TuyaMCU unplugging the power supply with a transistor)
    - if you hook up a USB to UART converter, more precisely ground to ground and the RX of the converter to (at will) RX1 or TX1 of the WiFi module, are you able to receive on 9600 or 115200 any communication, packets in the UART, e.g. in Realterm?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21077738
    burba
    Level 9  

    Yes, it's TuyaMCU. It works quite nicely with such an autoexec.bat
    startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 1 Motion
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 3 Readonly
    setChannelLabel 3 Battery

    Interestingly, in the sleep state it doesn't draw any detectable current for my power supply. And yet it wakes up immediately when something moves. It's as if the PIR sensor is somehow internally powered - maybe a capacitor of some sort? Of course, it takes quite a while before the wifi connects and the sensor reports in MQTT - about 12s. In the excited state it takes 55-75mA.
    USB Power Quick board and PIR motion sensor on a desk.
  • ADVERTISEMENT
  • #4 21077850
    p.kaczmarek2
    Moderator Smart Home
    Simply put, a small amount of current is drawn in the sleep state.
    This autoexec.bat is probably missing the second linkTuyaMCUOutputToChannel to retrieve the battery state.
    And this state itself is probably an enumerator, LowMidHigh
    Helpful post? Buy me a coffee.
  • #5 21079983
    burba
    Level 9  
    "linkTuyaMCUOutputToChannel" was there, it just cut it off for me when pasting. And the channel type turned out best to be "ReadOnlyLowMidHigh"
     startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 1 Motion
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 Battery
    linkTuyaMCUOutputToChannel 3 enum 3 
    .
  • #6 21079987
    p.kaczmarek2
    Moderator Smart Home
    Actually, you don't have to be limited to the channel types in the list anymore. I've recently added publishFile, this is the command that does the MQTT publish from a LittleFS file, where you can put any JSON for Home Assistant. There you can freely configure how HA will see a channel.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 21080136
    burba
    Level 9  

    Unfortunately, however, there is a problem with this PIR with TuyaMCU.
    I have observed that it works in the following way:
    -When motion is detected, the MCU activates the wifi module, connects to MQTT, reports sensor wake-up and goes to sleep
    After 30 seconds, it wakes up again, connects to MQTT, reports no motion
    -puts to sleep until the next motion is detected
    Theoretically.

    The problem is that for HA the sensor has a status of "detected" all the time. The sensor's OBK web page, on the other hand, correctly shows "no motion" after 30s, and remains in this status until the next motion detection.
    User interface for the PIR1_OpenBK7231N_E1ABA97B sensor showing no motion status and available configuration options. Interface screen of a PIR device with MQTT and Home Assistant issues.

    I've looked in the logs - and there's something I don't like here:
    
    Info:GEN:CHANNEL_Set channel 3 has changed to 2 (flags 0)
    Info:MQTT:Channel has changed! Publishing 2 to channel 3 
    Info:MQTT:Publishing val 2 to obkE1ABA97B/3/get retain=0
    ...
    Info:GEN:No change in channel 1 (still set to 0) - ignoring
    Info:MQTT:Publishing val OpenBK7231N 1215_merge_c8c1fc07825f May 9 2024 06:25:07 to obkE1ABA97B/build retain=0
    ...
    Info:GEN:CHANNEL_Set channel 1 has changed to 1 (flags 0)
    Info:MQTT:Channel has changed! Publishing 1 to channel 1 
    Info:MQTT:Publishing val 1 to obkE1ABA97B/1/get retain=0
    

    It appears to me that:
    1. the battery level (channel 3) is reported as "changed" every time. - even though it doesn't actually change (this of course doesn't interfere with anything)
    2. the PIR status (channel 1) is only actually reported to MQTT on this second connection, after 30s, after changing to the value "1", i.e. "no motion". On the other hand, when motion is detected (value "0"), the OBK ignores the change and does not send anything to MQTT, claiming that there was no change.
    3. The HA keeps the sensor status as "detected", because it treats the "1" and "0" values it gets from the OBK in reverse.
  • #8 21080261
    p.kaczmarek2
    Moderator Smart Home
    The description of the problem indicates that you should set the initial channel values in Startup Config to -1, i.e. to 'remember last state'. This will ensure that the module remembers the previous state and reports changes correctly. Don't worry about the flash memory consumption, the variable writing system optimises the flash erase cycles (writes in blocks of 64 bytes and only when the page fills up it deletes it once)

    And if you don't want to do this remember, you can set the initial states e.g. to 999, then the change will also be reported.

    After all, you would be wise to put the configuration in a separate topic....
    Helpful post? Buy me a coffee.
  • #9 21081259
    burba
    Level 9  
    Very cool it works with that "-1", thanks. Entering 999 would have some advantage?
    Only still a question of reversing the action - the status on the OBK website shows motion/no motion correctly, and HA the other way around. Is it possible to do this on foot somehow? Would a new Motion_Inv channel type be needed?
  • #10 21081294
    p.kaczmarek2
    Moderator Smart Home
    burba wrote:
    Very cool it works with this "-1", thanks. Entering 999 would have some advantage?

    Setting -1 causes the channel value to write to flash, we have flash write optimization, so I don't think it would hurt, so I would only enter 999 if I knew the changes would be really very frequent....


    burba wrote:

    Only still a matter of reversing the action - the status on the OBK website shows motion/no motion correctly, and HA the other way around.

    Maybe map the channel from TuyaMCU (here 20) to the channel from Motion (here 21) with the reversal:
    
    // change handler will not fire if channel is already 0...
    setChannel 20 999
    addChangeHandler Channel20 == 0 setChannel 21 1
    addChangeHandler Channel20 != 0 setChannel 21 0
    // make change
    setChannel 20 0
    // channel 21 is now 1
    

    Or suspect JSON Home Assistant from the Motion channel, then create a file on LittleFS, paste the JSON there, swap payloads with places, and execute the command:
    
    publishFile homeassistant/light/multifunction_alarm_OpenBK7231N_E1552B06_light_1/config myFile.txt 1
    

    Then you make your own custom HA discovery, and that way you can freely modify what is published
    Helpful post? Buy me a coffee.
  • #11 21082341
    burba
    Level 9  

    a couple of questions:
    1. how to preview the JSON of the motion channel in HA? in File Editor I only have a couple of .yaml files and a couple of directories where I didn't find anything interesting
    2. is there any option to add time signatures to OBK logs? I understand that without NTP the real time won't be there, but maybe at least since the last reboot? With TuyaMCU sleeping every now and then, it's hard to recognize what's new and what's old.

    Actually it works reasonably well with this configuration:
    Screenshot of the OpenBK7231N user interface showing start value settings for channels. Screenshot of pin settings and channel types in device configuration system.

    The type of Channel 1, i.e. the original channel to which the PIR from TuyaMCU is mapped, set as ReadOnly is probably necessary to be able to set the initial value for this channel to "-1". Without setting "-1" for both channels ch1 (the primary for the PIR) and ch2 (its "mirror" with the inverted value) the HA does not get sensor updates.
    For that a fixed IP address and of course the MQTT configuration.

    autoexec.bat
     
    startDriver TuyaMCU
    startDriver tmSensor
    
    linkTuyaMCUOutputToChannel 1 val 1
    
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 Battery
    linkTuyaMCUOutputToChannel 3 enum 3
    
    addChangeHandler Channel1 == 0 setChannel 2 1
    addChangeHandler Channel1 != 0 setChannel 2 0
    

    It works "reasonably well", because after starting the sensor it always appears in the "detected" state and only after less than a minute it changes status to "clear"
    Unfortunately, attempts to add in autoexec.bat any of the commands: setChannel 1 1, setChannel 1 0, setChannel 2 1, setChannel 2 0 end up with the sensor status in HA "locking" on one of the positions and not being updated.

    The way for TuyaMCU to constantly disable the sensor seems to be to lock the button in the pressed position. This makes things radically easier. Doing anything with a 4s work/40s sleep rhythm is eminently tiring.
  • #12 21084019
    p.kaczmarek2
    Moderator Smart Home
    1. i don't think i know of such an option, there are things added manually in configuration.yaml. If you find a way to do what you ask then let me know.
    2. There is an NTP driver but it only gets timestamps a few moments after the WiFi connection is established anyway. Timestamps could be added somehow, if only in code, but why are they needed? HA doesn't keep a log?

    Motion_inv I can easily add, or some kind of rotation option when mapping. And anyway...

    It's rather a momentary thing. Bytes of code won't arrive much either...
    I'm giving update 1.17.584
    Now the mapping has arguments:
    
    linkTuyaMCUOutputToChannel [dpId][varType][channelID][bDPCache-Optional][mult-optional][bInverse]
    

    bDPCache give 0, mult 1, bInverse 1

    burba wrote:

    The way for TuyaMCU to constantly disable the sensor seems to be to lock the button in the pressed position. This makes things radically easier. Doing anything in a 4s work/40s sleep rhythm is eminently tiresome.


    Because of this TuyaMCU issue, I do little testing of such devices.
    Helpful post? Buy me a coffee.
  • #13 21295958
    getbk
    Level 1  
    Hallo,

    wie ist bei diesem Teil die Pin-Konfiguration?

    Vielen Dank
  • #14 21332428
    bialy26
    Level 2  
    I have reprogrammed two identical sensors and don't know where to report the problem. Probably best here.
    The situation has happened 3 times. When the AAA batteries run down, the detector does not reconnect to the network, it flashes an LED as it detects movement, but the detector is dead. Various ways of flashing work, but the detector still does not connect to WiFi. What works 100% is uploading the original backup file and flashing OpenBeken again.
    These were the flags I had: 10, 27, 29, 35, 37, 43.
    Maybe it's something wrong with them?
    Normally removing the battery and inserting it still before discharging, everything is ok.
  • #15 21333335
    viktorpot
    Level 2  
    I managed to convert this device using the Tuya Cloud cutter selecting by firmware version 2.1.8 and low power common ty name

    Everything worked fine apart from the fact that I have to regularly (every 1s) press the button in order for this device to stay on wifi. I updated autoxec according to this thread, and thing started looking better and better until I configured MQTT and since then device does not connect to WIFI, the light is on all the time. Holding the button does not go to slow blink mode, but rather turns off the light.

    Do you know how to cure the situation? And also how to configure it so it does not go offline. I plan to use it with power supply so I don't need any power saving.
    Here is my log before MQTT config change:
    
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 271146/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 190115/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 191058/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 191873/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 191722/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:tttt
    Info:MAIN:Time 6, idle 191221/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 181964/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 86951/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 87232/s, free 73552, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 276680/s, free 73592, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 189005/s, free 73592, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 185902/s, free 73592, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 01 12 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 3 has changed to 1 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 1 to channel 3 
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 90 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 3 changes count.
    Error:CMD:no file early.bat err -2
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    Info:MAIN:Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID [Cottage]
    Info:MAIN:Using Pass [*****]
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk0D2CE54E/ subT cmnd/obk0D2CE54E/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 271479/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 189972/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 190996/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 192015/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 191682/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:ghtrhtr
    Info:MAIN:Time 6, idle 183352/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 192621/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 90337/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 85557/s, free 73552, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 186812/s, free 73592, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 188804/s, free 73592, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    bT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 269691/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 190444/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 190658/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 192038/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 192017/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:htrht
    Info:MAIN:Time 6, idle 185572/s, free 73096, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 182950/s, free 73096, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 84808/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 86932/s, free 73576, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 192993/s, free 73616, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 193061/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 195464/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 08 00 0C 00 02 02 02 02 02 02 01 04 00 01 01 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 8 (QueryState) len 19
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 1, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 1 has changed to 1 (flags 0)
    
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command setChannel 2 0
    Info:GEN:No change in channel 2 (still set to 0) - ignoring
    
    Info:MAIN:Time 15, idle 182761/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 01 12 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 3 has changed to 1 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 1 to channel 3 
    Info:MAIN:Time 16, idle 182513/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 17, idle 190322/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    in_Init_Before_Delay
    Info:CFG:####### Boot Count 93 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 3 changes count.
    Error:CMD:no file early.bat err -2
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    Info:MAIN:Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID [Cottage]
    Info:MAIN:Using Pass [htrhtt
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk0D2CE54E/ subT cmnd/obk0D2CE54E/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 269388/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 190520/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 190999/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 192002/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 191957/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:htrhtrht
    Info:MAIN:Time 6, idle 183281/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 183163/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 85109/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 86780/s, free 73584, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 193630/s, free 73624, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 191770/s, free 73624, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 194158/s, free 73624, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 02 13 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 2
    Info:GEN:CHANNEL_Set channel 3 has changed to 2 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 2 to channel 3 
    MAIN:Using SSID [Cottage]
    Info:MAIN:Using Pass [htrhtrht]
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk0D2CE54E/ subT cmnd/obk0D2CE54E/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 271441/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 190031/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 191049/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 192034/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 191691/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:htrhtr
    Info:MAIN:Time 6, idle 186794/s, free 73096, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 183389/s, free 73096, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 85801/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 88485/s, free 73576, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 185372/s, free 70776, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 194738/s, free 70776, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 196256/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 08 00 0C 00 02 02 02 02 02 02 01 04 00 01 00 25 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 8 (QueryState) len 19
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 1, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 0
    Info:GEN:No change in channel 1 (still set to 0) - ignoring
    
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 01 12 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 3 has changed to 1 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 1 to channel 3 
    Info:MAIN:Time 15, idle 180755/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 16, idle 188809/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 17, idle 190722/s, free 73616, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    in_Init_Before_Delay
    Info:CFG:####### Boot Count 96 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 3 changes count.
    Error:CMD:no file early.bat err -2
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    Info:MAIN:Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID [Cottage]
    Info:MAIN:Using Pass [htrhtrhrh]
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk0D2CE54E/ subT cmnd/obk0D2CE54E/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 271172/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 189017/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 189697/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 192252/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 190766/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:htrhtrh
    Info:MAIN:Time 6, idle 181724/s, free 73112, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 183219/s, free 73112, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 85536/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 86880/s, free 73560, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 189383/s, free 73600, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 189625/s, free 73600, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 188521/s, free 73600, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 01 12 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 3 has changed to 1 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 1 to channel 3 
    in_Init_Before_Delay
    Info:CFG:####### Boot Count 97 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 3 changes count.
    Error:CMD:no file early.bat err -2
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    Info:MAIN:Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID [Cottage]
    Info:MAIN:Using Pass [htrhtrhtr]
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk0D2CE54E/ subT cmnd/obk0D2CE54E/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk0D2CE54E/ subT obk0D2CE54E/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 1
    Info:EVENT:CMD_AddChangeHandler: added Channel1 with cmd setChannel 2 0
    Info:MAIN:Time 1, idle 265842/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 72 6A 7A 6F 6E 39 6B 79 78 70 6F 65 6B 73 6A 33 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 26 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"rjzon9kyxpoeksj3","v":"1.0.0"}
    Info:MAIN:Time 2, idle 188231/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 188361/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 191043/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 189883/s, free 78608, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid:Cottage key:ttttt
    Info:MAIN:Time 6, idle 180414/s, free 72848, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 182567/s, free 73088, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 84715/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 73080, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=b8:06:0d:2c:e5:4e
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 11, idle 87649/s, free 73560, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 186404/s, free 73416, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 13, idle 189742/s, free 73224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 196063/s, free 73608, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:Received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 2 (MCUconf) len 7
    Info:TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:Received: 55 AA 00 05 00 05 03 04 00 01 01 12 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 3, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 1
    Info:GEN:CHANNEL_Set channel 3 has changed to 1 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 1 to channel 3 
    


    EDIT: Found the device again using its AP, WIFI configuration was lost from some reason, so I reconfugured and thing are working fine again apart from the fact that device does turn off by itself, need to figure out how to stop it.

    Last but not least, how to use it as PIR sensor via MQTT? I use MQTT explorer to see what is send, but nothing sensible here for motion detect or is it?:
    Screenshot of MQTT Explorer interface showing details of the pir2 sensor.

Topic summary

The discussion focuses on identifying and configuring a PIR motion detector board, suspected to use a TuyaMCU with a CB3S/BK7231N WiFi module. Verification steps include checking UART RX1/TX1 connections, transistor Q1 controlling WiFi power, and UART communication at 9600 or 115200 baud. The device operates with OpenBeken firmware using an autoexec.bat script to start TuyaMCU and tmSensor drivers, mapping TuyaMCU outputs to motion and battery channels. The PIR sensor exhibits near-zero current draw in sleep mode and wakes immediately on motion, though WiFi connection and MQTT reporting take about 12 seconds. Battery state is reported as an enumerator (LowMidHigh) via a ReadOnlyLowMidHigh channel type. A known issue is that Home Assistant (HA) shows continuous motion detection status despite the device correctly reporting no motion on its web interface; this is resolved by setting initial channel values to -1 or 999 to ensure state changes are published. Channel inversion for motion status in HA can be implemented via channel mapping with change handlers or custom MQTT JSON publishing using LittleFS files. The latest firmware update (1.17.584) adds arguments to linkTuyaMCUOutputToChannel for inversion and caching. Users report problems with battery-powered sensors failing to reconnect after battery depletion, requiring re-flashing with original firmware and OpenBeken. Power supply use is considered to avoid sleep issues, but configuration challenges remain. NTP time stamping is limited due to intermittent WiFi sleep cycles. Overall, the TuyaMCU integration with CB3S/BK7231N modules requires careful configuration of channels, initial states, and MQTT publishing to achieve reliable motion detection reporting and battery status monitoring in HA environments.
Summary generated by the language model.
ADVERTISEMENT