PyRaspBeta

Relay + lamp

The relay + lamp kit is a high-trigger relay module with a lamp wired through its contacts, both fed from the same 5 V supply. It costs $13 and is for switching light: a night light that is actually bright, a timed lamp, or a light source for the light sensor in its zone. Wire vcc to 5 V, gnd to ground and sig to a GPIO — sig high lights the lamp.

What's inside

PartQtyPrice each
Relay module1$4
Lamp1$5
Total2$9
  • The relay module switches the lamp's current; its coil takes ~72 mA from the 5 V rail and its contacts carry the load, so the GPIO stays safe.
  • The lamp is the load; in the simulator it lights its zone, and light sensors there read it on top of daylight.
Exposed pinInside the kit
vccrelay:DC+
gndrelay:DC-
sigrelay:IN

vcc feeds the relay coil and the switched loop (DC+ → COM → NO → lamp+ → lamp− → DC−), so it must be 5 V. sig is high-trigger: a high GPIO closes the contacts. The kit has no chain ends.

Wiring it in circuit.py

circuit.py
from wiring import *

pi = Pi()
lamp = kits.RelayLamp()

pi.V5 >> lamp.vcc        # relay coil and switched supply are both 5 V
lamp.gnd >> pi.GND
pi.GPIO17 >> lamp.sig    # high = light on

Driving it in main.py

main.py
from gpiozero import OutputDevice
from time import sleep

lamp = OutputDevice(17, active_high=True, initial_value=False)

while True:
    lamp.on()
    sleep(1)
    lamp.off()
    sleep(1)

Why buy the kit

Loose parts cost $4 + $5 = $9.00, against $13 — $4.00 for the switched loop assembled. The same job by hand is a relay, a lamp and four wires with one easy mistake (COM and NC swapped, leaving the lamp on in reverse); the kit wires COM to the supply and NO to the lamp for you. The relays primer has the full picture.

Simulator vs real hardware

  • Contacts close about 10 ms after sig goes high and open about 5 ms after it falls, so a blink pattern still comes out with the lamp's own small delay.
  • On the board the lamp is a 5 V, 100 mA stand-in; in its zone it adds the lux set by the inspector, scaled by (V ÷ 5 V)², so a light sensor in the same room sees it — useful for testing a night-light loop.
  • The relay gives on/off only; for dimming use a PWM-capable output device instead.

Further reading

  • gpiozero: OutputDevice — the plain digital output used to drive a relay input, with active_high for low-trigger modules.