26. Intro to relays

Background

A relay is an electromagnetic switch that operates on the principle of electromagnetic induction.

Project 1 – Hello World

The relay will toggle, illuminating an LED every other second.

However, it’s not any LED. It’s a 12V, 360mA LED commonly found in automobiles.

Hardware Connections

The purpose of the ULN2803 is to increase the IO pin current to sufficiently drive the coil of the relay plus it has other protection features. Inside the ULN2803 are 8 Darlington transistor configurations. This is more than sufficient.

The ULN2803 contains 8 Darlington transistor pairs. Here’s what one of them looks like.

I created a custom schematic symbol for the SPST relay. Feel free to roast me on it.

The schematic is available at my GitHub repository.

Circuit prototyped on a breadboard

Software

The full source code is available in my GitHub repository.

Showcase

Project 2 – Sentinel – A Relay Controller

Toggling a load is good and all but what if we want specific behaviours? Let’s expand on the original by adding 3 modes of operation:

  1. Latching (thereby preserving a specific state)
  2. Disabling the relay
  3. Manual

A debounced push button lets a user select the mode. A short press toggles AUTO/MANUAL, long press forces the relay off (lockout).

Hardware Connections

The schematic is available at my GitHub repository.

The Software

Full source code is located in my GitHub repository.

The Showcase