Relay breakout boards

The relay breakout board from Sparky's Widgets is shown below. It will run off of mbed's VU 5V supply and works with any digital output pin. More than one relay may require an external power supply to drive multiple relays coils at the same time due to the limited power available via the USB cable.

/media/uploads/4180_1/swrelayboard.png

Sparky's Widgets Relay Breakout Board

/media/uploads/4180_1/swrbschem.png

Relay board schematic

A transistor driver circuit is used to control the relay coil. The snubber diode backwards across the relay coil absorbs the reverse voltage inductive spike that occurs when turning off the coil (i.e., V=Ldi/dt).

Any digital out pin can be used to control the relay (connects to the control input (CTRL is JP1-2) of the relay driver circuit).

Safety Note on High Voltages

A high voltage power line shorted to a digital logic circuit on a breadboard can blow up an entire computer system, or cause electrocution if touched. For safety, keep the wires for any high voltage and/or high current devices well away from the breadboard and do not touch them when power is on. Even a momentary wire short can blow things ups. An inline fuse and even a GFI breaker is not a bad idea. Long before a standard household AC circuit breaker trips, electronic parts will blow out with a short. Make sure that the bottom side of the PCB does not short out on any metallic surfaces. Breadboard contacts and small jumper wires only handle about one amp. The relay boards typically use screw terminals to attach the larger wires needed for the external device. Just driving the coil of a large relay requires most of the additional current that can be supplied to mbed via the USB cable, so an external DC power supply will likely be needed to power the relay coils and the load of the external device. For electrical isolation, when using a relay to control external AC devices or high voltage DC devices, do not connect the grounds on the power supplies from the control side to the load side.



Here is an example program the turns the relay on and off every 4 seconds.

#include "mbed.h"

DigitalOut myled(LED1);
DigitalOut Ctrl(p8);

int main() {
    while(1) {
        Ctrl = 1;
        myled = 1;
        wait(2);
        Ctrl = 0;
        myled = 0;
        wait(2);
    }
}



Wiring

mbedrelay boardexternal AC or DC load
VU(5v)VCC
GndGnd
P8CTRL
black terminalload 1
black terminalload 2


For the demo, one of the wires in a 2-pin AC extension cord was cut, pulled apart, stripped back, and each end attached to one of the two black screw terminals used for the load. The lamp was them plugged into the extension cord.


The relay board turning a household AC lamp on and off

In the video above running the demo code, the relay turns the lamp on and off every 4 seconds. Note the audible click of the relay, and the indicator LEDs changing, mbed LED1 and the green LED on the relay board. Since a relay contact turns the load on and off, it can be used to switch AC or DC loads as long as the load does not exceed the ratings on the relay contacts (120V 10A or around 1000Watts). For DC, cut the ratings in half.

Sparkfun just updated their relay breakout board. It is basically the same as the Sparky's Widgets board as far as connections needed and the example code.

/media/uploads/4180_1/_scaled_spfnrelaypcb.jpg
Sparkfun Relay Breakout Board

Phidgets makes a similar board with two relays. It can be purchased with an optional case which makes it a bit harder to short out AC lines.

/media/uploads/4180_1/prelaycase.jpg
Phidgets Dual Relay module with the optional case

Drivers, Relays, and Solid State Relays describes some other options and circuits to drive high current and/or high voltage AC and DC devices.


Please log in to post comments.