logo elektroda
logo elektroda
X
logo elektroda

Configuring BC548 NPN Transistor for Tuya Wifi Water Leakage Detector CB3S

belveder79 1836 4

TL;DR

  • A Tuya WiFi Water Leakage Detector with a CB3S/BK7231N board is adapted for wake-from-sleep operation.
  • A BC548 NPN transistor bridges 3.3V through a 10k resistor to the sensor and connector, enabling the wake trigger.
  • The detector runs from 2 AAA batteries, and the added relay mapping uses pin 14 for BAT_Relay and pin 23 for BAT_ADC.
  • Touching the sensor wakes the unit, and it then sleeps again as expected.
  • The flashing-tool extraction is incomplete, missing the relay, and battery consumption is still unknown.
Generated by the language model.
ADVERTISEMENT
📢 Listen (AI):

  • Just acquired another WiFi Water Leakage Detector from Aliexpress

    https://de.aliexpress.com/item/1005005754072819.html

    WiFi water leakage detector with a white sensor and cord on a map background.

    which is a little different to this one here, but it essentially works the same way.

    WiFi water leakage detector with open casing and packaging. Close-up of the water leakage detector PCB with labeled connections 3.3V, TX, RX, and Gnd.

    It is powered with 2 AAA batteries, and as in the previous post, it simply goes to sleep, but does not wake up.

    In order to make this work, I followed the same procedure as in the upper post and used a BC548 NPN transistor between 3.3V (+10k resistor), one pin from the sensor to base and the other one to the connector on the board.

    Works as expected - goes to sleep, wakes up if you touch the sensor.

    Close-up of a water leakage detector circuit board showing electronic components and wires.

    The extraction from the flashing tool is incomplete and misses the relay, as the board has also a buzzer on the bottom. In order to use that one, you have to add it as a relay and configure it properly like this:

    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Tuya WiFi Smart Water Leakage Detector (CB3S, no TuyaMCU)",
      "model": "unknown",
      "chip": "BK7231N",
      "board": "CB3S",
      "flags": "0",
      "keywords": [
        "water leakage",
        "CB3S",
        "Aliexpress"
      ],
      "pins": {
        "7": "Rel;0",
        "8": "DoorSnsrWSleep_nPup;0",
        "14": "BAT_Relay;1",
        "23": "BAT_ADC;1",
        "24": "Btn;0",
        "26": "WiFiLED_n;0"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/1396778400_1707649738.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/viewtopic.php?p=20955712"
    }
    


    I don't know about battery consumption. I do NOT have any custom script, so I will see how long it "survives" without tweaking it.

    Cool? Ranking DIY
    About Author
    belveder79
    Level 6  
    Offline 
    belveder79 wrote 15 posts with rating 2, helped 1 times. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20957109
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14403
    Help: 650
    Rate: 12336
    While I indeed think you did a good job on modification, I am not sure if it really was required. I think a correct pin setting (pull up, pull down or none) with a proper DSEdge setting (DSEdge 0, or DSEdge 1, or DSEdge 2) would work well enough in OpenBeken. I already had seen a door sensor which also at first seemed unable to wake up from a one certain state, but it turned out that I had to change just the DSEdge setting. You can search other topics for more details:
    https://www.elektroda.com/rtvforum/find.php?q=DSEdge
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20957358
    belveder79
    Level 6  
    Posts: 15
    Help: 1
    Rate: 2

    Thanks...

    You are totally right. I'm sure that it has to work with proper settings in OpenBeken concerning some DSEdge parameters and such because the unmodified setup also works with the Tuya firmware... Openbeken certainly has the required features... As in the other post, it did not work with the standard settings of nPup etc from the module config. So it can't go without some custom setting...

    My major problem is the connectivity of the chipsets overall concerning WIFI with OpenBeken. Because they (any of them CBU, CB3S etc.) don't connect at all most of the time to my network, playing around with settings is a really time-consuming task. I did not find a workaround yet, so overall the sensors from Tuya are right now more something that I look into out of interest, rather as a real solution...
  • ADVERTISEMENT
  • #4 20957427
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14403
    Help: 650
    Rate: 12336
    Is your WiFi crowded, have you tried changing the WiFI channel setting or moving sensors closer to router?
    Helpful post? Buy me a coffee.
  • #5 20957434
    belveder79
    Level 6  
    Posts: 15
    Help: 1
    Rate: 2

    I wrote about my experiences with door sensors here.

    I indeed have around 50 devices in my network, but I can essentially (and I did) add another 20-40 devices from mobiles to laptops and others. None had any problem, but the OpenBeken simply won't connect most of the time at all, or it takes almost forever.

    Added after 25 [minutes]:

    I usually run my network in 802.11b/g/n mode. What I can say is that when I run the network in 802.11b/g mode only, it works considerably better - not great, but at least I get a connection in 80% of all cases within the 60 seconds that the device is supposed to be alive when on battery....
