Using an Arduino Relay Module with Raspberry Pi or Netduino

Tags: netduino, raspberry-pi, maker, electronics, relay, schematic

These relay modules are commonly available on sites such as eBay and are generally marketed as Arduino compatible. However, I wanted to use the module with my Netduino and my Raspberry Pi 2. The module is designed to work at 5 volts, but both the Netduino and Raspberry Pi are fundamentally 3.3 volt systems. Netduino is mostly 5 volt tolerant but Raspberry Pi is not, so some care is needed.

I couldn't find a circuit schematic anywhere so I have reverse-engineered my module by inspection. Here's what I think the circuit is:

You should verify this yourself rather than relying on my guesstimate because I might have made mistakes and I won't be responsible for you blowing up your stuff. The opto-couplers are 817Cs, not TLP621s, I couldn't get Fritzing to take that label away.

The 3-pin jumper labelled 'JD' on the module allows a separate power supply to be used to drive the relay coils. With the jumper installed, the 'logic' power is connected through to the relay coils. This is no good on a 3.3 volt system as there is not enough voltage to power the coils properly. The rest of the logic will work happily on 3.3 volts. So, by completely removing the (yellow) jumper from the 3-pin header, 5 volts can be attacted to the left hand pin directly from the Netduino or Raspberry Pi 5 volt pin. The middle pin is shorted to Vcc on the 4-pin header and the right pin is shorted to ground on the 4-pin header, so the jumper must be completely removed otherwise you'll short the power supply and let the smoke out. Also note that this part of the circuit is not opto-isolated, so you might consider using a completely separate supply here, although whatever you use must share a common ground with the Netduino/Raspberry Pi. Take care and think before acting! 

The other jumper with 4 pins is labelled Vcc In1 In2 Gnd and is the logic side of the circuit, which is completely isolated from the relays. Connect this Vcc to your Netduino/Raspberry Pi 3V3 (3.3 volt) pin and Gnd to one of the computer's Gnd (0 volt) pins. In1 and In2 connect to GPIO pins. Once your GPIO pins are configured as outputs, then writing a 0 energizes the relay coil (LED on) and writing a 1 de-energizes it (LED off). You should hear a definite 'click' as the relay changes state. The relay coil needs that 5 volts to get reliable operation, it will not work or will not be reliable at 3.3 volts.

The nice thing about the module is that they've used an opto-coupler, so all the logic is electrically and physically isolated from the relay coil inductive load. There should be no chance of anything nast coming from the switched load or the relay coild and zapping the computer. However, you still need to be careful with the power arrangements and definitely be careful with that JD jumper pin, as you can short out the power supply if you put it in the wrong place!

On my breadboard I have used a 5-way ribbon cable to connect up to the Raspberry Pi's 5v, 3.3v, Gnd and GPIO pins 18 and 23, via an Adafruit Pi T Cobbler Plus.

No Comments

Add a Comment

Let Us Help You

Find us on Facebook