PyRaspBeta

Water pump

A water pump moves water from a reservoir into the soil. The shop's part costs $8 and is a world-coupled load: on the board it is a small 5 V stand-in, but in the simulated world it adds water to its zone's soil — the soil moisture a soil sensor reads rises while it runs. That makes it the actuator for irrigation: read the soil through an ADC, switch the pump, and watch the reading recover. It cannot be driven from a GPIO (the stand-in alone draws 100 mA, and real pumps draw far more); it goes behind a relay.

Water pump

Pins

PinWhat it isType
+Supply + (switched through a relay)passive
-Supply −passive
SettingTypeRangeDefault
flowMlPerMinnumber10–2000300
  • Pump() — Water pump — $8
  • Pins: 2
  • Chain ends: + >> pump >> -

The two leads are a supply loop: + takes the switched supply (through the relay's NO contact) and − returns to the supply ground. Wire the relay into the + side, as the relay + pump kit does.

Wiring it in circuit.py

A high-trigger relay switching the pump from the Pi's 5 V rail:

circuit.py
from wiring import *

pi = Pi()

relay = Relay("high")        # IN high = contacts closed
pump = Pump()                # Pump(flowMlPerMin=500) for a faster pump

pi.V5 >> relay.dc_plus
pi.V5 >> relay.com            # switched supply in at COM
relay.no >> pump.plus         # out at NO, into the pump
pump.minus >> relay.dc_minus
relay.dc_minus >> pi.GND
pi.GPIO17 >> relay.signal

Pump takes its flowMlPerMin setting by name (10–2000 ml/min, default 300). It is a world-model number, not something Python can measure.

Driving it in main.py

main.py
from gpiozero import OutputDevice
from time import sleep

water = OutputDevice(17)

while True:
    water.on()
    sleep(5)
    water.off()
    sleep(5)

The program drives the relay; the watering happens in the world. A real irrigation controller reads the soil first — the soil moisture sensor page and the soil + ADC kit are the sensing half.

Electrical notes

  • On the board, every load is a 50 Ω stand-in: 5 V across it draws 100 mA, well past a GPIO's safe 16 mA. The relay's contacts switch it instead.
  • Its effect on the world scales with (V ÷ 5 V)², clamped to 1.5, and below 2 % of full it counts as off.
  • Soil moisture rises by flow ÷ 600 percentage points per second while running: the default 300 ml/min adds 0.5 pp/s, so about 10 ml raises a 1-litre pot by one percentage point. Soil also evaporates, faster in warm air.
  • Running dry is not modelled: the pump waters the zone's soil whether or not a reservoir exists. A real pump would run dry, overheat and burn out.
  • A relay switches a pump on and off only; it is the right actuator for the job.

Simulator vs real hardware

  • The behaviour is the shared load model: a 50 Ω resistor across +/−, a level that follows the supply voltage, and a world effect of flow × level millilitres per minute. While off it reports no load.
  • The pump acts on the zone it is placed in (indoor by default, changeable in the inspector). The indoor zone integrates soil moisture with evaporation and the pump's inflow, so the effect is visible over seconds to minutes — exactly the loop the irrigation objectives test.
  • In the judge, an objective's environment pins the soil sensor's readings (e.g. moisturePct: 50) so checks are repeatable; the load still adds water to the zone for sensors left on their world feed.
  • The canvas shows water dripping while it runs; there is no flow, pressure or reservoir physics behind it.
  • Real pumps are inductive loads: the relay's contacts and wiring carry the kickback, and a real installation wants a fuse and a dry-run cutoff. The simulated one is a low-voltage stand-in.

Going deeper

Further reading