logo elektroda
logo elektroda
X
logo elektroda

OpenBeken on WiFi Smoke Detectors (Tuya CBU Chip) - ESP8266 Alternative, MQTT & Setup

toboxx 25209 162
ADVERTISEMENT
  • #121 21346927
    vitya123
    Level 6  
    drkaresz wrote:
    Thank your vitya for your patience!

    Glad to be able to help. In other subjects I am the one receiving help - so we are even!! :)

    Cool, so you just missed the power input... No problem - I have overlooked worse things.... :)
    All is good if it works now!
  • ADVERTISEMENT
  • #122 21346962
    drkaresz
    Level 6  
    I do not forget, just follow instruction as it was written on #82
    Anyway I try as you suggested with RX, TX, GND aaaand 3.3V
    The same. On my flashing board I see something is happening when I make a short to GND (as I see before I connect 3.3V too) but the flasher program keep counting and nothing.
  • #123 21347544
    drkaresz
    Level 6  
    I believe I am not a noob just a newbie on OpenBeken but have no any success with flashing the similar device what you did.
    1. connect my usb flasher RX to YG400A-W RX
    2. connect my usb flasher TX to YG400A-W TX
    3. connect my usb flasher GND to YG400A-W GND
    4. run OpenBeken, set up COM port, link is ok
    5. start flashing ask me to GND the CBU'S CEN which is port 18, very next to the led chamber
    6. I ground it to another free GND port for a really short time
    7. flashing program keep counting and counting and nothing happen
    1. I try it with connect my usb flasher 3.3V to YG400A-W 3.3V as it was suggested by vitya but it was written in this topic #82 it is not working and was not working for me too

    Ideas:
    - my usb flasher is wrong, but when I connect it to YG400A-W I see it has communication, when I GND the CEN I see it has another type of communication via the flasher's LEDs and this flasher work as a dream with tasmota
    - my YG400A-W not compatible, it is exactly the same what some other people successfully flashed before, I've checked the wifi and CBU chips
    - the YG400A-W is wrong, but it still has its original firmware and works on my app
    - I must be a noob really after dozens of flashed iot devices...

    May I ask any idea or just forget OpenBeken? In this case can someone offer me a homeassistant compatible smoke sensor which is available on the market right now and not the Nest brand which is so expensive?
  • #124 21347610
    vitya123
    Level 6  
    Quote:
    1. connect my usb flasher RX to YG400A-W RX
    2. connect my usb flasher TX to YG400A-W TX


    These are wrong: Rx goes to Tx and vice versa.

    Also, it is a good idea to start with connecting the GNDs.
  • #125 21347669
    drkaresz
    Level 6  
    >>21347610
    Yes, that is correct. It was a typo.
  • ADVERTISEMENT
  • #127 21347751
    drkaresz
    Level 6  
    Exactly the same my friend!

    And I believe (I hope) I found something.
    Under the light chamber, there is a small, deep scratch on the integrated wire of port 18. So I've ordered another one, and give a second run for this stuff.
    I hope next week I'll get good news.

    Anyway, thank you again for your patience and help!
    And just for fun: Vitya is a Hungarian nickname, I cannot be sure you are from Hungary too but if not, I just want to let you know.

    Be back soon!
  • #128 21347758
    vitya123
    Level 6  
    According to this, pin 18 is the reset line.
    You don't really need it: you can just remove power (3.3V) for a moment AFTER you clicked flash/backup in the flasher utility. Can you try that? Just make sure you don't remove the Rx/Tx lines..

    (and yes, I am Hungarian, too :) )
  • #129 21348164
    drkaresz
    Level 6  
    To be sure not do any mistake i welded the tx,rx,gnd and try yesterday what you offer with 3.3v. But when i disconnect 3.3v the usb flasher's led keep flashing and nothing else happen.
    Maybe i was who made that scratch when the RST output do not respont my GND short circuit when the program ask me to do. Because this i try to tap the 18th pin directly with a sharp tool. Maybe it happen during the assembly in the factory. Never find out.

    I see it is not a brain surgery so i've ordered an other sensor, i'll see. And as promise write you back when i try it again.

    [Köszi vitya a segítséget, baromi jó fej vagy, hogy ilyen kitartóan próbálkozol. Cserébe én sem adom fel ;)
    Legjobbakat!]
  • #130 21348182
    vitya123
    Level 6  
    Yet another idea: What baud did you use? Maybe you could try with a lower setting..
    This is how I did it:
    Screenshot of the BK7231 Easy UART Flasher program used for automatically downloading and flashing firmware.
    If this speed is not working for you, you can try a lower one.
  • ADVERTISEMENT
  • #131 21348755
    drkaresz
    Level 6  
    I've tried this and 115200, no one.
    Now I give it a rest while the other one arrive, probably before Christmas.
  • #132 21354824
    drkaresz
    Level 6  
    Hello vitya and folks!

    I was not sure before Christmas I would receive the new sensor, but it has arrived.
    And you were right, it needs the 3.3V. :)
    With this sensor, flashing is as simple as Tasmota, works like a dream. I'm wondering how long it will last with the batteries, I've set up 8 hours wake up.

    But I have an annoying observation. If I restart Home Assistant I do not receive updates from the sensor. It connects to the network, does something and disconnects, goes back to sleep, but HA does not receive any updates. I can live with it, it is not so often I need to restart, but I am planning several smoke sensors and do not want to unmount them one by one after a restart.
    Do you have any idea?
  • #133 21355081
    vitya123
    Level 6  
    Congrats on getting it to work! :)

    As for the issue you are describing, do you use an MQTT server as the "glue" between the sensors and HA? If yes, do you see the messages in the MQTT server? What do you see in the console log of the sensor? You may simply need to make the MQTT messages from the sensor "retained". See flag #7
  • #134 21355736
    drkaresz
    Level 6  
    I am going to try flag 7 when I get back home, now it is sleeping :) Thank you.

    What is your experience, how long does a battery stand and how often do you wake it up?

    And what is that temperature that it is publishing? Is it possible to use as another fire sensor?
  • ADVERTISEMENT
  • #135 21355828
    vitya123
    Level 6  
    As for the battery: I use Eneloop Pro rechargeable batteries. I only started to use these sensors lately, i.e. a few weeks, and they are still going strong (in both sensors I have).

    I don't know about the temperature sensing capabilities of the BK7231N. From a quick look at the Tuya website, I couldn't find any confirmation if the temperature sensor is built in. Maybe someone more knowledgeable could shed some light on this.
  • #136 21356076
    drkaresz
    Level 6  
    I have some minutes at home to play:
    Flag 7 did not help, I'll try Flag 27. Ye I know it is not a new ip... have no better idea.
    Now I have to leave again so if I find out something I write the result.

    For me it looks like the tamper switch do not bring online the device.
    Can you vitya copy me your autoexec.bat code please?
  • #137 21356400
    vitya123
    Level 6  
    Here is my Autoexec.bat:

    Battery_Setup 2000 3000 2 2400 4096
    //measure batt every 2s
    Battery_cycle 2
    //mqtt_broadcastInterval 1
    //mqtt_broadcastItemsPerSec 5
    addEventHandler OnHold 10 SafeMode 5
    
    setChannelLabel 1 Smoke
    setChannelLabel 2 Tamper
    
    // now wait for MQTT
    waitFor MQTTState 1
    // extra delay, to be sure
    delay_s 1
    // publish smoke and tamper state at least once after boot
    publish 1 $CH1
    publish 2 $CH2
    
    // if tampered, keep cycling (but drains battery)
    again1:
    delay_s 1
    if $CH2!=1 then goto again1
    delay_s 5
    goto again
    
    // if smoke detected, keep cycling (but drains battery)
    again:
    delay_s 1
    if $CH1!=1 then goto again
    delay_s 5
    
    // All good, sleep for 1 day
    PinDeepSleep 86400


    I borrowed it from this forum (can't remember from where exactly)
  • #138 21356630
    drkaresz
    Level 6  
    Ye, same here. Does the tamper make online your sensor?
    Or only when it wakes up from deepsleep AND it is tampered keep online while tampering?
  • #139 21406315
    dominictauscher
    Level 3  
    I have bought four devices after reading this article. Is there a complete instruction somewhere what to do or what order? I only know tasmota so far.

    The soldering is as easy as it gets.

    Interior of a smoke detector with a visible circuit board.

    ok you need install BK7231 EASY UART flasher, Select the N model, click download latest from web and hit flash. Maybe press the reset button on the smoke alert so it will be able to flash.

    I used the current build to this date Built on Jan 23 2025 22:12:58 version 1.18.24

    BK7231 Easy UART Flasher console showing write success.

    After the flash I have to disconnect the power and reconnect and wait for openbeken wifi AP to appear, connect to 192.168.4.1 in your browser.
    If no wifi shows, 5x reconnect power to reset the device and you should see the wifi eventually.

    After entering the PIN information and the autoexe.bat it seems to work as long as it get 3.3V from the UART flasher.

    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Tuya YG400A-W Smoke Alarm Smoke Sensor",
      "model": "YG400A-W",
      "chip": "BK7231N",
      "board": "TODO",
      "flags": "1024",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "9": "dInput_n;2",
        "15": "dInput_n;1",
        "17": "WifiLED_n;3",
        "23": "BAT_ADC;4",
        "26": "BAT_Relay_n;5",
        "28": "Btn;6"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }


    Screenshot of device pin settings interface.


    I used this autoexe.bat from post 102, post 88 did not work for me

    
    Battery_Setup 2000 3000 2 2400 4096
    //measure batt every 2s
    Battery_cycle 2
    //mqtt_broadcastInterval 1
    //mqtt_broadcastItemsPerSec 5
    addEventHandler OnHold 10 SafeMode 5
    
    setChannelLabel 1 Smoke
    setChannelLabel 2 Tamper
    
    // now wait for MQTT
    waitFor MQTTState 1
    // extra delay, to be sure
    delay_s 1
    // publish smoke and tamper state at least once after boot
    publish 1 $CH1
    publish 2 $CH2
    
    // if tampered, keep cycling (but drains battery)
    again1:
    delay_s 1
    if $CH2!=1 then goto again1
    delay_s 5
    goto again
    
    // if smoke detected, keep cycling (but drains battery)
    again:
    delay_s 1
    if $CH1!=1 then goto again
    delay_s 5
    
    // All good, sleep for 1 day
    PinDeepSleep 86400 


    Restart the device, enter mqtt information of home assistant and start the homeassistant discovery from openbeken config menu. Then you should see the sensor as mqtt device in homeassistant.

    User interface for BK7231N sensor with device information and logbook.

    With this everything works nice. Thank you everybody. I really like the tamper feature so I can see if the tenants removed the smoke detectors.
    However, the tamper pin will not wake up the device from deep sleep.

    Because I changed to rechargable AAA Ni MH batteries, I changed the autoexec code as follows:

    Battery_Setup 2000 2800 2 2400 4096
    //measure batt every 30
    Battery_cycle 30
    //mqtt_broadcastInterval 1
    //mqtt_broadcastItemsPerSec 5
    addEventHandler OnHold 10 SafeMode 5
    
    setChannelLabel 1 Smoke
    setChannelLabel 2 Tamper
    
    // now wait for MQTT
    waitFor MQTTState 1
    // extra delay, to be sure
    delay_s 1
    // publish smoke and tamper state at least once after boot
    publish 1 $CH1
    publish 2 $CH2
    
    // if tampered, keep cycling (but drains battery)
    again1:
    delay_s 1
    if $CH2!=1 then goto again1
    delay_s 5
    goto again
    
    // if smoke detected, keep cycling (but drains battery)
    again:
    delay_s 1
    if $CH1!=1 then goto again
    delay_s 5
    
    // All good, sleep for 1 hour
    PinDeepSleep 3600 


    Explanation of Parameters:
    2000: The low threshold voltage (2000 mV, or 2.0V) when the battery is considered nearly empty.
    2800: The high threshold voltage (2800 mV, or 2.8V) when the battery is fully charged.
    2: The frequency of battery measurement (every 2 seconds).
    2400: The scale factor for normalizing the readings (typically set to the nominal voltage, 2400 mV for a 2-cell pack).
    4096: The maximum ADC value (assumes a 12-bit ADC, common in microcontrollers).
  • #140 21409026
    sithyoda
    Level 7  
    I did it the same way as @dominictauscher.
    I can configure wifi but the device simply refuses to connect to the WLAN. Of course I tried many different WiFi's, with short keys and keys without special characters. I also tried different wifi encryptions - no luck.
    After a while it starts in save mode and broadcasts its own wifi again:
    Screenshot of the brandmelder_garage device interface in safe mode.

    Any idea on how I could debug the startup? Is there maybe a way to log via uart ?
  • #141 21409031
    dominictauscher
    Level 3  
    >>21409026
    maybe try to change the wifi name or password, or try to connect to a different device for testing such as your iphome
  • #142 21409036
    sithyoda
    Level 7  
    I am a professional network tech, so trust me, the wifi setup(s) are ok. I even tried an open wifi (no encryption at all), but the device does not want to connect.
    When it is in AP mode for initial configuration, it can even see wifi's after a scan. So I expect that the wifi chip is definitely OK.

    I simply need to find a way to get the bootlogs, I expect that it would reveal the problem.
  • #143 21409040
    dominictauscher
    Level 3  
    >>21409036
    Maybe try to flash a different version,
    Something sounds wrong
  • #144 21409044
    sithyoda
    Level 7  
    dominictauscher wrote:
    >>21409036
    Maybe try to flash a different version

    Had version 1.17.772 on the board before, but I upgraded because of this problem.
  • #145 21409118
    dominictauscher
    Level 3  
    Then I would just buy another one, I flashed four successfully and I’m not a network pro
  • #146 21411898
    p.kaczmarek2
    Moderator Smart Home
    Maybe check UART 2 (TX2) log at 115200? Or maybe try to change one character in MAC, maybe you have MAC collision?
    Helpful post? Buy me a coffee.
  • #147 21411903
    sithyoda
    Level 7  
    @p.kaczmarek2 Thx! This was the hint I needed. Will have a look asap.
  • #148 21413001
    sithyoda
    Level 7  
    Ok, it's not the MAC address, I've changed it with no difference.
    The bootlog ends with a deep sleep, even I installed a complete new config with flash tool. So in fact there should not be any startup nor autoexec.bat. Dunno why it falls into sleep before connecting to wifi.
    Attached bootlog
  • #149 21415281
    sithyoda
    Level 7  
    @p.kaczmarek2 Any hint, what could cause the deep_sleep?
  • #150 21420610
    p.kaczmarek2
    Moderator Smart Home
    There are 3 options:
    a) autoexec.bat
    b) short startup command
    c) you have DoorSensor pin defined
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the integration of OpenBeken firmware with Tuya CBU chip-based WiFi smoke detectors, specifically the YG400A-W model. Users share experiences with flashing the firmware, configuring MQTT, and troubleshooting issues related to smoke detection and battery management. Key challenges include the device's inability to wake up from deep sleep to report smoke detection, the need for proper pin configuration, and the implementation of battery monitoring. Solutions discussed include using specific pin roles, setting up autoexec.bat for device behavior, and the potential for GPIO and timer wake-up functionality in future firmware updates. Users also express interest in creating a network of interconnected smoke detectors for enhanced alarm capabilities.
Summary generated by the language model.
ADVERTISEMENT