Project 1.12.6
Bluetooth Water Pump Controller
Project 1.12.6: Bluetooth Water Pump Controller
Beginner Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython
Overview
Build a Bluetooth-controlled water pump using a relay and external power.
This project demonstrates safe short-range wireless control of a pump.
The final result should let the phone turn the pump on or off and request the current pump state.
Required Components
![]() Raspberry Pi Pico 2 W |
![]() 1-channel relay module |
![]() Small DC water pump |
![]() External power supply |
![]() Breadboard |
![]() Jumper wires |
![]() Phone with BLE app |
Circuit Connections
| Component Pin | Connects To | Pico GPIO / Physical Pin Number | Notes |
|---|---|---|---|
| Relay VCC | 5V / VSYS | Physical pin 40 | Module power |
| Relay GND | GND | Physical pin 38 | Common ground |
| Relay IN | GPIO 0 | GPIO 0 / physical pin 1 | Usually active-low |
| External pump supply positive | Relay COM | Not a GPIO pin | Pump power input |
| Relay NO | Pump positive terminal | Not a GPIO pin | Power flows when relay is on |
| Pump negative terminal | External pump supply negative | Not a GPIO pin | Return path |
| Diode stripe end | Pump positive terminal | Not a GPIO pin | Across pump terminals |
| Diode other end | Pump negative terminal | Not a GPIO pin | Across pump terminals |
Step-by-Step Assembly
Step 1: Place the Raspberry Pi Pico 2 W
Place the Raspberry Pi Pico 2 W on the breadboard so it sits across the center gap.
Keep the USB port facing outward so you can easily connect it to your computer.

Step 2: Place the Relay Module and Pump
Place the relay module on the breadboard or beside it where the pins are easy to reach.
Keep the pump and external pump supply separate from the Pico wiring.
Identify relay VCC, GND, IN, COM, and NO before wiring.

Step 3: Connect Relay Power
Connect relay VCC to 5V / VSYS.
Connect relay GND to GND.

Step 4: Connect the Relay IN Pin
Connect relay IN to GPIO 0.

Step 5: Wire Pump Power Through the Relay
Connect the external pump supply positive wire to relay COM.
Connect relay NO to the pump positive terminal.
Connect the pump negative terminal to the external pump supply negative wire.

Wiring Check
-
- Pico 2 W is placed correctly across the breadboard center gap
-
- Relay VCC connects to 5V / VSYS
-
- Relay GND connects to GND
-
- Relay IN connects to GPIO 0
-
- External pump supply positive connects to relay COM
-
- Relay NO connects to pump positive terminal
-
- Pump negative terminal connects to external supply negative
-
- Diode stripe end connects to pump positive
-
- Diode non-striped end connects to pump negative
-
- No loose jumper wires
Safety Note
Do not power the pump directly from the Pico. Use only a low-voltage DC pump and keep the Pico, breadboard, USB cable, and jumper wires dry.
Testing Individual Components
Before running the full project, test each part separately. This makes it easier to find wiring or code problems.
Relay Click Test
Check that the relay changes state before using Bluetooth control.
from machine import Pin
import time
relay = Pin(0, Pin.OUT)
relay.value(1)
time.sleep(1)
relay.value(0)
time.sleep(1)
relay.value(1)
Expected test result: You should hear the relay click on and off.
Pump Power Test
Check the pump and external supply separately before the final Bluetooth build.
No code is needed for this test. Briefly connect the pump directly to the correct external supply to confirm it runs.
Expected test result: The pump should run briefly when connected directly to the correct external supply.
BLE Advertising Test
Check that the Pico advertises as a BLE device your phone can see.
import bluetooth
import time
from ble_uart import BLEUART
ble = bluetooth.BLE()
ble.active(True)
uart = BLEUART(ble, name='Pico-Pump')
print('Scan for Pico-Pump in your BLE app')
while True:
time.sleep(1)
Expected test result: Your phone BLE app should find a device named Pico-Pump.
Full Project Code
Upload and run this code after the individual tests work correctly.
from machine import Pin
import bluetooth
import time
from ble_uart import BLEUART
relay = Pin(0, Pin.OUT)
relay.value(1)
ble = bluetooth.BLE()
ble.active(True)
uart = BLEUART(ble, name='Pico-Pump')
def pump_on():
relay.value(0)
def pump_off():
relay.value(1)
def pump_state_text():
return 'ON' if relay.value() == 0 else 'OFF'
def on_rx(data):
command = data.decode('utf-8').strip().lower()
print('Received command:', command)
if command == 'on':
pump_on()
uart.write(b'Pump ON\n')
elif command == 'off':
pump_off()
uart.write(b'Pump OFF\n')
elif command == 'pulse':
pump_on()
time.sleep(2)
pump_off()
uart.write(b'Pump pulse complete\n')
elif command == 'status':
uart.write(('Pump status: ' + pump_state_text() + '\n').encode())
elif command == 'help':
uart.write(b'Commands: on, off, pulse, status, help\n')
else:
uart.write(b'Unknown command. Send help.\n')
uart.on_rx(on_rx)
print('Bluetooth water pump controller ready')
print('Connect with a BLE app and send commands: on, off, pulse, status, help')
while True:
time.sleep(0.1)
How the Code Works
| Code Section | What It Does | Why It Matters |
|---|---|---|
| Active-low relay setup | Starts the pump relay in the OFF state | This keeps the pump from starting unexpectedly |
pump_on() / pump_off() |
Wrap the relay control in clear functions | The code becomes easier to read and safer to update |
pulse command |
Runs the pump for a short 2-second test | This is a safer beginner test than leaving the pump on indefinitely |
| BLE command replies | Send pump state feedback to the phone | The user can confirm what happened after each command |
Expected Result
After running the code, your phone BLE app should find Pico-Pump. Sending on should turn the pump on through the relay. Sending off should turn it off. Sending pulse should run the pump briefly and then stop it. Sending status should report whether the pump is ON or OFF.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| Pump does not run | Relay wiring or external power is wrong | Check the pump supply, relay COM, relay NO, and pump wires |
| Pump never stops after on | The off command was not sent or the relay is wired differently | Use the off command and verify active-low relay behavior |
| Phone cannot find Pico-Pump | BLE libraries are missing or Bluetooth is not active | Check the library files and rerun the advertising test |






