logo elektroda
logo elektroda
X
logo elektroda

[CB3S/BK7231N] 4/6/8 channel WIFI Smart Garden irrigation controller with TuyaMCU template guided

nkrt 1314 3
ADVERTISEMENT
  • #1 20669393
    nkrt
    Level 2  
    Hello. I bought a Chinese irrigation controller on Aliexpress and wanted to use it with Homeassistant:

    [CB3S/BK7231N] 4/6/8 channel WIFI Smart Garden irrigation controller with TuyaMCU template guided

    It is a 4-channel controller that uses a Chinese ESP32 clone (BK7231N / CB3S PCB) which is tied to the Tuya cloud and unusable without an internet connection, which sucks. Here is a pic of the PCB:

    [CB3S/BK7231N] 4/6/8 channel WIFI Smart Garden irrigation controller with TuyaMCU template guided

    The Beken module communicates via serial to another MCU (aka TuyaMCU, Nation N32G452) via serial. I had to desolder the CB3S module and feed it with external 3.3V to flash openbeken because the TuyaMCU was disturbing the process. The process was easy using hot air, desoldering wire, and a bit of patience.

    After flashing openbeken, I resoldered the CB3S module to the main PCB and booted openbeken successfully. Connected to Wi-Fi using the GUI was easy. I used the TuyaMCU Analyzer (https://github.com/openshwprojects/TuyaMCUAnalyzer) to find the dpids and found that 101-104 were the four outputs.

    Then I loaded the following autoexec.bat to the system:

    
    startDriver TuyaMCU
    startDriver NTP
    ntp_setServer ptbtime1.ptb.de
    ntp_timeZoneOfs 2
    
    linkTuyaMCUOutputToChannel 101 1 1
    linkTuyaMCUOutputToChannel 102 1 2
    linkTuyaMCUOutputToChannel 103 1 3
    linkTuyaMCUOutputToChannel 104 1 4
    
    addChangeHandler Channel1 == 1 addRepeatingEvent 1800 1 setChannel 1 0
    addChangeHandler Channel2 == 1 addRepeatingEvent 1800 1 setChannel 2 0
    addChangeHandler Channel3 == 1 addRepeatingEvent 1800 1 setChannel 3 0
    addChangeHandler Channel4 == 1 addRepeatingEvent 1800 1 setChannel 4 0
    


    The last four rows set the limit for an open valve to 30 min (1800s) in case the MQTT/WiFi connection is lost, so I don't produce inundations.

    Set the channels to toggle type:

    [CB3S/BK7231N] 4/6/8 channel WIFI Smart Garden irrigation controller with TuyaMCU template guided

    And integrate to Openhab via MQTT as seen in the YouTube videos.

    I am very happy with this solution. Big thanks to the Openbeken developers, nice job!
  • ADVERTISEMENT
  • #2 20669568
    p.kaczmarek2
    Moderator Smart Home
    That's something totally new to me, thank you for your presentation! I see you've also used repeating events to automatically stop the valves after given time. That's a good idea. But, btw, have you looked into clock events? They could be used to automatically start a given process at given time.
    [CB3S/BK7231N] 4/6/8 channel WIFI Smart Garden irrigation controller with TuyaMCU template guided
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20669732
    nkrt
    Level 2  

    Thank you for mentioning this! This could be interesting for indoor gardening usage and controller independent setups, but in my case, I want to make the decision if watering is necessary or not depending on the current weather/forecast as I am watering outdoors with it.
    BTW, the documentation of the project is very well done! Good job!
  • #4 20669822
    p.kaczmarek2
    Moderator Smart Home
    Thank you. I personally think that the documentation is in the very early stage and there are a lot of things that could be improved. The current version of docs is basically autogenerated from the code along with some handwritten comments in JSON format. We have a script for generating docs here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/scripts/getcommands.js

    There are, however, some documentation sections that I've written myself. Autoexec examples section is one of them:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Helpful post? Buy me a coffee.
ADVERTISEMENT