logo elektroda
logo elektroda
X
logo elektroda

How to Automate Water Barrel Filling With OpenBeken, CB3S, XKC-Y25-V Sensors, MQTT?

ydennn 237 1
ADVERTISEMENT
  • #1 21546991
    ydennn
    Level 1  
    Hello everyone could you tell me how to implement my idea? I have a smart valve on a cb3s board on a BK7231N chip, I have already flashed it with openbeken 1.18.99 firmware.

    initial configuration
    Quote:

    {
    "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": "Rel;1",
    "24": "LED;1",
    "26": "Btn;1"
    },
    "command": "",
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }

    she allowed the valve to be started, it is triggered by a button and can now be controlled by mqtt, which is already good

    My goal is to set up using this valve and two sensors xkc-y25-v, to set up automatic filling of the water barrel.
    The sensor operates on the principle of giving out 1 at the outlet when water is detected

    the logic of the operation should be as follows:
    the first sensor is installed at the bottom of the barrel, the second at the top

    If both sensors have 0, then the valve must be opened, if the second sensor has 1, then the valve must be closed or if more than 40 minutes have passed after opening. It would also be nice if the valve is powered, it should lock.

    I added 2 inputs to the configuration, when the sensors are triggered in the initial web panel, I see that the channel states change to 1
    Quote:

    ClearIO // clear old GPIO/channels
    lfs_format // clear LFS
    StartupCommand "" // clear STARTUP
    stopDriver * // kill drivers
    backlog setPinRole 6 dInput_NoPullUp; setPinChannel 6 2
    backlog setPinRole 7 dInput_NoPullUp; setPinChannel 7 3
    backlog setPinRole 14 Rel; setPinChannel 14 1
    backlog setPinRole 24 LED; setPinChannel 24 1
    backlog setPinRole 26 Btn; setPinChannel 26 1
    Flags 1024


    but I can't make the valve work automatically based on information from the sensors.
    I tried to enter these commands for the test but it doesn't work, there is no reaction to the sensors, although information is updated in the channels and sent to MQTT

    addEventHandler 2 0 SetChannel 1 1
    addEventHandler 3 0 SetChannel 1 0

    can someone tell me how to implement this? and then how can I save this configuration so that it remains working after restarting the device?
  • ADVERTISEMENT
  • Helpful post
    #2 21547010
    p.kaczmarek2
    Moderator Smart Home
    Create autoexec.bat file with a simple loop. Something like:
    
    
    again:
    // assumes those are sensors, both 0, then set 3 to 1 (open water)
    if $CH1==0&&CH2==0 then setChannel 3 1 
    // assumes those are sensors, both 1, then set 3 to 0 (closewater)
    if $CH1==1&&CH2==1 then setChannel 3 0
    
    delay_s 1
    goto again
    
    

    This is a minimal sample. See more samples:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md



    Alternatively get OBK-Berry and write script in berry:
    https://www.elektroda.com/rtvforum/topic4117238.html
    Helpful post? Buy me a coffee.
ADVERTISEMENT