logo elektroda
logo elektroda
X
logo elektroda

[WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification

paulp 3279 6
ADVERTISEMENT
  • #1 20478087
    paulp
    Level 6  
    Basic Information:
    Brand: UJV
    Model: Ufairy
    Chip: WB3S
    Vendor: Amazon(bought in January 2023 for about $25)
    [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification
    This device is very similar to the one described here. However there are some differences that I want to allude to.
    the usual disclaimer: electricity kills (some), always remove power, tear down at your own risk, etc.


    Teardown photos
    The housing comes off easily, I just had to undo 4 screws. The inside looks quite neat
    [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification
    The valve's brain is a WB3S module. So I decided to program it using a UART programmer. I connected the RX, TX, VCC, GND pins as usual. The peculiarity is that the CEN pin is permanently soldered to GND, so I had to cut the trace. Not sure if it needed, b/c I ended up not using the CEN at all. I used the BK7231 GUI Flash Tool from here and the OpenBK7231T_UA_1.15.450.bin firmware. At first I could not connect to module using the procedure described, shortening the CEN pin did noting but rebooted the UART adapter. This is why i attempted to cut the trace. This didn't help either (maybe), so I ended up removing and reconnecting back VCC. After a few attempts the module connected and everything went fine.
    Pin Definitions
    Pin definitions are different from the ones here
    P14-> Rel
    P24->LED
    P26->Btn

    Improvements (Verschlimmbesserungen)
    Since this valve is planned to be used in a critical application - namely be the main shut off valve in my conservatory (not the musical one, the one with plants), I decided I need to monitor its status. Conveniently there are many unused GPIOs on the module and two limit switches.
    [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification
    Inconveniently the switches are driven by 12V, so I made a resistive divider. You'd need to come down from 12V to 3V, so R1=3*R2. I had a 30k SMD and a 10k trough-hole laying around, so that's what I used.
    [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification [WB3S/BK7231T] Tuya Smart Valve (UJV Ufairy) teardown and modification
    The 30k resistor is connected to the NO contact of the respective limit switch. After soldering verify that the total resistance between NO and GND is whatever you designed (40k in my case), and between NO and GPIO - 3/4 of that. Then I configured the corresponding GPIOs (I used PWM2 and PWM1) as inputs.
    But there come some troubles, maybe pan Kaczmarek can help: the module doesn't seem to poll the state of the inputs while the relay pin is active. So I would expect the input states to be 1/0 when closed, 0/0 when moving, 0/1 when open. Instead I see that then opening the valve, "open" activates the moment "closed" deactivates and stays so while the actuator is moving and in the open state. When moving to the closed state "open" deactivates right away, both inputs stay low while moving and "closed" activates when the valve is closed.
  • ADVERTISEMENT
  • #2 20478539
    p.kaczmarek2
    Moderator Smart Home
    Thank you, we haven't seen much valves yet on our forum. Maybe only that one so far:
    [BK7231T][WB3S] Tuya Smart Valve Controller (water switch)

    Regarding the issue:
    paulp wrote:

    The 30k resistor is connected to the NO contact of the respective limit switch. After soldering verify that the total resistance between NO and GND is whatever you designed (40k in my case), and between NO and GPIO - 3/4 of that. Then I configured the corresponding GPIOs (I used PWM2 and PWM1) as inputs.

    Which exact GPIO role was used and did you make sure to assign different channel than the one used for Relay?

    paulp wrote:

    But there come some troubles, maybe pan Kaczmarek can help: the module doesn't seem to poll the state of the inputs while the relay pin is active.

    I'd say it's impossible because I know the pins logic code and I know that dInput role (if you used that) is polled continuously. On the firmware side, there is nothing like "disable inputs when relay is on".

    But, I'd say, that dInput has pull up resistor in MCU, which messes things, maybe you need dInput_noPup.

    paulp wrote:

    So I would expect the input states to be 1/0 when closed, 0/0 when moving, 0/1 when open. Instead I see that then opening the valve, "open" activates the moment "closed" deactivates and stays so while the actuator is moving and in the open state. When moving to the closed state "open" deactivates right away, both inputs stay low while moving and "closed" activates when the valve is closed.

    I am not sure about that part yet. Please answer first my other questions and we'll think about it.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20478712
    paulp
    Level 6  
    p.kaczmarek2 wrote:
    Which exact GPIO role was used and did you make sure to assign a different channel than the one used for Relay?

    I tried both dInput and dInput_NoPullUp - the effect is the same. This is my final configuration
    
      "pins": {
        "7": "dInput_NoPullUp;1",
        "8": "dInput_NoPullUp;2",
        "14": "Rel;0",
        "24": "LED;0",
        "26": "Btn;0"
      }

    It still behaves as described. The "open" switch goes high right when the arm begins to move towards the open position, and remains high in the open position. When moving toward the closed position the "open" input goes low. It does indeed mimic the state of the Rel pin (or rather its representation in Home Assistant). But I guess I'm not very familiar with the concept of channels to understand the source of this cross-talk.
    I hope this helps to troubleshoot it further.
  • ADVERTISEMENT
  • #4 20480171
    p.kaczmarek2
    Moderator Smart Home
    The config you have posted has no cross-talk at all. If that's all you have, and you also don't have any custom scripts in autoexec.bat (like scripts setting one channel when other changes), then I am confident that it's impossible to have, as you said, cross-talk between channels at the firmware level.

    Please try again and/or explain the issue again, maybe we can figure something out.

    As I said, in case of your current config, the channels 1 and 2 are only affected by their respective Digital Inputs and Relay state does not affect them.

    qq wrote:

    the module doesn't seem to poll the state of the inputs while the relay pin is active.

    Let's try to somehow double-check this observation. I don't know, if you feel confident enough with soldering iron and stuff, you could manually, temporary, connect a dinput pin with a resistor to GND and observe if it changes in case of Relay pin active and inactive. Do some tests, observe, check if it's really the case, because I think something else is at play here.
    Helpful post? Buy me a coffee.
  • #5 21151554
    nunonevespereira
    Level 2  
    THIS IS WRONG - don't do it -> "Maybe your valve actuator is different from mine, but you should have just connected the NO to the gpio directly and use a pullup type of input configuration. To explain my reasoning: NO isn't connected to anything on the board. When the limit switch gets triggered, it is connected to ground, so it never has 12v on it. It either isn't connected or is connected to ground. By using a direct connection to the gpio with pullup configured, the gpio is either 1 when the switch isn't triggered or 0 when it is triggered. It will probably solve your problem..."
  • ADVERTISEMENT
  • #6 21151679
    p.kaczmarek2
    Moderator Smart Home
    Yes, if NO contact (normally open) is either not connected or shorted to ground, then you need a GPIO with internall pull up resistor in order to read correctly the GPIO state.
    Helpful post? Buy me a coffee.
  • #7 21151708
    nunonevespereira
    Level 2  
    WRONG -> don't do it - 'That's what I said - "gpio with pull-up configured" and no resistors... ;)'

Topic summary

The discussion revolves around the teardown and modification of the UJV Ufairy smart valve, which utilizes the WB3S chip. The user details their experience with the device, including the ease of disassembly and the internal configuration. They attempt to program the WB3S module using a UART programmer but encounter issues with GPIO channel cross-talk, particularly between digital inputs and relay states. Various responses address the configuration of GPIO pins, suggesting the use of pull-up resistors for accurate state reading. The conversation highlights troubleshooting steps and clarifications regarding the wiring and programming of the valve's components.
Summary generated by the language model.
ADVERTISEMENT