Arduino UNO Q - Control Pump

A 12V pump can move water, oil, or other liquids and is commonly used in irrigation systems, aquariums, and water refilling stations. Arduino UNO Q controls the pump through a relay. With Bridge and Telegram, you can turn the pump on or off remotely from anywhere.

In this tutorial, you will learn:

Arduino UNO Q Pump

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×12V Pump
1×Vinyl Tube
1×Relay
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Sensors/Servo Expansion Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of the 12V Pump

Pinout

A 12V pump typically 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
Pump Pinout

How to Control the Pump

A 12V pump requires a 12V power supply — it must NEVER be connected directly to an Arduino UNO Q pin. A relay is used as the interface. The MCU controls the relay, which switches the 12V supply to the pump:

  • Relay pin HIGH → relay closes → 12V to pump → pump ON
  • Relay pin LOW → relay opens → no power to pump → pump OFF

Wiring Diagram

The wiring diagram between Arduino UNO Q Pump

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 pump. 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 Pump

  • Set up the relay pin as output:
pinMode(RELAY_PIN, OUTPUT);
  • Turn pump on and off:
digitalWrite(RELAY_PIN, HIGH); // pump ON delay(5000); digitalWrite(RELAY_PIN, LOW); // pump OFF delay(5000);

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 pump
  • 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 turns the pump on for 5 seconds, then off for 5 seconds — repeating continuously.

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump // This code turns the pump ON for 5 seconds and OFF for 5 seconds repeatedly. // The pump requires a 12V power supply and is controlled through a relay. #define RELAY_PIN 3 // The Arduino UNO Q MCU pin connected to the relay IN pin void setup() { Serial.begin(9600); pinMode(RELAY_PIN, OUTPUT); Serial.println("Arduino UNO Q Pump ready"); } void loop() { Serial.println("Pump: ON"); digitalWrite(RELAY_PIN, HIGH); // turn pump ON delay(5000); Serial.println("Pump: OFF"); digitalWrite(RELAY_PIN, LOW); // turn pump OFF delay(5000); }

Detailed Instructions

First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.

  • Connect: Wire the pump, relay, and 12V power supply to the Arduino UNO Q MCU as shown in the wiring diagram. Attach vinyl tubing to the pump inlet/outlet.
  • 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.
Create New App in Arduino App Lab on Arduino UNO Q
  • Give the App a name, for example: Pump
  • Click Create to confirm.
Arduino App Lab App folders and files on Arduino UNO Q
  • 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.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Observe the pump turning on and off every 5 seconds.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Pump ready [2026-04-29 09:00:01] Pump: ON [2026-04-29 09:00:06] Pump: OFF [2026-04-29 09:00:11] Pump: ON [2026-04-29 09:00:16] Pump: OFF

Bridge: Linux + MCU

This section shows how to program both processors of the Arduino UNO Q so the Linux side can turn the pump on and off via Bridge:

  • The pump 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 turn the pump on or off
  • The MPU has Wi-Fi — running full Debian Linux, it can accept commands from Telegram or any service and translate them into pump 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 sends on/off commands → calls Bridge → MCU controls relay → pump activates.

MCU Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump #include "Arduino_RouterBridge.h" #define RELAY_PIN 3 // The Arduino UNO Q MCU pin connected to the relay IN pin bool is_on = false; String pump_on(String arg) { digitalWrite(RELAY_PIN, HIGH); is_on = true; Monitor.println("Pump: ON"); return "on"; } String pump_off(String arg) { digitalWrite(RELAY_PIN, LOW); is_on = false; Monitor.println("Pump: OFF"); return "off"; } String get_state(String arg) { return is_on ? "on" : "off"; } void setup() { Bridge.begin(); Monitor.begin(); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, LOW); // start with pump off is_on = false; Bridge.provide_safe("pump_on", pump_on); Bridge.provide_safe("pump_off", pump_off); Bridge.provide("get_state", get_state); Monitor.println("Arduino UNO Q Pump Bridge ready"); Monitor.println("Initial state: OFF"); } void loop() {}

