Posts: 17
Joined: Tue May 22, 2012 7:54 pm

relay schematic

Tue May 22, 2012 7:58 pm

hi all

i'm new on this forum and i hope you can help me.
i have buy a raspberry pi b and i want to use the gpio for some automation.

can somebody tell me how i can setup anc programming with c++ a schematic with one relay?

I found this website http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29 did i can directly attach my relay to the gpio? or any other low budget ideas?

thx for your help

User avatar
Forum Moderator
Forum Moderator
Posts: 11847
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: relay schematic

Tue May 22, 2012 9:17 pm

No, you need a relay driver such as the ULN2004.

The GPIO's canot drive a relay directly because they cannot deliver enough current for a normal relay, also a relay forms a large induction, and switching off currents through such an induction can induce high voltages over the coil which may damage the GPIO port.
Also the GPIO cannot source more than 3.3 volt.
A ULN2004 can drive up to seven relays, and it can switch 50 Volt signals, the GPIO pins can directly drive it.
It costs only a few dimes at Farnell, (and about an euro in a normal electronics shop).

Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: relay schematic

Wed May 30, 2012 10:19 am

Or, depending on the relay and drive ca[ability of the GPIO pins, a transistor, resistor and diode may be sufficient. Though a ULN2004 gives you extra outputs, should you want them.

Posts: 1
Joined: Sun Jun 10, 2012 8:56 pm

Re: relay schematic

Sun Jun 10, 2012 9:11 pm

I used an Arduino relay board. They are cheap and usually even equipped with optocoupler and status led. Works like a charm, just hook it up to the GPIO headers and 5V from pin2.
I got this one on eBay: link.

Nigel Day
Posts: 22
Joined: Sat Jun 16, 2012 2:15 pm

Re: relay schematic

Sat Jun 16, 2012 3:37 pm

I have a little Z-guage model railway I control via a Velleman K8055 USB interface board, using 5V sealed reed relays I got from my local Maplins (http://www.maplin.co.uk/sealed-reed-relays-2605) to trigger the turnouts. Clearly, I could use this set-up with my raspi (someone has already reported success in porting the Linux driver, see http://forum.velleman.eu/viewtopic.php?f=12&t=7838), but it seems silly using an interface board three times the size of the raspi when I should be able to do it directly from the GPIO (plus a small breadboard, in both cases). Unfortunately while the relays are low drain (they have 500 Ohm impedance) they need at least 3.8V to trigger. Can someone suggest a simple circuit with commonly-available components I could use to drive these relays, please?

Even better, to allow me to control a turnout with one GPIO line, could someone help me with a circuit that would briefly energise one relay on the rising edge of the GPIO line, and do the same for a different relay on a falling pulse? This would also reduce the danger of burning out the turnout coils by activating them too long, or activating both coils at once! The 'normal' way these turnouts are activated is by pressing a a switch that temporarily connects the 10VAC output from the transformer unit to the appropriate coil of the turnout.

Posts: 258
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK

Re: relay schematic

Sat Jun 16, 2012 5:06 pm

The question regarding relays comes up fairly frequently, the easiest thing to do is use a darlington driver such as the ULN2004 or ULN2803 that you can power from a 5V or 12v line. Connect the GPIO pins to the input and the output to your relay, there will be enough power to directly activate your relay, no extra components required as it even has a clamp diode built-in.

Return to “Automation, sensing and robotics”