logo elektroda
logo elektroda
X
logo elektroda

[CBU/BK7231N] Configuring GPIO Pins for Flood Water Leak Sensor Guudgo DP-WW001 with deep sleep

jonira 654 1
ADVERTISEMENT
  • #1 21225260
    jonira
    Level 2  
    I have a Flood Water Leak Sensor and here are some info about it. It’s using a CBU BK7231N module and the model on the PCB is DP-WW001. It was running 1.0.11 firmware. It was bought from banggood (not available at the moment)

    White water leak sensor with attached cable lying on a wooden surface.View of an open water leak sensor with visible PCB.CBU BK7231N module on a printed circuit board with pin layout. Firmware update screen showing version V1.0.11 information. Digital multimeter measuring voltage in an electronic circuit.Listing for Tuya WiFi flood alarm device with integration features in an online store.

    I couldn’t get the gpio pins from Tuya GPIO Config so I tried to find them manually. It seems it has the same pins with the other water leak sensors using the CBU module.
    Here is the OBK config:
    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Guudgo Flood Water Leak Sensor",
      "model": "DP-WW001", 
      "chip": "BK7231N",
      "board": "CBU",
      "flags": "1024",
      "keywords": [
        "water",
        "leak",
        "flood"
      ],
      "pins": {
        "16": "dInput_NoPullUp_n;1",
        "17": "BAT_Relay;4",
        "20": "Btn;2",
        "23": "BAT_ADC;5",
        "26": "WifiLED;3"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
    


    I flashed it using UART with BK7231 GUI Flash Tool.
    I compared many other autoexec files from other posts to understand what is needed and I tried to keep it simple. In the future I want to improve it and go into sleep for 1 day if MQTT is not connected after a few seconds.
    
    // channels
    // 1(pin 16) dInput_NoPullUp_n
    // 2(pin 20) Btn
    // 3(pin 26) WifiLED
    // 4(pin 17) BAT_Relay
    // 5(pin 23) BAT_ADC
    
    PowerSave 1
    
    // Battery config and measure every 2sec
    Battery_Setup 2000 3000 2.03 2400 4096
    Battery_cycle 2
    
    // 0: wake up on rising edge
    // 1: wake up on falling edge
    // 2(default): state high - wake up on falling edge, state low - wake up on rising edge
    // Second argument (optional) allows to set per-pin DSEdge
    DSEdge 0 16
    
    // button (pin 20) hold launch safe mode
    addEventHandler OnHold 20 SafeMode
    
    setChannelLabel 1 "Water Leak"
    
    // wait for MQTT connection
    waitFor MQTTState 1
    delay_s 1
    
    // publish water state
    publishchannel 1
    
    // wait and sleep
    delay_s 20
    PinDeepSleep
    


    The water sensor is 0 when it detects water. If it changes from 1 to 0 and then back to 1 (dry) the sleeping/waking is working fine. There is an issue when it changes from 1 to 0 (waking up) and staying at 0 (wet) when it goes into sleep.
    Spoiler:
    If I set DSEdge to 0:
    waking up, after delay_s 20 restarts, after delay_s 20 sleeping. if sensor changes 1 > 0 it’s waking up.
    If I set DSEdge to 1:
    waking up, after delay_s 20 restarts, after delay_s 20 sleeping. no waking up.
    If I set DSEdge to 2:
    waking up, after delay_s 20 sleeping. no waking up.

    At the moment I have set DSEdge to 0 which seems to work better except the restart when it should go into sleep. I might need to investigate it further.
  • ADVERTISEMENT
  • #2 21225654
    divadiow
    Level 35  
    the pin assignments are also listed in the boot log for this device

    Code: Text
    Log in, to see the code


    "basic_pin_pin": 16
    "bt_pin": 20
    "samp_sw_pin": 17
    "samp_pin": 23
    "status_led_pin": 26


    "max_V": 3000
    "min_V": 2200

    looks like it'll be cloudcuttable too

    Added after 14 [minutes]:

    the pin assignments match this water leak sensor, but the case/PCB is clearly different https://www.elektroda.com/rtvforum/topic4056603.html

    https://github.com/OpenBekenIOT/webapp/pull/144
ADVERTISEMENT