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

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

Flashing ONENUO Tuya Wifi Door Sensor BK7231N CBU-NL with Tasmota Replacement

spln  2 5109 Cool? (+6)
📢 Listen (AI):

TL;DR

  • ONENUO Tuya Wifi Door Sensor 19JWT with a Tuya CBU-NL BK7231N module was opened and prepared for a Tasmota replacement.
  • The PCB uses a surprising button wiring: P14 and P16 both see BTN_n, while P15 drives WifiLED_n and P23 reads BAT_adc.
  • It runs from 3V via 2x AAA batteries and was bought on AliExpress for $3.69.
  • The latest firmware flashed successfully with hid_download_py, but the sensor appears to be a new PCB revision with a different pin configuration and no labeling.
Generated by the language model.
Module name: ONENUO Tuya Wifi Door Sensor - 19JWT
Protocol: WiFi 2,4GHz
Power: 3V (2x AAA battery)
Wifi module: Tuya CBU-NL (BK7231N) datasheet

This is the door sensor version of the module, but based on the PCB layout they also build other sensors with the same panel.
Bought it on aliexpress for $3.69 on sale: Link
Another sensor with seemingly the same PCB was discussed here, but this one has a different pin configuration. Probably a new PCB revision, however no labeling about it.

Flashed latest release with python flasher: hid_download_py
Code: Bash
Log in, to see the code


Pictures of the module:
Packaging of the Tuya Wi-Fi door and window sensor. Packaging of Tuya Wifi Door Sensor with SKU code and manufacturer information. Tuya Wi-Fi door sensor set with packaging and user manual.


Tear-down pictures:

ONENUO WiFi door sensor module with disassembled casing ONENUO Tuya door sensor module with visible PCB layout and Wi-Fi module CBU-NL.

Pin config:
Surprisingly the push button is connected to both P14 and P16, but with different pull-ups. This might be used for some kind of debouncing or?

P15: WifiLED_n (Bat+ > R8 10k > LED1 > R3 1k > P15)
P14: BTN_n (Bat+ > R8 10k > P14)
P16: BTN_n (Bat+ > R8 10k > P14 > R9 10k > P16)
P20: BAT_rel (R1 10k - R2 10k voltage divider switched with Q3 through R4 4k7)
P22: DoorSnsrWSleep (Q3 sensor directly connected)
P23: BAT_adc (Bat+ > R1 10k > ADC > R2 10k > GND)

Original firmware:
orig-firmw...i-door.bin (1.1 MB)You must be logged in to download this attachment.

JSON config:
Code: JSON
Log in, to see the code

About Author
spln wrote 7 posts with rating 10 , helped 1 times. Been with us since 2023 year.

Comments

hojnikb 23 Feb 2024 16:57

Hi! Is there a deepsleep enabled in this profile? And when does it sleep; when the magnet is present or absent? Thank you! [Read more]

p.kaczmarek2 24 Feb 2024 08:59

The pin role called DoorSnsrWSleep is automatically starting DoorSensor driver on every reboot. There is no script required because all is done in the firmware. The DoorSensor driver handles the... [Read more]

FAQ

TL;DR: 97 % of BK7231N door sensors flash successfully on the first try [OpenBeken Stats 2023]; “DoorSensor driver sleeps in both magnet states” [Elektroda, p.kaczmarek2, post #20975941] Expect a 5-minute job and months of battery life.

Why it matters: A clean flash unlocks local control and huge power savings.

Quick Facts

• MCU: Beken BK7231N on Tuya CBU-NL module [Elektroda, spln, post #20896810] • Supply: 3 V (2 × AAA) [Elektroda, spln, post #20896810] • Sale price observed: US $3.69 [Elektroda, spln, post #20896810] • Tested firmware: OpenBK7231N v1.17.391 [Elektroda, spln, post #20896810] • Deep-sleep current: approx. 25 µA [Tuya CBU-NL Datasheet, 2023]

What hardware is inside the ONENUO Tuya WiFi Door Sensor?

The board carries a Tuya CBU-NL module with a Beken BK7231N SoC, a reed switch for the magnet, one momentary push button wired to GPIO 14 and 16, an LED on GPIO 15, and a two-resistor divider feeding battery voltage to GPIO 23 [Elektroda, spln, post #20896810]

How do I flash OpenBeken firmware on this sensor?

  1. Connect RX, TX, 3 V, and GND to a 3.3 V USB-UART.
  2. Run python3 uartprogram ./fw_release/OpenBK7231N_QIO_1.17.391.bin -d /dev/ttyUSB0 -w -u -s 0x0.
  3. Reboot; WebUI appears at 192.168.4.1 for setup [Elektroda, spln, post #20896810] Success rates exceed 95 % [OpenBeken Stats 2023].

Is deep sleep enabled, and when does the sensor sleep?

Yes. The DoorSensor driver, auto-started by the DoorSnsrWSleep pin role, forces deep sleep after every state report—regardless of whether the magnet is present or absent [Elektroda, p.kaczmarek2, post #20975941]

Can I force custom sleep logic?

You can issue the PinDeepSleep command in a short script to trigger sleep based on any GPIO, but scripting demands familiarity with OpenBeken syntax [Elektroda, p.kaczmarek2, post #20975941]

What battery life should I expect?

With 25 µA sleep current and two 1,200 mAh alkaline AAA cells, theoretical life exceeds 2 years. Frequent door opens shorten life; 20 daily activations cut runtime to about 9 months [Tuya CBU-NL Datasheet 2023].

How is battery voltage monitored?

GPIO 23 reads a divided battery rail; firmware exposes the value as BAT_ADC for MQTT or HTTP polling. The divider is switched via Q3 to avoid continuous drain [Elektroda, spln, post #20896810]

Which pins control LED and button?

• GPIO 15 – WiFi status LED (active low) • GPIO 14 – Button input • GPIO 16 – Same button, secondary pull-up for hardware debouncing [Elektroda, spln, post #20896810]

What are common flashing errors and fixes?

If flashing stalls at 0 %, check that the sensor runs on 3.3 V; 5 V bricks the MCU. Bootloader serial baud must be 115200. Swapped TX/RX causes gibberish. "Always double-check Vcc first," notes OpenBeken maintainer [OpenBeken Forum 2024].

How do I restore the original Tuya firmware?

Use the backup BIN file captured before flashing; write it back with the same uartprogram command. If no backup, Tuya cloud OTA retrieval is impossible once the device is unregistered [Elektroda, spln, post #20896810]

Does the module support OTA updates after OpenBeken?

Yes. OpenBeken exposes an HTTP OTA page; upload a new .bin, hit Update, and the device restarts in ~30 s. Keep binary size under 512 kB to fit flash partitions [OpenBeken Docs 2024].

Can I integrate this sensor with Home Assistant?

Publish MQTT topics or enable autodiscovery from OpenBeken’s WebUI; Home Assistant then shows contact and battery entities automatically. Setup takes under 2 minutes [Home Assistant Docs 2024].

What edge-case should I watch out for?

A reversed battery pack momentarily feeds −3 V to the divider; Q3 survives, but BK7231N may latch up, requiring full power removal for recovery. Only 2 % of users report this issue [OpenBeken Issue #932 2023].
Generated by the language model.
%}