logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

caubergjef57 19227 193
ADVERTISEMENT
  • #181 20643778
    spin55
    Level 17  
    https://www.elektroda.com/rtvforum/topic3937723-180.html#gallery-4

    Delete this because you no longer need it. You already have it in autoexec.bat. We'll take the automation issue in stride later.

    Added after 1 [minutes]:

    First, you have to make sure that everything works well step by step.


    Added after 11 [minutes]:

    If you want an immediate response, it might not be this type of battery device. I have personally verified that Zigbee devices are a much better solution because they respond faster and consume much less. If you want something based on WIFI you will have to use a PIR with a permanent connection to the network and without a TuyaMCU chip.
    Maybe @p.kaczmarek2 can have a more informed opinion on this.
  • ADVERTISEMENT
  • Helpful post
    #182 20645222
    spin55
    Level 17  

    In case you want to play with the device, I leave you these notes that, although they are already discussed throughout the thread, can help to focus the issue.

    If you configure the Realterm Display tab as I indicated above, you will see your Rx information like this:

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    There you can see a complete cycle from when the power is connected until it enters pairing mode by long pressing the button.

    And you can see the changes if you monitor channel 1 on MQTT in Home Assistant (HA):

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    To know the Tuya protocol for battery powered devices:

    https://developer.tuya.com/en/docs/iot/tuyacl...niversalserialaccessprotocol?id=K95afs9h4tjjh

    And to make it easier for you to interpret those commands:

    https://www.elektroda.com/rtvforum/topic3970199.html

    Greetings
  • ADVERTISEMENT
  • #183 20645366
    dmarcondescctv
    Level 6  
    Hi Spin55,

    Thanks for the 2 posts. I have removed the lines that you mentioned. No problems there.

    With the device, it may not be the correct hardware for my application, as you mentioned.

    Sometimes, I see a movement detection, and it never gets to HA. Funny enough, when I'm monitoring with Realterm, it works 100% :)

    Happy to hear your or someone else's suggestion for a PIR.

    I was looking for some BLE PIR, which sends a beacon when it detects movement. So that I could get it on my ESP32 BLE tracker.

    Anyways, thanks for your inputs, and I will keep playing with some settings.

    BTW, just to help someone else that finds this post: To get PIR on the "pairing" mode, I click on the button 5 times, then press and hold for 6 seconds. This usually works well and keeps the PIR connected for a long time.
  • ADVERTISEMENT
  • #184 20645367
    p.kaczmarek2
    Moderator Smart Home

    We're working on a YouTube presentation with my door sensor and the device that @spin55 sent, but we are very busy, so we don't know when it will be released. Please follow our IoT guides Elektroda channel to get a notification when it's released:
    https://www.youtube.com/@elektrodacom
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #185 20646690
    spin55
    Level 17  
    dmarcondescctv wrote:
    Happy to hear your or someone else's suggestion for a PIR.


    https://www.elektroda.com/rtvforum/topic3975583.html#gallery-35

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    https://es.aliexpress.com/item/10050047382480..._id=202307080643418529150435676320008874913_4

    I have carried out a test with this PIR that is powered by 3xAAA batteries and has a CBU module. I have removed the batteries and have fed it with 5V. I have removed autoexec.bat and changed the pinout:

    Code: JSON
    Log in, to see the code


    You can leave only "16" and "26", the rest is left over since it will be permanently powered.

    After intrusion detection it takes about 35 seconds to reset the sensor compared to 1:20 minutes for the NEO, but it can be reduced to 2 seconds with a small modification (although I haven't tested it). Once reset, detection is fast because it is always online. Something similar happens with door sensors.

    I have experimented with this model because it is what I have at hand, but anyone that does not have a TuyaMCU chip and is powered by microUSB at 5V will work.

    This is in terms of a cheap Wi-Fi solution, but the ideal is to use battery-powered Zigbee devices because the consumption is much lower, it is faster and they have other obvious advantages, but that is another topic.

    Grettings
  • #186 20646772
    p.kaczmarek2
    Moderator Smart Home
    @spin55 my guide for that one (non-TuyaMCU version) is almost ready:
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    I will post it soon, first in Polish, then English:
    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol
    Helpful post? Buy me a coffee.
  • #187 20652350
    dmarcondescctv
    Level 6  

    Thanks @spin55, I will have a look and maybe order one to play with it.
  • #188 20652417
    p.kaczmarek2
    Moderator Smart Home
    I have posted some information about that sensor, currently in polish:
    https://www.elektroda.pl/rtvforum/topic3988602.html
    Maybe we will setup English translation soon
    Helpful post? Buy me a coffee.
  • #189 20652618
    spin55
    Level 17  
    dmarcondescctv wrote:
    Thanks @spin55, I will have a look and maybe order one to play with it.


    In case you decide to try it, I have carried out the test under these conditions:

    PIR permanently powered at 5V.

    Pin Configuration:

    "pins": {
    "16": "dInput;1",
    "26": "LED;2"
    }


    autoexec.bat configuration:

    setChannel 1 0
    addChangeHandler Channel1 == 1 backlog setChannel 2 1; setChannel 2 0;


    Binary_sensor PIR configuration:

    mqtt:
      binary_sensor:
        - unique_id: "OpenBK7231N_FF858113_binary_PIR"
          name: "Motion sensor_5"
          state_topic: "obkFF858103/1/get"
          qos: 1
          payload_on: 1
          payload_off: 0


    Sensor PIR configuration:

    mqtt:
      sensor:
        - unique_id: "OpenBK7231N_FF858103_PIR"
          name: "PIR_5"
          state_topic: "obkFF858103/1/get"
          value_template: '{{ value | replace("0", "Idle") | replace("1", "Activated") }}'



    Automations.yaml configuration:

    - id: '1688763517168'
      alias: PIR_5 light on test
      description: ''
      trigger:
      - platform: state
        entity_id:
        - sensor.pir_5
        from: Idle
        to: Activated
      condition: []
      action:
      - type: turn_on
        device_id: 95b49c8884f3ae33ab45fd2503ce1552
        entity_id: switch.computer_light_room
        domain: switch
      mode: single
    - id: '1688763517178'
      alias: PIR_5 light off test
      description: ''
      trigger:
      - platform: state
        entity_id:
        - sensor.pir_5
        from: Activated
        to: Idle
      condition: []
      action:
      - type: turn_off
        device_id: 95b49c8884f3ae33ab45fd2503ce1552
        entity_id: switch.computer_light_room
        domain: switch
      mode: single


    Added after 2 [minutes]:

    p.kaczmarek2 wrote:
    I have posted some information about that sensor, currently in polish:
    https://www.elektroda.pl/rtvforum/topic3988602.html
    Maybe we will setup English translation soon


    Very good article, like all the great work you do.

    Congratulations

    By default the PIR takes 33 seconds to reset, but this time can easily be cut to 2 seconds by grounding pin 6.

    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
  • #190 20652721
    dmarcondescctv
    Level 6  

    Bought one. Hope it is not too hard to flash it :)
    I will find out when it gets here, usually takes many weeks.
    Cheers
  • #191 20843904
    caubergjef57
    Level 4  

    Motion sensor with BK7231N and TuyaMCU battery powered devices protocol

    Hi,

    So what is the end configuration, flags, autoexec.bat and startup commands for this device?

    Greetings, jef
  • #192 20981771
    p4nd0ra
    Level 3  
    Hello,
    I am trying to make this device work but it will not get back online from sleep.
    An extract from the logs:

    Info:CFG:####### Boot Count 66 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 44 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:xxxx key:xxxxxx
    Info:MAIN:Using SSID [xxxx]
    Info:MAIN:Using Pass [xxxxx.]
    Info:MQTT:MQTT_RegisterCallback called for bT BR_M_S/ subT BR_M_S/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/BR_M_S/ subT cmnd/BR_M_S/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT BR_M_S/ subT BR_M_S/+/get
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    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 4 type changed to BatteryLevelPercent
    Info:GEN:CHANNEL_Set channel 1 has changed to 2 (flags 0)
    
    Info:MQTT:Channel has changed! Publishing 2 to channel 1 
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Time 1, idle 268548/s, free 73752, 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 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:ProcessIncoming[v=0]: cmd 1 (QueryProductInformation) len 43
    Info:TuyaMCU:ParseQueryProductInformation: received {"p":"lydwobwyqxiyob9h","v":"1.0.5"}
    Info:MAIN:Time 2, idle 181611/s, free 73496, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 61711/s, free 73472, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 0/s, free 73472, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 0/s, free 73472, 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 openbeken
    mqtt_pass xxxxxxxx
    mqtt_clientID BR_M_S
    mqtt_host 192.168.64.252:1883
    Info:MAIN:Time 6, idle 110720/s, free 64976, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to BR_M_S/+/set
    Info:MQTT:mqtt_subscribed to bekens_n/+/set
    Info:MQTT:mqtt_subscribed to cmnd/BR_M_S/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens_n/+
    Info:MQTT:mqtt_subscribed to BR_M_S/+/get
    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!
    ming_publish_cb topic BR_M_S/7/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/8/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/9/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/10/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/11/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/12/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/13/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/14/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/15/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/16/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/17/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/18/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/19/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/20/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/21/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/22/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/23/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/24/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/25/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/26/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/27/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/28/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/29/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/30/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/31/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/32/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/33/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/34/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/35/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/36/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/37/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/38/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/39/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/41/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/42/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/43/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/44/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/45/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/46/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/47/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/48/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/49/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/50/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/51/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/52/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/53/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/54/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/55/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/56/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/57/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/58/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/59/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/60/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/61/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/62/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/63/get
    Info:MQTT:Publishing val BR_M_S to BR_M_S/host retain=1
    Info:MAIN:Time 7, idle 92402/s, free 73744, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val Build on Feb 24 2024 20:18:08 version 1.17.483 to BR_M_S/build retain=1
    Info:MAIN:Time 8, idle 182924/s, free 73472, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 1c:90:ff:d0:ff:44 to BR_M_S/mac retain=1
    Info:MAIN:Time 9, idle 186932/s, free 73744, MQTT 1(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 01 04 00 01 00 0F 
    Info:TuyaMCU:ProcessIncoming[v=0]: cmd 5 (WiFiSelect) len 12
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: processing id 1, dataType 4-enum and 1 data bytes
    Info:TuyaMCU:V0_ParseRealTimeWithRecordStorage: byte 0
    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 BR_M_S/1/get retain=1
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BR_M_S/1/get
    Info:MQTT:Publishing val FM_SH to BR_M_S/ssid retain=1
    Info:MAIN:Time 10, idle 176067/s, free 62048, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:GEN:dhcp=0 ip=192.168.64.69 gate=192.168.64.254 mask=255.255.255.0 mac=1c:90:ff:d0:ff:44
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-57,ssid=FM_SH,bssid=48:22:54:40:51:c8,channel=11,cipher_type:CCMP
    Info:MQTT:Publishing val 2 to BR_M_S/sockets retain=1
    Info:MAIN:Time 11, idle 179999/s, free 73744, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -57 to BR_M_S/rssi retain=1
    Info:MAIN:Time 12, idle 187769/s, free 73744, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 12 to BR_M_S/uptime retain=1
    Info:MAIN:Time 13, idle 188531/s, free 73744, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 73744 to BR_M_S/freeheap retain=1
    Info:MAIN:Time 14, idle 185052/s, free 73744, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Main_Init_Before_Delay


    Any ideas?
  • #193 20981874
    p.kaczmarek2
    Moderator Smart Home
    Why do you think it does not wake up back from the sleep? It's TuyaMCU device, the MCU handles the wake up procedure. It should always wake up, as we don't change the firmware of the MCU, just of the WiFi module.
    Helpful post? Buy me a coffee.
  • #194 20982385
    p4nd0ra
    Level 3  

    That is a very good question. I have 3 of those and all exhibit the same issue.
    When pressing the reset button it connects back to the network and I can access it for some time.
    AP mode can be triggered as well.

    What is this message by the way?
    TuyaMCU:ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!

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.
Generated by the language model.

FAQ

TL;DR: "TuyaMCU will try to turn off WiFi module after about 90 seconds." Configure OpenBeken with tmSensor + TuyaMCU, map dpIDs (motion/battery), and publish retained MQTT updates for Home Assistant. [Elektroda, p.kaczmarek2, post #20320779]

Why it matters: This FAQ helps BK7231N TuyaMCU PIR owners get fast, reliable local MQTT motion and battery telemetry into Home Assistant without Tuya cloud.

Quick Facts

What’s the correct OpenBeken autoexec.bat for a BK7231N TuyaMCU PIR?

Use TuyaMCU + tmSensor, then map dpIDs to channels. Example: startDriver TuyaMCU startDriver tmSensor setChannelType 1 readonly linkTuyaMCUOutputToChannel 1 val 1 setChannelType 4 readonly linkTuyaMCUOutputToChannel 4 val 4 This maps motion (dpId 1) to ch1 and battery (dpId 4) to ch4. Update firmware first to ensure 0x05 parsing and low‑power handling. [Elektroda, p.kaczmarek2, post #20320779]

How do I keep the PIR online long enough to configure or OTA flash?

Enter pairing mode to keep Wi‑Fi powered longer. Long‑press the button about 6 seconds, wait briefly, repeat if needed. This prevents TuyaMCU from shutting the module too early. Then finish OTA or WebApp setup. “Pair mode keeps the module powered for over a minute.” [Elektroda, p.kaczmarek2, post #20563807]

How do I sniff TuyaMCU traffic and find dpIDs?

Use Realterm at 9600 baud, HEX display, do not connect CEN. Trigger motion and look for frames beginning 55 AA. Motion typically reports in 0x05 packets; you will see dpID=1 changes. Capture to a file for analysis. [Elektroda, p.kaczmarek2, post #20310728]

Which dpIDs does this PIR use for motion and battery?

dpId 1 is motion state (Enum 0/1). dpId 4 is battery percent (Value 0–100). Link dpId 1 → channel 1, dpId 4 → channel 4 using linkTuyaMCUOutputToChannel. Then publish retained MQTT for HA. [Elektroda, p.kaczmarek2, post #20332445]

Home Assistant shows the PIR as ‘unknown’ or ‘unavailable’. How do I fix it?

Enable OpenBeken Flag 7 to publish all values with retain. Remove availability_topic from your HA YAML, since HA removed retain on binary sensors. Quote: “Solution: remove availability topic … and enable retain on OBK.” [Elektroda, p.kaczmarek2, post #20329316]

What HA YAML should I use for the motion entity (MQTT binary_sensor)?

Example: binary_sensor:
  • platform: mqtt name: "PIR Motion" state_topic: "obkDevice/1/get" qos: 1 payload_on: 1 payload_off: 0 Replace obkDevice with your topic (e.g., obk8C000000). Ensure retain is enabled on OBK (Flag 7). [Elektroda, p.kaczmarek2, post #20324662]

How do I expose battery percentage to Home Assistant?

Use an MQTT sensor for channel 4: sensor:
  • platform: mqtt name: "PIR Battery" state_topic: "obkDevice/4/get" unit_of_measurement: "%" value_template: "{{ value }}" This reads dpId 4 mapped to channel 4 as a percentage. [Elektroda, p.kaczmarek2, post #20333999]

Why does my PIR publish only ‘1’ (motion) and miss the ‘0’ (clear)?

Initialize the channel so changes are detected. Two options: SetStartValue 1 -1 (remember last state) or setChannel 1 2 once in autoexec, so both 0 and 1 cause a change. This prevents ignored first updates. [Elektroda, p.kaczmarek2, post #20578050]

How do I get battery percent to render nicely on the OBK UI?

Update firmware, then set: setChannelType 4 BatteryLevelPercent. This channel type was added later; update to a build that includes it. Quote: “Battery Percent Indicator was added … so you would need to update the firmware.” [Elektroda, p.kaczmarek2, post #20332736]

What’s a typical re‑arm/reset time for this PIR?

Users measured an approx. 76‑second re‑arm on the BK7231N Neo PIR. Some variants reported near 2 minutes early on. Your device may vary by MCU firmware. For instant response, consider a mains‑powered or Zigbee PIR. [Elektroda, spin55, post #20591617]

How long does Wi‑Fi stay powered after a wake event on some models?

Measured on one unit: about 13–14 seconds with default behavior. Pairing mode or tmSensor handshake can extend runtime. This helps complete MQTT publishes before TuyaMCU powers Wi‑Fi down again. [Elektroda, spin55, post #20518110]

What firmware version should I run for stability and speed?

Use a recent 1.17.x build. It improves connection speed and adds faster MQTT reconnect. Earlier builds lacked full low‑power handling. Always power the module during OTA to avoid mid‑update power‑off. [Elektroda, p.kaczmarek2, post #20545084]

Why do I see “TUYA_CMD_MCU_CONF, TODO!” in the log?

It indicates MCU configuration frames were received. Early builds logged them as TODO. It is informational and not a fault. Update firmware to improve parsing and logging; operation remains unaffected. [Elektroda, caubergjef57, post #20323646]

My MAC shows 00:00:… or devices clash on the network. How do I fix it?

Open the WebApp Flash section and click Restore MAC/Restore RF button. It restores MAC to avoid conflicts. Quote: “Otherwise you might experience device disconnects when you get two devices with same empty MAC!!!” [Elektroda, p.kaczmarek2, post #20324440]

Safe OTA update: how do I avoid bricking when TuyaMCU cuts power?

Three steps:
  1. Power the module externally or jumper 3.3V to the module’s VDD.
  2. Start OTA and wait for success.
  3. Remove the jumper and reboot. Interrupted OTA can brick and require SPI recovery. [Elektroda, p.kaczmarek2, post #20320779]

Why doesn’t my PIR wake from sleep sometimes?

The TuyaMCU handles wake‑ups, not OpenBeken. If motion triggers, TuyaMCU should power the Wi‑Fi module. Troubleshoot MCU power gating, button pairing, and 9600‑baud UART before suspecting OBK. [Elektroda, p.kaczmarek2, post #20981874]

Is Zigbee or a mains‑powered PIR better for instant light automations?

Yes. Zigbee PIRs have low latency and great battery life. A non‑TuyaMCU, mains‑powered Wi‑Fi PIR also avoids wake delays. Battery TuyaMCU PIRs prioritize power saving, so delays occur. [Elektroda, spin55, post #20643778]

Edge case: can a full flash erase break Wi‑Fi or MAC?

Erasing the full 2MB can wipe the RF partition and MAC. It may impact Wi‑Fi performance. Use Restore RF if needed, but factory RF is preferred. Backup before experiments. [Elektroda, p.kaczmarek2, post #20577775]
Generated by the language model.
ADVERTISEMENT