logo elektroda
logo elektroda
X
logo elektroda

Semi-Success: Tuya RainPoint TTP106W Indoor Water Pump/Irrigation with CB3S Module and OpenBeken

alleywayapps 483 7
ADVERTISEMENT
  • Helpful post
    #1 21628388
    alleywayapps
    Level 7  
    Tuya RainPoint Indoor Water Pump (TTP106W) with CB3S Module Successfully Flashed with OpenBeken 1.18.145

    Semi-Success: Tuya RainPoint TTP106W Indoor Water Pump/Irrigation with CB3S Module and OpenBeken
    This thing comes with a bunch of tubes and I connect it to a 20 liter tank for watering while away on vacation. The RainPoint app sucks and I was hoping to configure a better system that could water at the same time every day instead of only X hours from me configuring it at that moment. The problem is if I want it to water at 5 am every 48 hours, I better configure it at 5am. Anyway...we'll see how far I get with that..

    Enclosure is easy to open and I was able to flash it using UART by holding the TX/RX directly on the module with my steady fingers(no soldering!) with thanks to the following:
    https://docs.libretiny.eu/boards/cb3s/#pinout

    Didn't find my device listed in the dropdown, so started to sweat a bit..

    Tried to discover what turns the pump on/off with the GPIO exploration page, but I had no luck getting anything to do anything.

    Sweating more.

    When I set off on this journey, I didn't realize there was a separate MCU that interfaces with the CB3S module. I thought it was odd that the physical button still turned the pump on and off.

    Now I've learned a bit about what the TuyaMCU is and how we need to load the driver and create a autoexec.bat with channel mappings.

    Basically the TuyaMCU controls the pump and is the only controller doing anything when running only on batteries. (when the USB cable is plugged in, the Wifi module is awake and can give commands/program the MCU).

    Fortunately I was able to get some idea of the dpid settings from https://templates.blakadder.com/rainpoint_TTP106W.html and here https://github.com/make-all/tuya-local/blob/m...vices/aubess_rainpoint_irrigation_system.yaml

    They seem to have some slight differences that I haven't worked out yet.

    FYI, the back of my PCB board says "TTP106W Rev12" with a date of 2022.04.22

    I have enabled the following flags: 31, 37, and 51 ( still have to learn what the other various TuyaMCU-specific flags are supposed to do)

    Can switch on the pump from the webpage and see/change some values. Seems like it doesn't populate the value after a restart though...not sure what that's about..
    EDIT: fixed it by using the dpCache and some SetStartValue 2 -1 // set it to last remembered between reboots
    Anyhow, I'm far enough along that I thought I could share my autoexec.bat and await some critique..

    Code: Bash
    Log in, to see the code


    Pump control panel with watering duration and frequency input fields
  • ADVERTISEMENT
  • #2 21628704
    p.kaczmarek2
    Moderator Smart Home
    An interesting device, I haven't seen that yet. So, is it fully functional now? Do you happen to have original firmware firmware backup?

    Regarding configuration - are you using it with Home Assistant? It should be possible to do it with some automation, however... it may be tricky if this device is battery powered and goes to sleep often.

    I would personally consider removing MCU to get full control, but it may be a bit more problematic task.

    Do you have any photos from the inside?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21628887
    alleywayapps
    Level 7  
    Here are some photos of the internals.

    Close-up of a green PCB with a C3S module and various electronic components
    Green PCB with micro USB and power cables connected

    I do have a backup of the original firmware. I think I had tried some of the tools to decipher what was in there and it looked like gloppity-gook in the hex viewer.

    Was able to get it into Home Assistant by connecting to MQTT broker and running the HA discovery and I can indeed run the pump which pumps the configured time.

    One annoying thing is that if I have a "TextField" channel type, then its value does not show up in Home Assistant - any way around that?

    My plan is the following:
    PRIMARY FUNCTION: Keep on WiFi, let HA determine watering schedule based on weather.
    FALLBACK: somehow unplugged on batteries, use sane "defaults" of X seconds watering at the same time every two days.

    I can "reset" the MCU countdown to next watering by modifying the frequency (change to 49 hrs, then back to 48 hrs) and I can do that at the same time (7am) every day, thus constantly shifting the MCU's schedule forward as long as HA can access the device. If we're disconnected for some reason, it will theoretically be tuned to 7am every two days as long as the batteries are good, thus providing a sane watering schedule while on holiday.

    I successfully prototyped running a command "startScript" from MQTT to run a custom .bat file which has the job of setting a "temporary" WateringDurationTime (pump for say 60 or 200 seconds) that I would like to be handed down from Home Assistant maybe as a payload when making the request(??) And at the end of actually running the pump for this very specific amount of time, it would reconfigure the watering duration for the MCU back to sane defaults of watering duration for FALLBACK scenario.

    HOWEVER...I'm discovering that I'm having a hard time saving a configurable "sane default fallback" watering duration. I thought I could default another TextField channel and use setStartValue 22 -1 but this seems not to save between reboots. My other writable channels which are mapped with MCU appear to only save their values because of the "dpCache" flag... any ideas? Seems like there might be a number of ways to store variables.

    What do we think of this plan?
  • #4 21628931
    p.kaczmarek2
    Moderator Smart Home
    I see.. let's start by adding text field to HA discovery. Can you help testing that?
    “Configuration” widget with numbers 2 and 43 and “ADD TO DASHBOARD” link
    Added to main, should be in release soon
    https://github.com/openshwprojects/OpenBK7231...mmit/6ae05de5600b7ad387dafc67c0253e1b58e74296

    Added after 1 [minutes]:

    PS: setStartValue 22 does not work because:
    
    define MAX_RETAIN_CHANNELS 12
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21630066
    alleywayapps
    Level 7  
    Thanks for that hint - I moved from channel 22 to channel 11 and now works as expected.
    Can indeed test the HA Discover in next build.

    It's looking more and more like I can go from Semi-Success to calling this a success. (see atttached movie)



    Connected to MQTT, I can run successfully commands on OpenBeken.
    So basically I can have HA run the pump via an automation that can water for a dynamic number of seconds.
    It calculates a number of seconds based on current weather and forcast.
    Sends signal to OpenBeken to config number of seconds, then runs a custom water-and-reset.bat file
    which will do the watering, then reset the values to the fallback numbers in case of loss of power/wifi

    Can't remember why, but the dpcache flags ended up not working for me.
    In the end, the autoexec.bat script looks like this:


    // Start TuyaMCu driver
    startDriver TuyaMCU
    startDriver NTP
    
    // set TuyaMCU baud rate
    tuyaMcu_setBaudRate 9600
    // set TuyaMCU default wifi state 0x04, which means "paired",
    // because some TuyaMCU MCUs will not report all data
    // unless they think they are connected to cloud
    tuyaMcu_defWiFiState 4
    
    
    // Borrowed from:
    // https://templates.blakadder.com/rainpoint_TTP106W.html
    // https://github.com/make-all/tuya-local/blob/main/custom_components/tuya_local/devices/aubess_rainpoint_irrigation_system.yaml
    // search "TTP106W" on google for the board
    
    // 1 == pump power on/off
    setChannelType 1 Toggle
    setChannelLabel 1 "Pump Mode"
    linkTuyaMCUOutputToChannel 1 bool 1
    
    // 2 == watering duration (6..1800 seconds)
    setChannelType 2 TextField
    setChannelLabel 2 "Watering Duration Seconds"
    linkTuyaMCUOutputToChannel 102 val 2
    SetStartValue 2 -1 // set it to last remembered between reboots
    
    // 11 == FALLBACK watering duration (6..1800 seconds)
    setChannelType 11 TextField
    setChannelLabel 11 "FALLBACKWateringDuration"
    setStartValue 11 -1
    if $CH11==0 then setChannel 11 100
    
    
    // 3 == watering frequency (1..168 hours)
    setChannelType 3 TextField
    setChannelLabel 3 "Watering Frequency (hours)"
    linkTuyaMCUOutputToChannel 103 val 3
    SetStartValue 3 -1 // set it to last remembered between reboots
    
    // 4 == remaining watering time
    setChannelType 4 readonly
    linkTuyaMCUOutputToChannel 104 2 4
    setChannelLabel 4 "Remaining watering time (seconds)"
    
    // 5 == error report (0x00 = no error; 0x01 = no water) but it doesn’t seem to work correctly
    
    // 6 == operation status: 2 - manual; 1 - auto; 0 - idle
    setChannelType 6 readonly 
    linkTuyaMCUOutputToChannel 106 2 6
    setChannelLabel 6 "Operation Status" // 2 - manual; 1 - auto; 0 - idle CONFLICT WITH
    
    // 7 == next watering event in minutes
    setChannelType 7 ReadOnly
    linkTuyaMCUOutputToChannel 107 2 7
    setChannelLabel 7 "Next Watering Event (in minutes)"
    
    // 8 == power status: (1 - battery high; 2 - medium; 3 - low; 4 - USB port)
    setChannelType 8 readonly  
    linkTuyaMCUOutputToChannel 108 2 8
    setChannelLabel 8 "Power Status"
    
    // 9 == watering autorun on/off
    // DISABLE ! AutoRun stupidly starts watering every time you change the frequency (103)
    // setChannelType 9 Toggle
    // setChannelLabel 9 "Autorun"
    // linkTuyaMCUOutputToChannel 109 bool 9
    
    // Just really make sure to disable autorun
    tuyaMcu_sendState 109 bool 0
    
    waitFor MQTTState 1
    // addRepeatingEvent [IntervalSeconds][RepeatsOr-1][CommandToRun]
    addRepeatingEvent 5 -1 publishAll
    addRepeatingEvent 5 -1 tuyaMcu_sendQueryState  // For TuyaMCU devices
    
    
    And my [b]water-and-reset.bat[/b] file looks like this:
    
    
    // This file is in charge of running the pump and resetting the countdown timer
    // on the MCU when running on batteries without USB and WiFi
    
    // This .bat file can be tested with
    // http://      /cm?cmnd=backlog%20setChannel%202%207;%20startScript%20water-and-reset.bat
    
    // In practice, publish command in MQTT
    
    // We have to change the watering freq (ch3) to reset the MCU's internal countdown clock
    // that works when only on batteries. This is a safeguard for loss of USB power or WiFi Down.
    
    // A workaround for resetting MCU's internal countdown is to modify the watering frequency
    //  existing (48) -> 49 -> 48 again will reset ch7 (dpid 107) to 2880 (60 min x 48 hrs)
    delay_s 1
    setChannel 3 49
    delay_s 1
    publishChannel 3
    
    setChannel 3 48
    delay_s 1
    publishChannel 3
    
    // Run the pump
    setChannel 1 1
    publishAll
    delay_s 1
    
    // Return watering duration to FALLBACK watering duration stored in ch11
    
    setChannel 2 $CH11
    
    delay_s 1
    publishAll
  • ADVERTISEMENT
  • #8 21647519
    alleywayapps
    Level 7  
    For anyone looking to riff off my AI-generated algorithm that uses forecast max temp, cloud cover, precipitation probability, avg humidity, and wind to determine the number of seconds to water...

    Please check out the following gist:

    https://gist.github.com/mlake/e6175469541bc0ecadfb681172bd9ad6

    Requires a free AccuWeather API key

Topic summary

The Tuya RainPoint Indoor Water Pump (model TTP106W) equipped with a CB3S module was successfully flashed with OpenBeken firmware version 1.18.145 using UART without soldering. The device is used for automated irrigation from a 20-liter tank, aiming to improve scheduling beyond the limitations of the original RainPoint app, which only allows watering intervals based on the current time of configuration. Integration with Home Assistant was achieved via MQTT and HA discovery, enabling remote pump control. However, challenges remain with displaying "TextField" channel types in Home Assistant, which is being addressed by adding support in the OpenBK7231T_App firmware. The user plans to maintain WiFi connectivity for dynamic watering schedules based on weather data, with a fallback to battery-powered default watering intervals. Internal photos were shared, and a backup of the original firmware was obtained. Suggestions included potentially removing the MCU for full control, though this is more complex. Firmware development and testing continue to enhance device functionality and integration.
Summary generated by the language model.
ADVERTISEMENT