Heater
A heater is a resistor that turns electricity into warmth. The shop sells one for $10, and it is a world-coupled load: on the board it is a small 5 V stand-in, but in the simulated world it warms the room it is placed in using its rated power (1000 W by default). That makes it the actuator for thermostats, greenhouses and incubators — read a temperature sensor, switch the heater, and the temperature actually responds. It cannot be driven from a GPIO: the stand-in alone draws 100 mA, and the thing it represents is kilowatts. It goes behind a relay.
Pins
| Pin | What it is | Type |
|---|---|---|
| + | Supply + (switched through a relay) | passive |
| - | Supply − | passive |
| Setting | Type | Range | Default |
|---|---|---|---|
powerW | number | 50–3000 | 1000 |
Heater()— Heater — $10- Pins: 2
- Chain ends:
+ >> heater >> -
The two leads are a supply loop: + takes the switched supply (through the relay's NO contact) and − returns to the supply ground. The part is not polarised in the model, but wiring the relay into the + side is the convention — and how the relay + heater kit is wired.
Wiring it in circuit.py
A high-trigger relay switching the heater from the Pi's 5 V rail:
from wiring import *
pi = Pi()
relay = Relay("high") # IN high = contacts closed
heater = Heater() # Heater(powerW=2000) for a 2 kW unit
pi.V5 >> relay.dc_plus
pi.V5 >> relay.com # switched supply in at COM
relay.no >> heater.plus # out at NO, into the heater
heater.minus >> relay.dc_minus
relay.dc_minus >> pi.GND
pi.GPIO17 >> relay.signalHeater takes its powerW setting by name (50–3000 W, default 1000) — it is the number the world model uses, not something the board can measure.
Driving it in main.py
from gpiozero import OutputDevice
from time import sleep
heat = OutputDevice(17)
while True:
heat.on()
sleep(5)
heat.off()
sleep(5)Nothing about the heater is visible to Python — the program drives the relay's GPIO, and the world does the rest. In a real thermostat you would compare a sensor reading first; the thermostat recipe and the DHT22 page show that loop.
Electrical notes
- On the board, every load is a 50 Ω stand-in: 5 V across it draws 100 mA. That is already six times a GPIO's safe 16 mA, which is why the relay's contacts switch it, not a pin.
- Its effect on the world scales with
(V ÷ 5 V)², clamped to 1.5, and below 2 % of full it counts as off. Fed the full 5 V through the relay, the rated power is what enters the room. - Rated power is 50–3000 W (default 1000 W). A 1 kW heater raises a small room by a few degrees per hour; the room loses heat to the outdoors as it warms, so the curve flattens rather than climbing forever.
- A relay switches a heater on and off only. If you want proportional heat, you would need a different actuator — the shop does not model one.
Simulator vs real hardware
- The behaviour is the shared load model: a 50 Ω resistor across
+/−whose level follows the supply, and whose world effect israted power × level. While it is off (or below 2 % of full) it reports no load at all. - The heater acts on the zone it is placed in —
indoorby default, changeable in the inspector. Indoor zones model a room as a heat capacity (2.5 MJ/K) leaking to the outdoors through the walls (τ ≈ 4 h), plus heat from people and appliances. The heater's watts enter that balance directly, so a temperature sensor reading its zone — a DHT22 or DS18B20 on its world feed — sees the rise. - In the judge, an objective's
environmentplaces its sensors with pinned readings so the checks are repeatable; the load still acts on the zone, but a sensor whose reading is pinned does not respond to it. - There is no thermal mass, glow or fan noise in the model while it runs;
spins: falsein its behaviour means the canvas only shows the element glow. - Real heaters have thermostats, fuses and mains wiring. The simulated one is a low-voltage stand-in: treat the relay lesson (switch the load, never the GPIO) as what carries over.
Going deeper
- The switch that makes it safe: relay module and the primer relays and switching loads.
- Kit: relay + heater.
- Recipe: thermostat with a relay.
- Sibling loads: fan moves air, pump waters soil, lamp adds light.
Further reading
- gpiozero: OutputDevice — the class the relay is driven with.
- Raspberry Pi 4 datasheet — why a pin is a signal, not a power supply.
- Adafruit: Power Relay FeatherWing pinouts — switching a load through COM/NO.