Arduino relay

An Arduino pin gives only a small current, but household devices need much more. A relay is an electrically controlled switch: a small current magnetises a coil, which closes a powerful circuit.

Wire the relay module correctly (IN, VCC, GND and COM, NO, NC) and switch a 12 V lamp from code. Build a thermostat with hysteresis and a watering system driven by soil moisture.

In this lab

  • how a relay works
  • COM, NO and NC contacts
  • thermostat with hysteresis
  • automatic watering

What you learn

An Arduino pin gives only 20 mA at 5 V, while household devices need much more current and voltage. A relay is an electrically operated switch: a small current magnetises a coil, which closes the contacts of the power circuit. The control and load circuits are separated. The aim is to control real home devices automatically with sensors.

Tasks

  1. Wire the control side (IN, VCC, GND) and load side (COM, NO, NC) of the relay module correctly
  2. Switch a 12 V lamp from an Arduino program
  3. Control a home device with a button, light and temperature
  4. Build a thermostat with hysteresis
  5. Build automatic watering driven by soil moisture

What you can build

  • Automatic street light — On at dusk, off at dawn.
  • Watering system — When the soil dries, the pump waters it.
  • Incubator — Hold 37–38 °C with a lamp heater.
  • Aquarium controller — Light by day, filter pump on a schedule.
  • Garage light — When a car approaches, the garage light stays on for 30 s.
  • Code lock — The right button sequence makes the relay open the lock.

Virtual Lab › Robotics

Related labs

  • Robotics basics
  • Arduino
  • Arduino LED
  • Arduino sensors
  • Arduino servo
  • Arduino thermometer