logo elektroda
logo elektroda
X
logo elektroda

Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

caubergjef57 14076 193
ADVERTISEMENT
  • #151 20563989
    p.kaczmarek2
    Moderator Smart Home
    @spin55 , if you use the command I have given, the one with -t switch, it will ping forever.

    Please check.

    It looks like everything is working except the web panel?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #152 20564003
    spin55
    Level 17  
    Oh well. There I will leave it running to see if it catches something.
  • #153 20567416
    spin55
    Level 17  
    Hello,
    I'm sorry I can't continue the thread at this time because there are family matters that need my attention.
    p.kaczmarek2, the latest version OpenBK7231N_1.17.98 seems to work fine, but after some time of use the inter-chip communication (Wifi- TuyaMCU) gets corrupted. I think that in 15 days I will have enough time to make a detailed comment on all the problems that I have been encountering. Without monitoring the communication with Realterm it would have been impossible for me to see what is happening.

    Regards
  • #154 20577587
    spin55
    Level 17  
    The ESP82** chip had to be erased before flashing to avoid unstable operation. Is there any possibility to do the same with BK7321N?

    Because I have had to make multiple firmware changes during the tests, both via USB and OTA, I have been able to see strange behaviors reminiscent of the ESP82** when they were not previously erased.
  • ADVERTISEMENT
  • #155 20577775
    p.kaczmarek2
    Moderator Smart Home
    Erasing full 2MB of BK7231 will also erase RF partition and destroy MAC address, it will end with 00 00 00 00 bytes. It may also reduce WiFi performance.
    You may use Restore RF button on BK7231 easy GUI flasher or on our Web App, to restore RF, but it will not be as good as the factory RF.
    During my time of BK7231 testing and flashing, I had one or two strange BK7231N which were buggy with original RF and were fixed by doing "restore RF" but in most cases it is not recommended.
    Still, you can do a 2MB backup and try.
    Helpful post? Buy me a coffee.
  • #156 20577863
    spin55
    Level 17  
    Thanks for the clarification.

    Is it normal that the SSID and Wifi Password data are kept after flashing via USB?

    Until now, the OTA update destroyed the autoexec.bat configuration. It no longer destroys it in the latest firmware versions?
  • #157 20577886
    DeDaMrAz
    Level 19  
    spin55 wrote:
    Thanks for the clarification.

    Is it normal that the SSID and Wifi Password data are kept after flashing via USB?

    Until now, the OTA update destroyed the autoexec.bat configuration. It no longer destroys it in the latest firmware versions?


    Regarding OTA update, LFS purge was a problem that was only influencing N devices and was fixed in one of the previous versions, so autoexec will stay intact after OTA update as the autoexec deletion is bringing more problems than it solves.

    There is an issue that affects certain N devices that is reflecting exactly as you described and for such devices RF recovery is not recommended as well as it can interfere with WiFi functionality and destroy the MAC address - meaning it is known and can be replicated (I have 2 such devices).
  • #158 20577962
    spin55
    Level 17  
    With the latest firmware versions the device works "almost" fine.

    OpenBK7231N_1.17.104.rbl

    Let's see if I can describe step by step what I've seen:

    It starts working fine. It transmits the detection information but only publishes the reset information. For this reason only 1 is published in MQTT, the one for motion detection (0) is not published because it assumes that the variable is already at zero and does not change. I've fixed it by forcing publish with a script called from autoexec.bat.

    MQTT log:
    
    Message 22 received on obk1F8D1236/1/get at 11:18:
    1
    QoS: 0 - Retain: false
    Message 21 received on obk1F8D1236/1/get at 11:14:
    1
    QoS: 0 - Retain: false
    Message 20 received on obk1F8D1236/1/get at 11:13:
    1
    QoS: 0 - Retain: false
    Message 19 received on obk1F8D1236/1/get at 11:09:
    1
    QoS: 0 - Retain: false
    Message 18 received on obk1F8D1236/1/get at 11:04:
    1
    QoS: 0 - Retain: false
    Message 17 received on obk1F8D1236/1/get at 11:04:
    1
    QoS: 0 - Retain: false
    Message 16 received on obk1F8D1236/1/get at 11:02:
    1
    QoS: 0 - Retain: false
    Message 15 received on obk1F8D1236/1/get at 11:00:
    1
    QoS: 0 - Retain: false
    Message 14 received on obk1F8D1236/1/get at 10:55:
    1
    QoS: 0 - Retain: false
    Message 13 received on obk1F8D1236/1/get at 10:52:
    1
    QoS: 0 - Retain: false
    Message 12 received on obk1F8D1236/1/get at 10:49:
    1
    QoS: 0 - Retain: false
    Message 11 received on obk1F8D1236/1/get at 10:42:
    1
    QoS: 0 - Retain: false
    Message 10 received on obk1F8D1236/1/get at 10:39:
    1
    QoS: 0 - Retain: false
    Message 9 received on obk1F8D1236/1/get at 10:33:
    1
    QoS: 0 - Retain: false
    Message 8 received on obk1F8D1236/1/get at 10:30:
    1
    QoS: 0 - Retain: false
    Message 7 received on obk1F8D1236/1/get at 10:27:
    1
    QoS: 0 - Retain: false
    Message 6 received on obk1F8D1236/1/get at 10:21:
    1
    QoS: 0 - Retain: false
    Message 5 received on obk1F8D1236/1/get at 10:19:
    1
    QoS: 0 - Retain: false
    Message 4 received on obk1F8D1236/1/get at 10:16:
    1
    QoS: 0 - Retain: false
    Message 3 received on obk1F8D1236/1/get at 10:11:
    1
    QoS: 0 - Retain: false
    Message 2 received on obk1F8D1236/1/get at 10:06:
    1
    QoS: 0 - Retain: false
    Message 1 received on obk1F8D1236/1/get at 10:04:
    1
    QoS: 0 - Retain: false
    Message 0 received on obk1F8D1236/1/get at 10:01:
    0
    QoS: 0 - Retain: true


    WebApp Log:
    
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 1 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 9 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:ssid:ONO_MAC key:
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk1F8D1236/ subT obk1F8D1236/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens/ subT bekens/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk1F8D1236/ subT cmnd/obk1F8D1236/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens/ subT cmnd/bekens/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk1F8D1236/ subT obk1F8D1236/+/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 1 type changed to readonly
    Info:GEN:Channel 4 type changed to readonly
    Info:MAIN:Time 1, idle 275224/s, free 71736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 185637/s, free 71736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 63129/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 0/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 0/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    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:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk1F8D1236
    mqtt_host 192.168.1.45:1883
    Info:MAIN:Time 6, idle 109285/s, free 71376, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 7, idle 182606/s, free 71224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 188253/s, free 71032, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 189599/s, free 71800, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk1F8D1236/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk1F8D1236/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to obk1F8D1236/+/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk1F8D1236/1/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk1F8D1236/4/get
    Info:MQTT:Publishing val obk1F8D1236 to obk1F8D1236/host retain=0
    Info:MAIN:Time 10, idle 180659/s, free 71800, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-63,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MQTT:Publishing val Build on May  3 2023 09:13:10 version 1.17.98 to obk1F8D1236/build retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 01 04 00 01 01 10 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 12 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    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 obk1F8D1236/1/get retain=0
    Info:MAIN:Time 11, idle 190493/s, free 71800, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk1F8D1236/1/get
    Info:MQTT:Publishing val 38:1f:8d:12:36:69  to obk1F8D1236/mac retain=0
    Info:MAIN:Time 12, idle 175848/s, free 60104, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MQTT:Publishing val 2 to obk1F8D1236/sockets retain=0
    Info:MAIN:Time 13, idle 183632/s, free 71568, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -63 to obk1F8D1236/rssi retain=0
    Info:MAIN:Time 14, idle 189787/s, free 71800, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 14 to obk1F8D1236/uptime retain=0
    Info:MAIN:Time 15, idle 187475/s, free 71800, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 2 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 9 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:ssid: key:
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk1F8D1236/ subT obk1F8D1236/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens/ subT bekens/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk1F8D1236/ subT cmnd/obk1F8D1236/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens/ subT cmnd/bekens/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk1F8D1236/ subT obk1F8D1236/+/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 1 type changed to readonly
    Info:GEN:Channel 4 type changed to readonly
    Info:MAIN:Time 1, idle 281944/s, free 71736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 188747/s, free 71312, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 64075/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 0/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 0/s, free 71752, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    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:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk1F8D1236
    mqtt_host 192.168.1.45:1883
    Info:MAIN:Time 6, idle 109450/s, free 71176, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 7, idle 297145/s, free 71024, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 189474/s, free 71792, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk1F8D1236/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk1F8D1236/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to obk1F8D1236/+/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk1F8D1236/1/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk1F8D1236/4/get
    Info:MQTT:Publishing val obk1F8D1236 to obk1F8D1236/host retain=0
    Info:MAIN:Time 9, idle 188021/s, free 71336, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MQTT:Publishing val Build on May  3 2023 09:13:10 version 1.17.98 to obk1F8D1236/build retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 01 04 00 01 00 0F 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 12 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    Info:GEN:No change in channel 1 (still set to 0) - ignoring
    
    Info:MAIN:Time 10, idle 192406/s, free 71584, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-63,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MQTT:Publishing val 38:1f:8d:12:36:69  to obk1F8D1236/mac retain=0
    Info:MAIN:Time 11, idle 182696/s, free 71544, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 2 to obk1F8D1236/sockets retain=0
    Info:MAIN:Time 12, idle 197047/s, free 71560, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -63 to obk1F8D1236/rssi retain=0
    Info:MAIN:Time 13, idle 191860/s, free 71560, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 13 to obk1F8D1236/uptime retain=0
    Info:MAIN:Time 14, idle 191642/s, free 71560, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38


    autoexec.bat
    
    startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 1 readonly
    // vincular dpid al canal 1
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 4 readonly
    // vincular dpid al canal 4
    linkTuyaMCUOutputToChannel 4 val 4
    startScript pir.bat


    pir.bat
    
    addRepeatingEvent 10 -1 publish "1" $CH1


    MQTT log (with pir.bat):
    
    Message 25 received on obk8D123669/1/get at 16:42:
    0
    QoS: 0 - Retain: false
    Message 24 received on obk8D123669/1/get at 16:41:
    1
    QoS: 0 - Retain: false
    Message 23 received on obk8D123669/1/get at 16:41:
    1
    QoS: 0 - Retain: false
    Message 22 received on obk8D123669/1/get at 16:36:
    0
    QoS: 0 - Retain: false
    Message 21 received on obk8D123669/1/get at 16:36:
    1
    QoS: 0 - Retain: false
    Message 20 received on obk8D123669/1/get at 16:36:
    1
    QoS: 0 - Retain: false
    Message 19 received on obk8D123669/1/get at 16:32:
    0
    QoS: 0 - Retain: false
    Message 18 received on obk8D123669/1/get at 16:31:
    1
    QoS: 0 - Retain: false
    Message 17 received on obk8D123669/1/get at 16:31:
    1
    QoS: 0 - Retain: false
    Message 16 received on obk8D123669/1/get at 16:28:
    1
    QoS: 0 - Retain: false
    Message 15 received on obk8D123669/1/get at 16:28:
    1
    QoS: 0 - Retain: false
    Message 14 received on obk8D123669/1/get at 16:22:
    1
    QoS: 0 - Retain: false
    Message 13 received on obk8D123669/1/get at 16:22:
    1
    QoS: 0 - Retain: false
    Message 12 received on obk8D123669/1/get at 16:16:
    0
    QoS: 0 - Retain: false
    Message 11 received on obk8D123669/1/get at 16:16:
    1
    QoS: 0 - Retain: false
    Message 10 received on obk8D123669/1/get at 16:16:
    1
    QoS: 0 - Retain: false
    Message 9 received on obk8D123669/1/get at 16:12:
    0
    QoS: 0 - Retain: false
    Message 8 received on obk8D123669/1/get at 16:08:
    0
    QoS: 0 - Retain: false
    Message 7 received on obk8D123669/1/get at 16:08:
    1
    QoS: 0 - Retain: false
    Message 6 received on obk8D123669/1/get at 16:05:
    0
    QoS: 0 - Retain: false
    Message 5 received on obk8D123669/1/get at 16:04:
    1
    QoS: 0 - Retain: false
    Message 4 received on obk8D123669/1/get at 16:01:
    0
    QoS: 0 - Retain: false
    Message 3 received on obk8D123669/1/get at 16:01:
    1
    QoS: 0 - Retain: false
    Message 2 received on obk8D123669/1/get at 16:01:
    1
    QoS: 0 - Retain: false
    Message 1 received on obk8D123669/1/get at 15:59:
    0
    QoS: 0 - Retain: false
    Message 0 received on obk8D123669/1/get at 15:58:
    1
    QoS: 0 - Retain: false


    Sometimes the replenishment is skipped. Others do not respond. Sometimes it does not publish the detection. All this while the communication between chips is correct (monitored with Realterm).

    More tomorrow...
  • #159 20578008
    DeDaMrAz
    Level 19  
    Nice explanation, I am waiting for some PIR sensors to arrive so I can play with them and will join this discussion more actively to make this sensor 100% supported and bug free, and @p.kaczmarek2 will obviously help out. Just be a bit more patient as it is hard for us (or me) to work without the device in our hands.
  • ADVERTISEMENT
  • #160 20578050
    p.kaczmarek2
    Moderator Smart Home
    Hmm nice, but maybe instead of forcing a publish, just use SetStartValue to make channel remember its previous value after reboot? I am not sure...
    but the usage would be like:
    
    SetStartValue channelIndex -1
    

    start value -1 means "remember last state".

    Or... if you don't want to save value in flash... you could do a setChannel in autoexec.bat and set it to for example, value like 999 or just -1, so both 0 and 1 makes a change...

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • #161 20578590
    spin55
    Level 17  
    p.kaczmarek2 wrote:
    Or... if you don't want to save value in flash... you could do a setChannel in autoexec.bat and set it to for example, value like 999 or just -1, so both 0 and 1 makes a change...


    Very nice proposal that would prevent double posting, but I can't access autoexec.bat because the device doesn't go into pairing mode with this firmware.

    55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 
    6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62                
    55 AA 00 03 00 00 02                                                    
    55 AA 00 03 00 00 02 -->  Here it should stop                                                  
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 05 00 05 01 04 00 01 00 0F                                     
    55 AA 00 05 00 08 04 02 00 04 00 00 00 64 7A FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC F


    Added after 5 [minutes]:

    Go on:

    When the communication between MCU's gets corrupted, what I do is flash via USB the OpenBK7231N_QIO_1.15.599.bin firmware that allows me to pair and access WebApp to configure autoexec.bat. Once this is done I update via OTA to the current firmware. I do it this way because often you can't put the device in pairing mode with this firmware.

    I have also verified that the MAC is set to 0 when the copy of the original firmware is loaded via USB and it is returned to Openbeken.

    As I have already mentioned, I have a device that has an ESP8266 chip flashed with Esphome. I took screenshots of the communication between MCU's with Realterm and compared to the one that BK7321N has, there are important differences in the way of processing the information. They use different versions of the Tuya protocol and I think that the version {"P":"Okurono2XLVRV0fB","v":"1.1.0"} that TuyaMCU Esphome has is more efficient because it saves better battery consumption, compared to version { "p":"lydwobwyqxiyob9h","v":"1.0.5"} running TuyaMCU OpenBeken.

    ESP8266 Log Rx:

    55 AA 00 01 00 24 7B 22 50 22 3A 22 4F 6B 75 72 6F 6E 6F 32 58 4C 56 52 
    56 30 66 42 22 2C 22 76 22 3A 22 31 2E 31 2E 30 22 7D 19                
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 05 00 0A 65 01 00 01 00 66 04 00 01 03 E3
    ------------------------                      
    55 AA 00 01 00 24 7B 22 50 22 3A 22 4F 6B 75 72 6F 6E 6F 32 58 4C 56 52 
    56 30 66 42 22 2C 22 76 22 3A 22 31 2E 31 2E 30 22 7D 19                
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 05 00 0A 65 01 00 01 00 66 04 00 01 03 E3


    BK7321N Log Rx:

    55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 
    6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62                
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 05 00 05 01 04 00 01 01 10                                     
    55 AA 00 05 00 08 04 02 00 04 00 00 00 64 7A FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 00                                                                      
    55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 
    6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62                
    55 AA 00 02 00 00 01                                                    
    55 AA 00 02 00 00 01                                                    
    55 AA 00 05 00 05 01 04 00 01 00 0F FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC


    BK7321N makes two Wi-Fi connections: one to send the motion sensor reset (55 AA 00 05 00 05 01 04 00 01 01 10) and another to report that there is an intrusion (55 AA 00 05 00 05 01 04 00 01 00 0F).

    ESP8266 only makes one connection to send intrusion (55 AA 00 05 00 0A 65 01 00 01 00 66 04 00 01 03 E3). Send sensor and battery status in the same command 05.

    In addition, the reset time of the motion sensor in BK7321N is 2 minutes or more and sometimes it fails. The one for ESP8266 is much shorter.

    But this depends on the firmware of the TuyaMCU chip, so for the moment it is untouchable, unless someone dares to reprogram it.

    Another thing that is observed with Realterm, is that there are no FC's between chip communications in ESP8266. Imagine the amount of FC generated for 2 minutes or more. There are not so many here because I have edited them.

    ESP8266 Log Tx:

    55 AA 00 01 00 00 00                                                    
    55 AA 00 02 00 01 02 04                                                 
    55 AA 00 02 00 01 03 05                                                 
    55 AA 00 02 00 01 04 06                                                 
    55 AA 00 05 00 01 00 05 49 00 FF 04 80 3D F3 FE FE                      
    55 AA 00 01 00 00 00                                                    
    55 AA 00 02 00 01 02 04                                                 
    55 AA 00 02 00 01 03 05                                                 
    55 AA 00 02 00 01 04 06                                                 
    55 AA 00 05 00 01 00 05



    BK7321N Log Tx:

    55 AA 00 01 00 00 00
    55 AA 00 02 00 01 03 05                                                 
    55 AA 00 02 00 01 04 06                                                 
    55 AA 00 05 00 01 00 05                                                 
    55 AA 00 05 00 01 00 05 FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 00             
    55 AA 00 01 00 00 00                                                    
    55 AA 00 02 00 01 03 05                                                 
    55 AA 00 02 00 01 04 06                                                 
    55 AA 00 05 00 01 00 05 FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC


    In the ESP8266 Tx line, one more command line can be seen Report the network status of the device (55 AA 00 02 00 01 03 05 --> Wi-Fi has been configured, but not connected to the router).

    https://developer.tuya.com/en/docs/iot/tuyacl...niversalserialaccessprotocol?id=K95afs9h4tjjh
  • #162 20579398
    spin55
    Level 17  
    After two days of proper communication between MCU's, it starts to get corrupted. On the first and second reboots it can be seen that it doesn't even respond to the 01 command anymore. It's like the TuyaMCU driver is not loaded. autoexec.bat corruption?

    Corruption Begins:
    
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC 00                                                             
    55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 
    6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62                
    55 AA 00 02 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00
    -------------------------
    New boot:
    
    FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC
    -----------------------
    New boot:
    
    FE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC 00 00 00 00 00 00 00 00 00 00 
    00 00 00 00
    --------------
  • #163 20582898
    spin55
    Level 17  
    p.kaczmarek2, I was about to validate your firmware OpenBK7231N_QIO_1.17.104 and suddenly I find myself again with symptoms of what I call code corruption.

    Those 00s that you see seem to be generated by TuyaMCU to try to communicate with the Wifi module, but the communication between chips according to the Tuya protocol disappears as if autoexec.bat was not executed to load the tuyaMCU and tmSensor drivers.


    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol


    I was able to access autoexec.bat and edit it to add SetChannel 1 2 as you suggested and it works. There is no duplication of posts in MQTT anymore.

    autoexec.bat

    startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 1 readonly
    // vincular dpid al canal 1
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 4 readonly
    // vincular dpid al canal 4
    linkTuyaMCUOutputToChannel 4 val 4
    SetChannel 1 2


    MQTT Log

    Message 24 received on obk8D123669/1/get at 13:55:
    0
    QoS: 0 - Retain: false
    Message 23 received on obk8D123669/1/get at 13:55:
    1
    QoS: 0 - Retain: false
    Message 22 received on obk8D123669/1/get at 13:53:
    0
    QoS: 0 - Retain: false
    Message 21 received on obk8D123669/1/get at 13:52:
    1
    QoS: 0 - Retain: false
    Message 20 received on obk8D123669/1/get at 13:50:
    0
    QoS: 0 - Retain: false
    Message 19 received on obk8D123669/1/get at 13:48:
    1
    QoS: 0 - Retain: false
    Message 18 received on obk8D123669/1/get at 13:46:
    0
    QoS: 0 - Retain: false
    Message 17 received on obk8D123669/1/get at 13:46:
    1
    QoS: 0 - Retain: false
    Message 16 received on obk8D123669/1/get at 13:44:
    0
    QoS: 0 - Retain: false
    Message 15 received on obk8D123669/1/get at 13:44:
    1
    QoS: 0 - Retain: false
    Message 14 received on obk8D123669/1/get at 13:42:
    0
    QoS: 0 - Retain: false
    Message 13 received on obk8D123669/1/get at 13:42:
    1
    QoS: 0 - Retain: false
    Message 12 received on obk8D123669/1/get at 13:40:
    0
    QoS: 0 - Retain: false
    Message 11 received on obk8D123669/1/get at 13:40:
    1
    QoS: 0 - Retain: false
    Message 10 received on obk8D123669/1/get at 13:38:
    0
    QoS: 0 - Retain: false
    Message 9 received on obk8D123669/1/get at 13:38:
    1
    QoS: 0 - Retain: false
    Message 8 received on obk8D123669/1/get at 13:36:
    0
    QoS: 0 - Retain: false
    Message 7 received on obk8D123669/1/get at 13:35:
    1
    QoS: 0 - Retain: false
    Message 6 received on obk8D123669/1/get at 13:34:
    0
    QoS: 0 - Retain: false
    Message 5 received on obk8D123669/1/get at 13:33:
    1
    QoS: 0 - Retain: false
    Message 4 received on obk8D123669/1/get at 13:32:
    0
    QoS: 0 - Retain: false
    Message 3 received on obk8D123669/1/get at 13:31:
    1
    QoS: 0 - Retain: false
    Message 2 received on obk8D123669/1/get at 13:29:
    0
    QoS: 0 - Retain: false
    Message 1 received on obk8D123669/1/get at 13:29:
    1
    QoS: 0 - Retain: false
    Message 0 received on obk8D123669/1/get at 13:27:
    0
    QoS: 0 - Retain: false


    I had timed the reset cadence and it is 1 minute and 16 seconds. And as seen in the following screenshot, it is practically identical in each cycle.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    55 AA 00 05 00 05 01 04 00 01 00 0F FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 00


    When I saw that the operation was already stable, I tried to put it in pairing mode and I succeeded, but as a result of that the code corruption problems began. I don't know if it's a consequence of this or it's just a coincidence, but right now the pir motion device is inoperative and I will once again carry out the already described process of downgrading via USB to the OpenBK7231N_QIO_1.15.599 firmware that will allow me to configure autoexec.bat without fear of cuts .


    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
  • #164 20584195
    spin55
    Level 17  
    I think the RF part of the chip has been corrupted because, although I can flash it via USB with other Openbeken firmwares, there is no communication according to Tuya protocol between chips nor can I create wifi AP by disconnecting and reconnecting repeatedly. The TuyaMCU chip tries to communicate with BK7321N but gets no response.

    So I reloaded the backup of the original firmware and, despite losing the MAC, it seems that it has regenerated the RF part and is operational again. I can now update both via USB and OTA. I have been able to configure autoexec.bat according to what was published in previous posts and I see that the OpenBK7231N_1.17.104.rbl firmware works fine while the communication between chips remains within the Tuya protocol.

    I'll let it run for a few days to see if the code corruption issue reproduces.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Mensaje 20 recibido en obk8D123669/1/get a las 12:16:
    1
    QoS: 0 - Retain: false
    Mensaje 19 recibido en obk8D123669/1/get a las 12:15:
    0
    QoS: 0 - Retain: false
    Mensaje 18 recibido en obk8D123669/1/get a las 12:14:
    1
    QoS: 0 - Retain: false
    Mensaje 17 recibido en obk8D123669/1/get a las 12:13:
    0
    QoS: 0 - Retain: false
    Mensaje 16 recibido en obk8D123669/1/get a las 12:12:
    1
    QoS: 0 - Retain: false
    Mensaje 15 recibido en obk8D123669/1/get a las 12:11:
    0
    QoS: 0 - Retain: false
    Mensaje 14 recibido en obk8D123669/1/get a las 12:09:
    1
    QoS: 0 - Retain: false
    Mensaje 13 recibido en obk8D123669/1/get a las 12:07:
    0
    QoS: 0 - Retain: false
    Mensaje 12 recibido en obk8D123669/1/get a las 12:07:
    1
    QoS: 0 - Retain: false
    Mensaje 11 recibido en obk8D123669/1/get a las 12:05:
    0
    QoS: 0 - Retain: false
    Mensaje 10 recibido en obk8D123669/1/get a las 12:04:
    1
    QoS: 0 - Retain: false
    Mensaje 9 recibido en obk8D123669/1/get a las 12:03:
    0
    QoS: 0 - Retain: false
    Mensaje 8 recibido en obk8D123669/1/get a las 12:02:
    1
    QoS: 0 - Retain: false
    Mensaje 7 recibido en obk8D123669/1/get a las 12:00:
    0
    QoS: 0 - Retain: false
    Mensaje 6 recibido en obk8D123669/1/get a las 12:00:
    1
    QoS: 0 - Retain: false
    Mensaje 5 recibido en obk8D123669/1/get a las 11:58:
    0
    QoS: 0 - Retain: false
    Mensaje 4 recibido en obk8D123669/1/get a las 11:58:
    1
    QoS: 0 - Retain: false
    Mensaje 3 recibido en obk8D123669/1/get a las 11:56:
    0
    QoS: 0 - Retain: false
    Mensaje 2 recibido en obk8D123669/1/get a las 11:56:
    1
    QoS: 0 - Retain: false
    Mensaje 1 recibido en obk8D123669/1/get a las 11:54:
    0
    QoS: 0 - Retain: false
    Mensaje 0 recibido en obk8D123669/1/get a las 11:53:
    1
    QoS: 0 - Retain: false
  • #165 20584208
    p.kaczmarek2
    Moderator Smart Home
    Sorry for the later reply. To the best of my knowledge, the latest OBK should work at least BETTER than the old one, so I am not sure why downgrading was helping in your case.

    I will, however, note here that you may be right with that corruption. During my testing, I have experienced one strange issue. Basically, I have used very old batteries, with very low voltage and it somehow bricked CB3S, and I had to flash it again so it can with new batteries. There was no problem with recovering it, but still, it was a surprising issue..

    Regarding FC:
    
    55 AA 00 05 00 05 01 04 00 01 00 0F FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC 
    FC FC FC FC FC FC F
    

    I think I saw it several times while testing door sensors with TuyaMCU and it was just a noise caused by one of the modules (WiFi or MCU, I don't remember) being off. I didn't consider it a problem.

    Quote:

    p.kaczmarek2, I was about to validate your firmware OpenBK7231N_QIO_1.17.104 and suddenly I find myself again with symptoms of what I call code corruption.

    So I would say there are two options:
    1. it's a low battery problem, maybe your battery is too discharged?
    2. what do you have here:
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    Maybe it goes into safe mode?

    It would be interesting to see how @DeDaMrAz 's humidity/temperature TuyaMCU sensor from this topics works for him, after a longer time, is it still stable?
    https://www.elektroda.com/rtvforum/topic3975583.html
    Helpful post? Buy me a coffee.
  • #166 20584301
    spin55
    Level 17  
    p.kaczmarek2 wrote:
    So I would say there are two options:
    1. it's a low battery problem, maybe your battery is too discharged?


    Food with external stabilized source of 3.3V.

    Quote:
    2. what do you have here:


    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    p.kaczmarek2 wrote:
    Maybe it goes into safe mode?


    I don't see Wi-Fi SSID AP

    p.kaczmarek2 wrote:
    It would be interesting to see how @DeDaMrAz 's humidity/temperature TuyaMCU sensor from this topics works for him, after a longer time, is it still stable?


    For now I'm going to leave it with this firmware to parcel out the cause of the possible corruption of autoexec.bat

    NOTE: It would be very interesting to be able to implement a response to command 10 in the wifi module to try to shorten the reset time of the sensor, but we would have to discover how to make tuyaMCU generate the request for that command 10.
  • #167 20587122
    spin55
    Level 17  
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    I usually monitor the Rx line with Realterm and I have never seen a 06 command request from TuyaMCU. However, you have implemented a command 06 in BK7231N that simulates sending a dummy date.

    According to Tuya's documentation:

    -------------------------

    Obtain the local time

    Note:

    Start to send a data packet to obtain the local time, after the device is connected to network, that is, the device receives status 5 through the command of “reporting the network status of the device”.

    After the device is connected to the server, if the network performance is poor, it might fails to obtain time data. Regarding time-dependent devices, such as locks, if local time is not calibrated and it fails to obtain time data, it is required to obtain the time value every 3 seconds, in order to obtain time data successfully.

    MCU sends the following command: 55 aa 00 06 00 00 05

    The module returns the following command: 55 aa 00 06 00 08 01 12 09 11 10 09 05 01 59

    The preceding example represents the local time of Monday, September 17, 2018, 16:09:05.

    ---------------------------

    I deduce from this information that TuyaMCU sends command 06 after receiving command 02 notifying that there is already a connection to the router and cloud. This request is received by the wifi module and responds with another command 06 that contains the data of the current date.

    That is, as it is implemented, that command 06 does nothing. It is a situation similar to the 08 command that was sent in previous firmwares.

    In any case, I don't think this is of any importance because TuyaMCU ignores the command.

    I continue with the tests and at the moment this firmware works fine. Starting Monday, if there is no incident, I will start playing with the pairing to see if I am able to reproduce the anomalies described in previous posts.

    Good weekend.
  • #168 20590448
    spin55
    Level 17  
    Good news, the operation with this firmware is still stable.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Mensaje 16 recibido en obk8D123669/1/get a las 12:10:
    1
    QoS: 0 - Retain: false
    Mensaje 15 recibido en obk8D123669/1/get a las 12:08:
    0
    QoS: 0 - Retain: false
    Mensaje 14 recibido en obk8D123669/1/get a las 12:08:
    1
    QoS: 0 - Retain: false
    Mensaje 13 recibido en obk8D123669/1/get a las 12:06:
    0
    QoS: 0 - Retain: false
    Mensaje 12 recibido en obk8D123669/1/get a las 12:06:
    1
    QoS: 0 - Retain: false
    Mensaje 11 recibido en obk8D123669/1/get a las 12:04:
    0
    QoS: 0 - Retain: false
    Mensaje 10 recibido en obk8D123669/1/get a las 12:04:
    1
    QoS: 0 - Retain: false
    Mensaje 9 recibido en obk8D123669/1/get a las 12:02:
    0
    QoS: 0 - Retain: false
    Mensaje 8 recibido en obk8D123669/1/get a las 12:01:
    1
    QoS: 0 - Retain: false
    Mensaje 7 recibido en obk8D123669/1/get a las 11:59:
    0
    QoS: 0 - Retain: false
    Mensaje 6 recibido en obk8D123669/1/get a las 11:58:
    1
    QoS: 0 - Retain: false
    Mensaje 5 recibido en obk8D123669/1/get a las 11:57:
    0
    QoS: 0 - Retain: false
    Mensaje 4 recibido en obk8D123669/1/get a las 11:56:
    1
    QoS: 0 - Retain: false
    Mensaje 3 recibido en obk8D123669/1/get a las 11:54:
    0
    QoS: 0 - Retain: false
    Mensaje 2 recibido en obk8D123669/1/get a las 11:54:
    1
    QoS: 0 - Retain: false
    Mensaje 1 recibido en obk8D123669/1/get a las 11:52:
    0
    QoS: 0 - Retain: false
    Mensaje 0 recibido en obk8D123669/1/get a las 11:52:
    1
    QoS: 0 - Retain: false


    As I had commented, today I began to carry out tests to put the device in pairing mode and I have verified the difficulty to achieve it with this firmware.

    Until now I followed the instructions in the manual and managed to do it without problems with other previous firmwares, but with this firmware it seems like a lottery.

    The process is already described throughout the thread and is as follows:
    -----------------------------------

    How to reset?
    
    (1) Press the reset button for 6 seconds till the indicator flash rapidly. Then device turn to smart wifi mode.
    (2) Press the reset button again for 6 seconds till the indicator flash slowly. The device turns to AP mode.
    
    Device Status                LED State
    
    Smart Wi Fi                    Indicator flashes quicly
    AP mode                        Indicator flashes slowly
    Triggered                       LED will rapidly blink and OFF after scheduled time
    Suspend mode              Indicator OFF
    Reset                               Indicator lights up for 4s and after 2seconds ligths OFF. Device goes    
                                             into configuration mode        
    Main function
    
    Operate status: alarma/ normal (the device can be triggered only once 1 minute)

    --------------------------------------
    I have found that it is possible to put it into pairing mode with a single long press instead of two, but you have to do it when you have just sent the 05 command and before the communication drops. Monitoring the Rx line with Realterm is relatively easy to achieve.

    The process looks like this:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Failed attempts:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    For now it is still working fine.
  • #169 20591617
    spin55
    Level 17  
    The device continues to work fine with this firmware.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Mensaje 23 recibido en obk8D123669/1/get a las 10:47:
    0
    QoS: 0 - Retain: false
    Mensaje 22 recibido en obk8D123669/1/get a las 10:46:
    1
    QoS: 0 - Retain: false
    Mensaje 21 recibido en obk8D123669/1/get a las 10:45:
    0
    QoS: 0 - Retain: false
    Mensaje 20 recibido en obk8D123669/1/get a las 10:44:
    1
    QoS: 0 - Retain: false
    Mensaje 19 recibido en obk8D123669/1/get a las 10:43:
    0
    QoS: 0 - Retain: false
    Mensaje 18 recibido en obk8D123669/1/get a las 10:42:
    1
    QoS: 0 - Retain: false
    Mensaje 17 recibido en obk8D123669/1/get a las 10:40:
    0
    QoS: 0 - Retain: false
    Mensaje 16 recibido en obk8D123669/1/get a las 10:40:
    1
    QoS: 0 - Retain: false
    Mensaje 15 recibido en obk8D123669/1/get a las 10:37:
    0
    QoS: 0 - Retain: false
    Mensaje 14 recibido en obk8D123669/1/get a las 10:37:
    1
    QoS: 0 - Retain: false
    Mensaje 13 recibido en obk8D123669/1/get a las 10:35:
    0
    QoS: 0 - Retain: false
    Mensaje 12 recibido en obk8D123669/1/get a las 10:35:
    1
    QoS: 0 - Retain: false
    Mensaje 11 recibido en obk8D123669/1/get a las 10:33:
    0
    QoS: 0 - Retain: false
    Mensaje 10 recibido en obk8D123669/1/get a las 10:33:
    1
    QoS: 0 - Retain: false
    Mensaje 9 recibido en obk8D123669/1/get a las 10:31:
    0
    QoS: 0 - Retain: false
    Mensaje 8 recibido en obk8D123669/1/get a las 10:31:
    1
    QoS: 0 - Retain: false
    Mensaje 7 recibido en obk8D123669/1/get a las 10:29:
    0
    QoS: 0 - Retain: false
    Mensaje 6 recibido en obk8D123669/1/get a las 10:29:
    1
    QoS: 0 - Retain: false
    Mensaje 5 recibido en obk8D123669/1/get a las 10:27:
    0
    QoS: 0 - Retain: false
    Mensaje 4 recibido en obk8D123669/1/get a las 10:27:
    1
    QoS: 0 - Retain: false
    Mensaje 3 recibido en obk8D123669/1/get a las 10:25:
    0
    QoS: 0 - Retain: false
    Mensaje 2 recibido en obk8D123669/1/get a las 10:24:
    1
    QoS: 0 - Retain: false
    Mensaje 1 recibido en obk8D123669/1/get a las 10:23:
    0
    QoS: 0 - Retain: false
    Mensaje 0 recibido en obk8D123669/1/get a las 10:22:
    1
    QoS: 0 - Retain: false


    And get into pairing mode the first time with a single long press of the configuration button.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    And here you can see the entire sequence from connecting the device to +Vcc to putting it into pairing mode, including the sensor reset period which takes approximately 1 minute 16 seconds.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    And the Log of the entire sequence.

     obk8D123669/ subT obk8D123669/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens/ subT bekens/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk8D123669/ subT cmnd/obk8D123669/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens/ subT cmnd/bekens/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk8D123669/ subT obk8D123669/+/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 1 type changed to readonly
    Info:GEN:Channel 4 type changed to readonly
    Info:GEN:CHANNEL_Set channel 1 has changed to 2 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 2 to channel 1 
    Info:MAIN:Time 1, idle 275151/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 190129/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 182774/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 189329/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 190471/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid: key:
    Info:MAIN:Time 6, idle 181544/s, free 71656, 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 183929/s, free 71656, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 83796/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 71672, 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=38:1f:8d:12:36:69 
    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:Time 11, idle 97468/s, free 71760, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 187196/s, free 71800, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk8D123669
    mqtt_host 192.168.1.45:1883
    Info:MQTT:Connect error in mqtt_client_connect - code: -4 (ERR_RTE)
    Info:MAIN:Time 13, idle 183858/s, free 71800, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk8D123669
    mqtt_host 192.168.1.45:1883
    Info:MAIN:Time 14, idle 184929/s, free 71120, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 15, idle 188256/s, free 70928, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk8D123669/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk8D123669/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to obk8D123669/+/get
    Info:MQTT:Publishing val obk8D123669 to obk8D123669/host retain=0
    Info:MAIN:Time 16, idle 186482/s, free 71696, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val Build on May  5 2023 10:21:44 version 1.17.104 to obk8D123669/build retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 01 04 00 01 01 10 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 12 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    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 obk8D123669/1/get retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 08 04 02 00 04 00 00 00 64 7A 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 15 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 4, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 4 int: 100
    Info:GEN:CHANNEL_Set channel 4 has changed to 100 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 100 to channel 4 
    Info:MQTT:Publishing val 100 to obk8D123669/4/get retain=0
    Info:MAIN:Time 17, idle 190090/s, free 71696, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/1/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/4/get
    Info:MQTT:Publishing val 38:1f:8d:12:36:69  to obk8D123669/mac retain=0
    Info:MAIN:Time 18, idle 159280/s, free 71696, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 2 to obk8D123669/sockets retain=0
    Info:MAIN:Time 19, idle 185761/s, free 71696, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -71 to obk8D123669/rssi retain=0
    Info:MAIN:Time 20, idle 188264/s, free 71696, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-71,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MQTT:Publishing val 20 to obk8D123669/uptime retain=0
    Info:MAIN:Time 21, idle 186729/s, free 71464, MQTT 1(2), bWifi 1, secondsWithNoPing -1, socks 2/38 
    received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 190900/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 184998/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 191341/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 191146/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid: key:
    Info:MAIN:Time 6, idle 184069/s, free 71656, 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 184765/s, free 71656, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 85259/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 71672, 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=38:1f:8d:12:36:69 
    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 95602/s, free 71768, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 189088/s, free 71808, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk8D123669
    mqtt_host 192.168.1.45:1883
    Info:MAIN:Time 13, idle 189647/s, free 71720, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 187118/s, free 71720, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk8D123669/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk8D123669/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to obk8D123669/+/get
    Info:MQTT:Publishing val obk8D123669 to obk8D123669/host retain=0
    Info:MAIN:Time 15, idle 182454/s, free 71480, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val Build on May  5 2023 10:21:44 version 1.17.104 to obk8D123669/build retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 01 04 00 01 00 0F 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 12 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    Info:GEN:CHANNEL_Set channel 1 has changed to 0 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 0 to channel 1 
    Info:MQTT:Publishing val 0 to obk8D123669/1/get retain=0
    Info:MAIN:Time 16, idle 190147/s, free 71720, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/1/get
    Info:MQTT:Publishing val 38:1f:8d:12:36:69  to obk8D123669/mac retain=0
    Info:MAIN:Time 17, idle 174406/s, free 71472, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 2 to obk8D123669/sockets retain=0
    Info:MAIN:Time 18, idle 188731/s, free 66608, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -71 to obk8D123669/rssi retain=0
    Info:MAIN:Time 19, idle 193245/s, free 66608, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 19 to obk8D123669/uptime retain=0
    Info:MAIN:Time 20, idle 190119/s, free 71720, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-71,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 185 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 5 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 []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk8D123669/ subT obk8D123669/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens/ subT bekens/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk8D123669/ subT cmnd/obk8D123669/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens/ subT cmnd/bekens/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk8D123669/ subT obk8D123669/+/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 1 type changed to readonly
    Info:GEN:Channel 4 type changed to readonly
    Info:GEN:CHANNEL_Set channel 1 has changed to 2 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 2 to channel 1 
    Info:MAIN:Time 1, idle 273450/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79 6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 190231/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 182810/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 188901/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 190230/s, free 76400, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:ssid: key:
    Info:MAIN:Time 6, idle 180658/s, free 71656, 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 184607/s, free 71656, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 84829/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 71672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 71672, 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=38:1f:8d:12:36:69 
    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 94984/s, free 71760, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:MAIN:Time 12, idle 187024/s, free 71800, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_userName 
    mqtt_pass 
    mqtt_clientID obk8D123669
    mqtt_host 192.168.1.45:1883
    Info:MAIN:Time 13, idle 199435/s, free 67320, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 190392/s, free 67128, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 15, idle 189518/s, free 71712, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk8D123669/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk8D123669/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to obk8D123669/+/get
    Info:MQTT:Publishing val obk8D123669 to obk8D123669/host retain=0
    Info:MAIN:Time 16, idle 186295/s, free 71472, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val Build on May  5 2023 10:21:44 version 1.17.104 to obk8D123669/build retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 01 04 00 01 01 10 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 12 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    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 obk8D123669/1/get retain=0
    Info:MAIN:Time 17, idle 191095/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/1/get
    Info:MQTT:Publishing val 38:1f:8d:12:36:69  to obk8D123669/mac retain=0
    Info:MAIN:Time 18, idle 174879/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 2 to obk8D123669/sockets retain=0
    Info:MAIN:Time 19, idle 186745/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -67 to obk8D123669/rssi retain=0
    Info:MAIN:Time 20, idle 191247/s, free 71480, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-67,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MQTT:Publishing val 20 to obk8D123669/uptime retain=0
    Info:MAIN:Time 21, idle 184597/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 63096 to obk8D123669/freeheap retain=0
    Info:MAIN:Time 22, idle 188367/s, free 63096, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MQTT:Publishing val 192.168.1.57 to obk8D123669/ip retain=0
    Info:MAIN:Time 23, idle 187334/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Channel has changed! Publishing 1 to channel 1 
    Info:MQTT:Publishing val 1 to obk8D123669/1/get retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 03 00 00 02 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 3 (WiFiState) with 7 bytes
    Info:MAIN:Time 24, idle 377025/s, free 71504, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/1/get
    Info:MQTT:Channel has changed! Publishing 0 to channel 4 
    Info:MQTT:Publishing val 0 to obk8D123669/4/get retain=0
    Info:MAIN:Time 25, idle 181174/s, free 71480, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8D123669/4/get
    Info:MAIN:Time 26, idle 189448/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 27, idle 191035/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 28, idle 199679/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 29, idle 190841/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 30, idle 189585/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.57 gate=192.168.1.1 mask=255.255.255.0 mac=38:1f:8d:12:36:69 
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-71,ssid=,bssid=00:1a:2b:48:20:34 ,channel=13,cipher_type:CCMP
    Info:MAIN:Time 31, idle 188539/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 32, idle 190218/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 33, idle 200272/s, free 71712, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 34, idle 190507/s, free 71488, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38


    NOTE: Battery drain could be reduced if only intrusion information was sent via Wi-Fi:

    55 AA 00 01 00 00 00
    55 AA 00 02 00 01 03 05
    55 AA 00 02 00 01 04 06
    55 AA 00 05 00 01 00 05
    55 AA 00 05 00 01 00 05
    -----------------------------
    55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 79 64 77 6F 62 77 79 71 78 69 79
    6F 62 39 68 22 2C 22 76 22 3A 22 31 2E 30 2E 35 22 7D 62
    55 AA 00 02 00 00 01
    55 AA 00 02 00 00 01
    55 AA 00 05 00 05 01 04 00 01 00 0F
    55 AA 00 05 00 08 04 02 00 04 00 00 00 64 7A
  • #170 20595106
    p.kaczmarek2
    Moderator Smart Home
    Today I have received package from @spin55 , here's the sensor:
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    The sensor is currently waiting in queue to be analyzed, flashed and tested. I am not sure when I'll have time to look into it, as there are already also smoke sensor guys waiting and the TM1650 module from aliexpress is waiting for support as well. Let's hope I will get onto it soon. Thank you for your continued support and testing, @spin55!
    Helpful post? Buy me a coffee.
  • #171 20634360
    spin55
    Level 17  
    It's just to confirm that all three PIRs I have work fine with this firmware.
    Congratulations guys, you do an excellent job.

    Grettings
  • #172 20634362
    p.kaczmarek2
    Moderator Smart Home

    That's good to hear. I apologize for the delay on my side. It is almost impossible to do support for all those features quickly. I still have a pending motion sensor to check, as said in the previous post.
    Helpful post? Buy me a coffee.
  • #173 20641106
    dmarcondescctv
    Level 6  

    >>20634360
    Hi spin55,

    Would you be able to assist? I bought a similar PIR device, and I'm having problems with the firmware.
    I have flashed it, apparently no problems on the process.
    After that, it just connects to my WiFi for a brief moment, 3 - 5 seconds, and then goes offline. I can't ping it or access the GUI.
    From the realterm, I get "00 00 00 00...."

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    I also have tried a few other suggestions in this (and other) post, like erase all, restore the RF part, install the FullFW, with no luck.

    Do you have any advice?

    Thanks,
  • #174 20641145
    p.kaczmarek2
    Moderator Smart Home

    Well, have you configured it with the proper autoexec.bat?
    Helpful post? Buy me a coffee.
  • #175 20641170
    dmarcondescctv
    Level 6  
    First of all, thank you for getting back to me in such a short time.

    I have no chance to launch the web application within the 3 - 5 seconds that the device is reachable.

    What I tried instead was to add some commands that I would assume would be in the autoexec.bat in the short startup command and push it to the OBKConfig.
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
  • ADVERTISEMENT
  • #176 20641388
    spin55
    Level 17  

    dmarcondescctv wrote:
    After that, it just connects to my WiFi for a brief moment, 3 - 5 seconds, and then goes offline. I can't ping it or access the GUI.


    In order for the connection to be maintained long enough to configure autoexec.bat, you have to put it in pairing mode. To do this, you have to hold down the button next to the battery until the blue LEDs go off. Check that the web remains active and configure autoexec.bat.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    In the image you posted from Realterm, you have the port set to 115200, change it to 9600.

    As problems arise, we will guide you.
  • #177 20642362
    dmarcondescctv
    Level 6  

    Hi Spin55.

    With the change to 9600, I can see some progress in my troubleshooting:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Pressing and holding the button for +5 seconds gave me more time to access the web application and create the autoexec.bat.

    I have copied your autoexec.bat from a previous post.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Thank you for the help so far.
  • #178 20642407
    spin55
    Level 17  
    Configure Realterm/Display like so:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    For the TuyaMCU information to be displayed clearly:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Added after 13 [minutes]:

    Can you post a screenshot of the web like this?

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
  • #179 20642500
    p.kaczmarek2
    Moderator Smart Home

    @dmarcondescctv I looked at your Web App Log screenshot and it seems to look like your device is correctly getting TuyaMCU packet with dpID and value, and then it correctly forwards it to MQTT. You can see the MQTT publish log entry in the image. Can you provide more information about the current issue with your device?
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    Please see above, I have marked interesting log lines on your log screenshot.
    Helpful post? Buy me a coffee.
  • #180 20643689
    dmarcondescctv
    Level 6  

    Hi @spin55 and @p.kaczmarek2,

    With your help, I managed to get it working. Thank you!

    Now, I'm working to make it more reliable. My idea was that when someone steps into a room, the PIR would turn on a smart switch via Home Assistant.

    It is working, BUT not all the time and takes several seconds to turn the light on.

    Here are some screenshots.

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

Topic summary

The discussion revolves around configuring a motion sensor device powered by the BK7231N chip and utilizing the TuyaMCU protocol. Users share experiences and troubleshooting steps related to flashing the device, setting up the autoexec.bat file, and ensuring proper communication between the TuyaMCU and the Wi-Fi module. Key issues include the device not waking from sleep, MQTT communication problems, and the need for specific commands to maintain connectivity. Solutions involve using RealTerm for monitoring, adjusting baud rates, and ensuring the correct setup of drivers and commands in the autoexec.bat file. Users also discuss the importance of maintaining a stable power supply and the potential for firmware updates to improve functionality.
Summary generated by the language model.
ADVERTISEMENT