Arduino UNO Q - Water/Liquid Valve
A water/liquid solenoid valve controls the flow of water, oil, or other liquids. It opens when 12V is applied and closes when power is removed. Arduino UNO Q controls it through a relay. With Bridge and Telegram, you can open and close the valve remotely from anywhere.
In this tutorial, you will learn:
- What a water/liquid solenoid valve is and how it works
- How to wire the valve and relay to the Arduino UNO Q MCU
- How to program the MCU to open and close the valve
- How to use Bridge to control the valve from the Linux side (Python)
- How to open and close the valve remotely via Telegram on Arduino UNO Q
- How to use OpenClaw on Arduino UNO Q with the water valve

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of the Water/Liquid Valve
Pinout
A solenoid valve has two wire connections:
- Positive (+) red wire: Connect to 12V DC through the relay
- Negative (-) black wire: Connect to GND of the 12V DC power supply

How It Works
- When 12V is applied → the solenoid opens → liquid can flow
- When power is removed → the solenoid closes → liquid flow stops
※ NOTE THAT:
Some valves require a minimum fluid pressure to open fully after applying 12V. Also, some valves are directional — check the flow arrow on the body. The valve must NEVER be connected directly to an Arduino UNO Q pin. Always use a relay to switch the 12V supply.
How to Control the Valve
The Arduino UNO Q MCU controls a relay, which switches the 12V supply to the solenoid valve:
- Relay pin HIGH → relay closes → 12V to valve → valve OPEN
- Relay pin LOW → relay opens → no power to valve → valve CLOSED
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Connect the relay module IN pin to MCU pin D3. Connect the relay's COM and NO terminals between the 12V supply and the solenoid valve. Connect the relay's VCC to 5V and GND to GND.
| Relay Pin | Arduino UNO Q MCU |
|---|---|
| GND | GND |
| VCC | 5V |
| IN | D3 |
How To Program For Water Valve
- Set up the relay pin as output:
- Open and close the valve:
Arduino UNO Q Code
The Arduino UNO Q has two processors working together:
- The STM32 MCU controls the relay that switches 12V power to the solenoid valve
- The Qualcomm MPU runs Debian Linux and handles Wi-Fi, Python, and cloud connectivity
- In this section, only the MCU is programmed — the Linux side stays idle. A later section shows how both processors work together via Bridge.
This code opens the valve for 5 seconds, then closes it — repeating continuously.
Detailed Instructions
First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.
- Connect: Wire the solenoid valve, relay, and 12V power supply to the Arduino UNO Q MCU as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q.
- Create a new App: Click the Create New App button.

- Give the App a name, for example: WaterValve
- Click Create to confirm.

- Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino. Keep other files as default.
- No library required — uses only the built-in digitalWrite() function.
- Upload: Click the Run button in Arduino App Lab.

- Observe the valve alternating between open and closed every 5 seconds. You can hear the click of the solenoid engaging.
App Lab Console Output
Bridge: Linux + MCU
This section shows how to program both processors of the Arduino UNO Q so the Linux side can open and close the valve via Bridge:
- The solenoid valve is connected to the MCU via relay — the MCU controls the relay output pin
- The MPU cannot control the relay directly — it calls Bridge functions to open or close the valve
- The MPU has Wi-Fi — running full Debian Linux, it can accept commands from Telegram or any web service and translate them into valve control actions
- Arduino_RouterBridge enables RPC communication between the two processors
- ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code
In short: MPU receives open/close commands → calls Bridge → MCU controls relay → valve actuates.
MCU Code (Bridge)
Python Code (Bridge)
Detailed Instructions
- Connect: Wire the solenoid valve, relay, and 12V power supply to the Arduino UNO Q as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait for the board to be detected.
- Create a new App: Click Create New App, name it WaterValveBridge, then click Create.
- Paste the MCU sketch: Copy the MCU Bridge code above and paste it into sketch/sketch.ino.
- Paste the Python code: Copy the Python Bridge code above and paste it into the Python file in the App.
- Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.

- Search for Arduino_RouterBridge created by Arduino and click the Install button.
- Upload: Click the Run button in Arduino App Lab.

- Watch the valve cycle: open → wait 5 seconds → close → wait 1 second → repeat.
App Lab Console Output
Telegram
Control the water/liquid valve remotely via Telegram — open and close from anywhere with a simple command.
MCU sketch: Keep the same MCU sketch from the previous Bridge section.
Python Code (Telegram)
Detailed Instructions
- Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
- Replace YOUR_CHAT_ID with your Telegram chat ID.
- Paste this Python code into your App's Python file (keep the same MCU sketch).
- Click the Run button. Send /open from Telegram to start the flow, then /close to stop it.
App Lab Console Output
ArduinoBot
OpenClaw
...OPENCLAW
OpenClaw support for Arduino UNO Q Water/Liquid Valve is coming soon.
...OPENCLAW
Project Ideas
You can build many useful projects with the solenoid valve and Arduino UNO Q:
- Remote Irrigation System: Control garden watering from anywhere via Telegram — send /open to start irrigation and /close to stop, with the Linux side logging each session's duration to a file
- Time-Based Watering: Program the MPU to automatically open the valve for 10 minutes every morning at 6 AM using the Linux system clock — no manual intervention needed
- Water Leak Response: Combine a water sensor with the valve — when the sensor detects a leak, Python immediately calls Bridge.call("close_valve") to stop the water supply and sends a Telegram alert
- Fish Tank Auto-Top-Up: Use a water level sensor in a fish tank — when the level drops below a threshold, Python opens the valve for 30 seconds to add water, then closes it and sends a Telegram confirmation
- Beer/Juice Dispenser: Control a food-safe solenoid valve connected to a liquid reservoir — /open dispenses liquid and /close stops it, with a timer to prevent over-pouring
Challenge Yourself
Ready to go further with the water valve on Arduino UNO Q? Try these challenges:
- Easy: Add a /open_10s Telegram command that opens the valve for exactly 10 seconds using time.sleep(10) on the Python side before calling Bridge.call("close_valve").
- Medium: Implement a daily irrigation schedule: Python reads a schedule file (e.g., schedule.json with open/close times) and automatically controls the valve based on the Linux system clock — send a Telegram notification when each session starts and ends.
- Advanced: Build a flow-time logger: every time the valve is opened via Telegram or automatically, Python records the start time, close time, and duration to a CSV file — implement a /log Telegram command that returns the last 5 irrigation sessions.