logo elektroda
logo elektroda
X
logo elektroda

Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

khafif 3366 10
ADVERTISEMENT
  • #1 20611044
    khafif
    Level 5  
    TUYA-BK7231N/CBU-Wi-Fi-door sensor-Home assistant MQTT setup

    Need detailed setup for flashing the TUYA-BK7231N/CBU-Wi-Fi-door sensor and Home assistant MQTT setup please. Thank you.

    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

    2023-08-06 UPDATE:
    Here is a nice step by step guide for flashing it and deep sleep setup:

    [BK7231N/CBU] Door sensor without TuyaMCU - easy flashing and configuration guide
    NOTE: The following sensor is using BK7231 deep sleep, it has no TuyaMCU.
  • ADVERTISEMENT
  • Helpful post
    #2 20611082
    p.kaczmarek2
    Moderator Smart Home
    Hello, this device is already supported by OpenBeken:
    https://github.com/openshwprojects/OpenBK7231T_App
    You can find our flasher here:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    I think the setup approach from here could work:
    https://www.elektroda.com/rtvforum/topic3972898.html
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20611389
    khafif
    Level 5  
    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

    - mqtt was discovered by HA. door sensor goes sleep but the deep sleep and push button are not working when sensor goes sleep. I have to manually turn it off and on every time it goes to sleep.

    - I do not have deep sleep in the drop down list (attached photo).

    Thank you.

    Added after 24 [minutes]:

    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

    in this post (firmware) you have displayed sensor battery at HO, but now it is not showing.
    https://www.elektroda.com/rtvforum/topic3914412.html is the new version missing this option or it is me. Thanks.

    Added after 11 [hours] 27 [minutes]:

    I know you need my tuya back, copy attached original tuya firmware.
  • #4 20611799
    khafif
    Level 5  
    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

    weblog
    Info:MQTT:Channel has changed! Publishing 1 to channel 43
    Info:MQTT:Publishing val 1 to BK_DS1/43/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BK_DS1/43/get
    Info:MQTT:Channel has changed! Publishing 1 to channel 47
    Info:MQTT:Publishing val 1 to BK_DS1/47/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic BK_DS1/47/get

    am going to try the deep sleep and the push button.
  • ADVERTISEMENT
  • #5 20612363
    p.kaczmarek2
    Moderator Smart Home
    Hello again, if the sensor does not wake up, it can mean that:
    - you have chosen wrong IO for sensor role
    - you have incorrect DSEdge setting (DSEdge 2 is default, there is also DSEdge 1 or DSEdge 0)

    khafif wrote:
    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT
    - I do not have deep sleep in the drop down list ( attached photo).

    For which role are you looking for? It seems you have all required roles here. I can see one role for DoorSensor (the PD role, input with PullDown). If you want a pull-up input door sensor role, scroll up, it's a bit earlier on the list.

    Don't forget that if you set a Button role for pairing Button, it will also be able to wake up the device in the time of emergency. That way you can play around with settings and choose the ones that suits you best.
    Helpful post? Buy me a coffee.
  • #6 20612399
    khafif
    Level 5  
    Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT Flashing and Deep Sleep Setup Guide for TUYA-BK7231N/CBU Wi-Fi Door Sensor with Home Assistant MQTT

    1- I managed (don't ask how) to get these results.
    2- I cannot remove/find channel 1 in any setup?
    3- I had to use dInput_n to reverse HO sensor action.
    4- Door sensor sleep mode in HO not displaying ON or OFF?
    5- MQTT state not displaying disconnected when in sleep mode?
    6- How can I control the sleep mode duration (to reduce the time frame)?
    7- How to turn OFF LED, it is always on.
    8- Can we blink the LED (in Bright light) when awake mode triggered by Button or Door Sensor?





    Added after 4 [minutes]:

    One more clarification, can we display battery state in HO as voltage and capacity percentage so we can enable an alarm triggered at battery percentage to be replaced!

    Thank you for the great achievement, keep it going and regards to all the team.
  • #7 20638378
    simovicsava
    Level 7  
    Guys, I found the correct settings. :-))))

    Link
  • #8 20639725
    khafif
    Level 5  
    Thanks, I’ll check it and give feed back.
  • #9 20639762
    p.kaczmarek2
    Moderator Smart Home

    DSEdge (the wake up edge of deep sleep, either "opposite of current", "rising" or "falling") and the exact Door Sensor pin type (pull up, no pull up, etc) can change between devices. Please always remember to set the Button role for your button so you can do an emergency wake up of the device if the door sensor GPIO is configured incorrectly.
    Helpful post? Buy me a coffee.
  • #10 20646748
    khafif
    Level 5  
    now the door sensor is not connected to my wifi router, I cannot reset to access AP mode, I did flash it more than 5 times using the UART flasher, still cannot access the access point web site to enter my WiFi pass-code. The BK flasher always writing file data to chip is success.

    is there any other methods/ways to follow to diagnose the board.

    
    Starting flash new (no backup)!
    Now is: 08 July 2023 18:35:40.
    Flasher mode: BK7231N
    Going to open port: COM5.
    Serial port open!
    Getting bus... (now, please do reboot by CEN or by power off/on)
    Getting bus failed, will try again - 0/100!
    Getting bus failed, will try again - 1/100!
    Getting bus failed, will try again - 2/100!
    Getting bus success!
    Going to set baud rate setting (921600)!
    Will try to read device flash MID (for unprotect N):
    Flash MID loaded: 1560EB
    Will now search for Flash def in out database...
    Flash def found! For: 1560EB
    Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
    Entering SetProtectState(True)...
    sr: 80
    sr: 680
    final sr: 680
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    SetProtectState(True) success!
    Reading file firmwares/OpenBK7231N_QIO_1.17.104.bin...
    Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.104.bin...
    Preparing to write data file to chip - resetting bus and baud...
    Getting bus... (now, please do reboot by CEN or by power off/on)
    Getting bus success!
    Going to set baud rate setting (921600)!
    Will try to read device flash MID (for unprotect N):
    Flash MID loaded: 1560EB
    Will now search for Flash def in out database...
    Flash def found! For: 1560EB
    Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
    Entering SetProtectState(True)...
    sr: 80
    sr: 680
    final sr: 680
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    SetProtectState(True) success!
    Going to do erase, start 0, sec count 298!
    Erasing sector 0... ..........
    Writing file data to chip successs.
  • ADVERTISEMENT
  • #11 20684028
    p.kaczmarek2
    Moderator Smart Home
    @khafif in worst case, you can try doing full 2MB erase but maybe backup RF partition first so you can restore it later... I will look into adding a dedicated option for that to our flasher.

    2023-08-06 UPDATE:
    Here is a nice step by step guide for flashing it and deep sleep setup:

    [BK7231N/CBU] Door sensor without TuyaMCU - easy flashing and configuration guide
    NOTE: The following sensor is using BK7231 deep sleep, it has no TuyaMCU.
    Helpful post? Buy me a coffee.

Topic summary

The discussion focuses on the setup and flashing of the TUYA-BK7231N/CBU Wi-Fi door sensor for integration with Home Assistant using MQTT. Users share resources for flashing the device, including links to OpenBeken support and the BK7231 GUI Flash Tool. Issues arise with deep sleep functionality, MQTT state visibility, and battery status display. Users report problems with the sensor not waking from deep sleep, incorrect settings for input/output roles, and difficulties in accessing the device's access point mode after flashing. Solutions involve adjusting DSEdge settings, ensuring correct GPIO configurations, and troubleshooting connection issues. A step-by-step guide for flashing and deep sleep setup is also referenced.
Summary generated by the language model.
ADVERTISEMENT