Python Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump from arduino.app_utils import * import time def loop(): state = Bridge.call("get_state") print(f"Pump state: {state}") # Example: run pump for 5 seconds, then stop if state == "off": print("Starting pump...") Bridge.call("pump_on") time.sleep(5) print("Stopping pump...") Bridge.call("pump_off") time.sleep(1) App.run(user_loop=loop)

Detailed Instructions

  • Connect: Wire the pump, 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 PumpBridge, 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.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for Arduino_RouterBridge created by Arduino and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Arduino_RouterBridge Arduino

This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

0.4.1
Install
More Info
  • Upload: Click the Run button in Arduino App Lab.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Watch the pump cycle: on → wait 5 seconds → off → wait 1 second → repeat.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Pump Bridge ready [2026-04-29 09:00:01] Initial state: OFF [2026-04-29 09:00:02] Pump: ON [2026-04-29 09:00:07] Pump: OFF
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:02] Pump state: off [2026-04-29 09:00:02] Starting pump... [2026-04-29 09:00:07] Stopping pump... [2026-04-29 09:00:08] Pump state: off

Telegram

Control the pump remotely via Telegram — turn it on or off from anywhere with a simple command.

MCU sketch: Keep the same MCU sketch from the previous Bridge section.

Python Code (Telegram)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-controls-pump from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q Pump Bot\n" "/on - Turn the pump ON\n" "/off - Turn the pump OFF\n" "/state - Read current pump state") elif text == "/on": result = Bridge.call("pump_on") send_message(chat_id, f"💧 Pump state: {result}") elif text == "/off": result = Bridge.call("pump_off") send_message(chat_id, f"🔴 Pump state: {result}") elif text == "/state": result = Bridge.call("get_state") send_message(chat_id, f"Pump state: {result}") else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(1) App.run(user_loop=loop)

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 /on from Telegram to start the pump, then /off to stop it.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:10:00] Waiting for Telegram messages... [2026-04-29 09:10:05] Received: /on [2026-04-29 09:10:12] Received: /state [2026-04-29 09:10:20] Received: /off
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/state
10:15 AM ✓✓
Pump state: off
10:16 AM
/on
10:17 AM ✓✓
💧 Pump state: on
10:18 AM
/state
10:19 AM ✓✓
Pump state: on
10:20 AM
/off
10:21 AM ✓✓
🔴 Pump state: off
10:22 AM

OpenClaw

...OPENCLAW

OpenClaw support for Arduino UNO Q Controls Pump is coming soon.

...OPENCLAW

Project Ideas

You can build many useful projects with the pump and Arduino UNO Q:

  • Remote Irrigation System: Start and stop garden watering from anywhere via Telegram — the Linux side logs each pumping session with start time and duration to a CSV file
  • Automatic Plant Watering: Program the MPU to run the pump every morning for 5 minutes using the Linux system clock — no manual intervention required
  • Flood Response: Pair with a water sensor — when the sensor detects a rising water level, the pump automatically switches on via Bridge to drain the water and sends a Telegram alert
  • Aquarium Auto Top-Up: Monitor the water level with a sensor — when it drops below the minimum, Python activates the pump for 30 seconds to refill and sends a Telegram notification
  • Water Refill Station: Build a coin-operated or timer-controlled water dispenser — /on starts the pump and a 30-second Python timer stops it automatically, preventing overflow

Challenge Yourself

Ready to go further with the pump on Arduino UNO Q? Try these challenges:

  • Easy: Add a /on_10s Telegram command that turns the pump on for exactly 10 seconds using time.sleep(10) on the Python side before calling Bridge.call("pump_off").
  • Medium: Implement a daily watering schedule: Python reads a JSON file containing ON/OFF times and controls the pump automatically — send a Telegram notification when each pumping session starts and finishes.
  • Advanced: Build a flow logger: every pump ON session is logged to a CSV file with start timestamp, stop timestamp, and duration — implement a /log Telegram command that returns a summary of the last 5 sessions.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!