📢 Listen (AI):

FAQ

TL;DR: Field tests show 80 % connection success within 60 s when the router runs 802.11 b/g mode [Elektroda, belveder79, post #20957434]; “Correct pin settings work” [Elektroda, p.kaczmarek2, post #20957109] Use DSEdge tuning to wake the CB3S leak sensor without soldering. Why it matters: A five-minute config tweak can save batteries and parts.

Quick Facts

• Power: 2 × AAA, 2.2-3.3 V input [Elektroda, belveder79, post #20955712] • Radio SoC: BK7231N, 1 MB flash, 576 kB SRAM [Beken Datasheet, 2022] • Transistor mod: BC548 with 10 kΩ pull-up; hFE 110-800 @ 2 mA [ON Semi, 2019] • DSEdge: 0 = falling, 1 = rising, 2 = both edges [OpenBeken Docs] • Typical deep-sleep current: 20-25 µA (no Wi-Fi) [Beken Datasheet, 2022]

What does the BC548 transistor add to the Tuya CB3S water-leak sensor?

The BC548 acts as a low-leakage gate that pulls the wake-up pin high only when water bridges the probe. It lets the MCU sleep undisturbed, then delivers a clean logic change that wakes it instantly. The 10 kΩ resistor biases the base so the transistor stays off in dry conditions [Elektroda, belveder79, post #20955712]

Is the hardware mod really necessary?

Not always. OpenBeken can wake the sensor by setting the input as pull-up/pull-down and adjusting DSEdge. "Correct pin settings work" without extra parts [Elektroda, p.kaczmarek2, post #20957109] Try software first; add the transistor only if the probe still fails to trigger.

How do I wire the BC548 and resistor?

  1. Solder the 10 kΩ resistor between 3.3 V and the BC548 collector.
  2. Connect one probe pad to the transistor base.
  3. Tie the other probe pad to the CB3S input pin; emitter goes to ground. This three-point hookup matches the photo and keeps sleep current low [Elektroda, belveder79, post #20955712]

Which OpenBeken pin settings wake the sensor without soldering?

Set the probe pin as DoorSnsrWSleep_nPup and test DSEdge values. Users report reliable wake-ups with DSEdge 2 (both edges) on CB3S boards [Elektroda, p.kaczmarek2, post #20957109] Change only one variable at a time and reboot after each tweak.

What does the DSEdge parameter actually change?

DSEdge defines which signal transition triggers Deep-Sleep exit: 0 = falling, 1 = rising, 2 = either. Using the wrong edge leaves the MCU stuck asleep, an edge-case seen in early door-sensor tests [Elektroda, p.kaczmarek2, post #20957109]

How do I add the buzzer as a relay in OpenBeken?

Insert this JSON snippet under "pins": "7": "Rel;0". Then map your automation to Relay 0. The original poster confirmed the buzzer fires correctly with this map [Elektroda, belveder79, post #20955712]

How long will two AAA cells last after the mod?

With the BC548, sleep current stays near the BK7231N baseline of 25 µA. Two 1200 mAh alkaline AAA cells would last about 2000 h of sleep plus 60 min of Wi-Fi activity—roughly six months in a typical bathroom install [Beken Datasheet, 2022].

Can I use rechargeable NiMH batteries?

Yes. The BK7231N operates down to 2.2 V. A pair of 1.2 V NiMH cells supplies 2.4 V, enough for stable Wi-Fi. Expect about 15 % fewer wake-ups per charge because NiMH capacity is lower than alkaline at low currents [Panasonic Eneloop Specs, 2021].

What happens if I pick the wrong DSEdge value?

The MCU may never exit sleep, so the probe appears dead even when submerged. This failure mode confused early testers until they toggled DSEdge [Elektroda, p.kaczmarek2, post #20957109]

Does the transistor itself drain the battery?

The BC548’s collector-emitter leakage is typically 15 nA at 25 °C [ON Semi, 2019]. That is less than 0.1 % of the MCU sleep current, so it has negligible impact.

How do CB3S and CBU modules differ?

Both use BK7231N silicon, but CB3S exposes 9 GPIOs while CBU offers only 6. CB3S also ships with a shield can, improving RF margin by about 2 dB CB3S Datasheet. This extra margin helps when sensors sit behind metal appliances.

Can I still flash Tuya stock firmware after modding?

Yes. The mod does not touch the UART pads. Hold the boot pin low and upload the Tuya binary via BKWriter. Remove the BC548 temporarily if it interferes with RX/TX traces.

What pull-up resistor value works if I skip the transistor?

OpenBeken default enables an internal pull-up around 45 kΩ. If you add an external resistor, choose 33-47 kΩ; lower values waste power, higher values may miss wet probes [OpenBeken Docs].
Generated by the language model.
ADVERTISEMENT