Raspberry Pi and 8 channel relay board


8 posts
by goodkat » Wed May 15, 2013 9:20 am
Hello.

I have 8 channel relay board which I want to connect to Raspberry Pi. I did a research online but the wiring schematics I found didn't worked and I became afraid that I may fry either the Pi or the relay board.
As I hope I understood right, I might need some kind of barrier between the Pi and the relay board and external 5v power source for the relay board (because I will have all 8 relays switched ON simultaneously).
I've seen videos on Youtube where people connect the relay board directly to the Pi's and everything is working properly, but I can't get it working. Is that even safe? And another thing - the seller which sold the relay board wrote in the description that each relay needs ~30mA to work, so this means that for each relay board I hook to the Pi I will need 5v 2.4A power supply, right?

If somebody has done that and have a properly working and safe setup I will really appreciate some help and guidance with making mine. When I get the things working I will write proper documentation so that anyone doing the same after me don't have to bother reading lots of confusing forum posts.

This is a picture of the relay board and the Pi I've got - http://upload.bg/?get_file=f2322f4c779d ... d91&inline
Posts: 2
Joined: Wed May 15, 2013 8:58 am
by pjc123 » Wed May 15, 2013 11:41 am
There is very detailed information on this forum about the operation of these relays (a years worth), so start reading so you understand (Or if you are new to electronics, at least have an idea) how all the circuitry works instead of blindly hooking things up. Keeping in mind that there are minor differences between these boards, the closest I have seen to a complete schematic is here:

viewtopic.php?t=36225

Unfortunately I am too lazy to draw up a schematic, so it would be nice if you did that once you get it going.

I use a similar circuit to the above schematic, but with the following differences (This is how my working relay card is connected, and I also operate all relays at the same time on occasion):

1) Do not supply power to the pi via the test points. Apply power through the micro usb connector as normal, so you do not bypass the pi's fuse.

2) On my board, 8 relays turned on take 60ma each which is a total of 480ma (.48 Amps). As far as the calculation you did for 30ma, it is .030 Amps X 8, not .30 X 8, for a total of .24 Amps. Also keep in mind that some of the data on the spec sheets of these devices is flatly wrong, and measuring values is the only way to be sure. An external power supply is needed even with minimal extra items connected to the pi and activating all 8 relays simultaneously. To connect an external power supply, remove the VCC / JDVcc / GND jumper. Connect the pis +5V and GND from the GPIO pins to the relay cards 10 pin header (Vcc and GND) to operate the opto circuitry. Connect an external 5V power supply to the 3 pin header (JDVcc and GND) to operate the coils and associated circuitry (Almost all of the 60ma per relay is drawn from this supply).

3) You can use a ULN2803 or similar IC in place of the transistor if you want to. Either one will safely isolate the 3.3V data level of the pi from the 5V of the relay card. This will also convert the card from being active LOW to active HIGH, which makes a heck of a lot more sense. Some will argue that neither is required, but that has been discussed ad nauseam in these forums, so come to your own conclusion about the risks.
Posts: 910
Joined: Thu Mar 29, 2012 3:37 pm
by Mistertee » Tue Aug 13, 2013 6:48 am
Here is a link to a dedicated Raspberry Pi 8 relay card that uses I2C control. This means that a number of these can be daisy chained to provide 16, 24, 32 .... upto a maximum of 64 relays.

http://www.sf-innovations.co.uk/custard-pi-6.html
Posts: 21
Joined: Tue Aug 13, 2013 6:43 am
by pjc123 » Tue Aug 13, 2013 11:14 am
Mistertee wrote:Here is a link to a dedicated Raspberry Pi 8 relay card that uses I2C control. This means that a number of these can be daisy chained to provide 16, 24, 32 .... upto a maximum of 64 relays.

http://www.sf-innovations.co.uk/custard-pi-6.html


Interesting.....too bad it is so expensive ($55).
Posts: 910
Joined: Thu Mar 29, 2012 3:37 pm
by Mistertee » Tue Aug 13, 2013 11:45 am
It is priced at £36 which is competitive with the Pi Face (which is £28) but the Custard Pi 6 supplies much more. It is made in small quantities in the UK, so not cheap and cheerful China prices I am afraid.

The PCB can be supplied on it's own for a few £££s for someone to source the components and build it themselves if you are interested.
Posts: 21
Joined: Tue Aug 13, 2013 6:43 am
by pjc123 » Tue Aug 13, 2013 12:57 pm
Mistertee wrote:It is priced at £36 which is competitive with the Pi Face (which is £28) but the Custard Pi 6 supplies much more. It is made in small quantities in the UK, so not cheap and cheerful China prices I am afraid.

The PCB can be supplied on it's own for a few £££s for someone to source the components and build it themselves if you are interested.


The piface is a completely different product with extra functions, not just a relay board. Another issue with the Custard Pi relay board is that it requires an additional 12v power supply, which makes it even more expensive. Lets see, I could buy eight Sainsmart 8 channel relay cards at $12 each for a price of $96 + GPIO expander chips, or I could buy 8 custard Pis at $55 each for a total of $440. This is a no brainer. I guess if I worked for the government, this would fit right in with the $640 toilet seat that the Pentagon bought in the 80's.
Posts: 910
Joined: Thu Mar 29, 2012 3:37 pm
by Mistertee » Tue Aug 13, 2013 8:57 pm
I guess we can both agree on the stupidity of the Pentagon :D
Posts: 21
Joined: Tue Aug 13, 2013 6:43 am
by Mistertee » Fri Aug 16, 2013 4:58 pm
On a more serious note though:

Have taken on board the comments about the price. In fairness, this is not a valid comparision as this example compares an off the shelf product (Custard Pi 6) with one that does not exisit (combining exisiting products with a GPIO expander). The latter approach needs electronics knowledge and the design of a new PCB to take the components.

A starter kit version has been introduced for £12. (Please see here for more information).
http://www.sf-innovations.co.uk/custard-pi-6.html

There is full schematic and parts list included to help designers up and running quickly without having to guess at the circuit.

The user can build this circuit up with anything from 1 to 8 relays as required thus cutting costs.
Posts: 21
Joined: Tue Aug 13, 2013 6:43 am