logo elektroda
logo elektroda
X
logo elektroda

Water Detector 898WT: How to Turn Off WiFi LED During Sleep Mode?

rubenlogon 654 7
ADVERTISEMENT
  • #1 21083787
    rubenlogon
    Level 4  

    I flashed the 898WT water sensor available on AliExpress with openbeken. This is the PCB which contains a CBU module:
    Printed circuit board with a CBU electronic module and connected cable.
    I have everything almost ready with the following pin configuration:
    Screenshot of pin configuration settings for the 898WT water sensor.
    The BAT file I am using is this (heavily based on the smoke detector BAT file):
    
    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 Water
    // now wait for MQTT
    waitFor MQTTState 1
    // extra delay, to be sure
    delay_s 1
    // publish water state at least once after boot
    publish 1 $CH1
    // if water detected, keep cycling (but drains battery)
    again:
    delay_s 1
    if $CH1=1 then goto again
    delay_s 15
    // All good, sleep for 5 days
    PinDeepSleep 432000 


    Everything seems to work, the device wakes from sleep to notify water leaks but the small problem I am facing is that, WiFi LED blinks while connecting to WiFi, it stays on once it is fully connected, but after Sleep command is executed the LED stays on. I think it won't draw much battery, but I think it will be better to keep it off while sleeping. Is it possible to do this?. Thank you
  • ADVERTISEMENT
  • #2 21083804
    p.kaczmarek2
    Moderator Smart Home
    That's a very interesting problem. I haven't seen that one yet. It's possible that somehow Beken does not set the pin in the required state when going to sleep.

    Well, the simplest way to fix it would be to just set the WiFi role to "WiFiLED" instead of "WiFiLED_n", can you try is that approach working?

    Alternatively, we could just set the LED pin on boot to WiFi role and then before sleep try setting it to something like AlwaysHigh or AlwaysLow, see roles list here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md
    That approach has however one downside - it will slowly wear out flash. Still, if you are expecting this device to boot every 5 days or when there is a water leak, then I don't think that flash wear will be ever noticeable...

    I could also try to add some command or a clause to PinDeepSleep to fix that, but that would require some more testing, would you like to help?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21083839
    rubenlogon
    Level 4  

    Hi. Setting role to wifiled makes the led blink while connecting but it stays off while connected but also while sleeping which, from a battery point of view, is a better solution. How can I set pin roles (wifiled or alwayslow) in the bat file? Yeah, I would like to help in everything I can :). Thanks for your reply!
  • #4 21083844
    p.kaczmarek2
    Moderator Smart Home
    There is a command for setting pin role from script, it can be found there:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    It seems to be called: SetPinRole.
    A documentation excerpt showing the SetPinRole command for setting pin roles.

    I can also consider adding a hardcoded solution to your problem, but I am not yet sure whether it's something common or specific to your device.

    By the way, it should be just also possible to write a script that does a "WIFI LED" effect on a simple digital pin with a LED or REL role on a separate channel, but I would need to look into it for a few moments more. Something like "myWiFiLED.bat".
    Helpful post? Buy me a coffee.
  • #5 21083931
    rubenlogon
    Level 4  

    For the moment, I add some pictures from the installation:
    Close-up of a sensor mounted by the wall with an attached cable and a visible opening for the LED. Image of sensor installation on a tiled wall with an open door. Close-up of a sensor with an attached cable secured with hot glue.
    I glued the tip of the cable with the electrodes to the body of the sensor using some hot melt glue to keep the electrodes always parallel to the ground. The hole present in the tip of the cable is aligned to make the led present on the body visible in it. I made it this way because the sensor has an adhesive back cover that you need to slide in order to access the batteries. If you glue the electrodes to the opposite part of the sensor's body, with the electrodes touching the ground, you would need to slide the body down in order to remove the body from the wall, which means that in fact you won't be able to do so.
  • ADVERTISEMENT
  • #6 21083970
    p.kaczmarek2
    Moderator Smart Home
    That's a very nice setup. I would like to add this device to our supported devices list, but I need one more thing - device template in JSON format. Would you be able to provide that soon? It's not easy to type down config from the screenshot...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Helpful post
    #7 21083978
    rubenlogon
    Level 4  

    Here it goes:
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Full Device Name Here",
      "model": "enter short model name here",
      "chip": "BK7231N",
      "board": "TODO",
      "flags": "1024",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "14": "Btn;2",
        "15": "WifiLED;0",
        "20": "BAT_Relay;4",
        "22": "dInput_n;1",
        "23": "BAT_ADC;5"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }


    Added after 47 [minutes]:

    Just as a curiosity, the PCB looks almost the same as for the ONENUO Tuya Wifi Door Sensor BK7231N CBU-NL with slight changes.
  • #8 21084258
    p.kaczmarek2
    Moderator Smart Home
    That's correct. I have also noticed it when I was testing such devices. Tuya seems to be using the same PCB/design for water and door sensors. Ah, and for humidity/temperature sensors as well, at least often.

    Thank you for sharing template!
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around configuring the WiFi LED behavior of the 898WT water detector, which has been flashed with OpenBeken firmware. The user seeks to turn off the WiFi LED during sleep mode to conserve battery. Suggestions include changing the pin role to "WiFiLED" or "AlwaysLow" using the SetPinRole command from the script. The user successfully implements a setup that keeps the LED off during sleep, which is more battery-efficient. Additionally, a JSON template for the device configuration is shared, highlighting similarities with other Tuya devices. The conversation emphasizes collaboration on testing and improving the firmware for better functionality.
Summary generated by the language model.
ADVERTISEMENT