Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Relay boards

Wed Dec 26, 2018 4:34 pm

Hi everyone,
My question is this......
Can I control 4 "16 channel" relay boards
Here is what I want to do....
I want to make a water feature in my garden with 16 water jet's and around each jet 3 coloured lights "red-green-blue" that's a board for each colour.
Pi picks a random number for the water jet and then picks a random colour (0-2:red-green-blue) but the jet has to be the same as the light.....so jet =4, I need 4 to light on 1 of the colour boards.
Hope this makes sense.
Regards Frank

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Wed Dec 26, 2018 5:09 pm

Thats possible.
However, which type of relays that you need to use are demanding on the type of yets that you are using. So, if those are big ones. You can not use the relais on the general relays boards. Because they can't handle it.

So, can you provide more information about the yets and the lamps? To see if what for kind of parts you potential need?

andrew.grimm3
Posts: 17
Joined: Sat Dec 06, 2014 3:59 pm

Re: Relay boards

Wed Dec 26, 2018 6:24 pm

Another chance is to use an NPN open collector output transistor to drive your external relay from the GPIO on the Rpi.

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Thu Dec 27, 2018 8:26 pm

Hi and thanks for the replies.
Before I continue about my project can someone tell me how to upload photos, so I can use them to explain better.
Regards Frank

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Thu Dec 27, 2018 8:31 pm

Under the submit bottum you can find the "attachments". If you click on "add files" you can add a picture. And then you can add it to you post.

pcmanbob
Posts: 5916
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay boards

Thu Dec 27, 2018 8:39 pm

If you want to post a number of images or biger image files,

Go to imgur.com you can open afree account then upload your images to there, then if you select the image you will have a number of options on the left which you can copy and past in to your post to display the image.

The line you need to copy is under "BBcode for message boards and forums."

Example

Code: Select all

[img]https://i.imgur.com/CmP9IV2.jpg[/img]
so the above line when pasted in you my post produces this image

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Sun Dec 30, 2018 8:02 pm

Hi Guy's, Sorry about the delay but very busy.
First off PCman Bob I have tried your Imgur hope it works..

https://imgur.com/a/50bJXl7

unfortunately it's not working like yours but they are there and you can see them..
I want to control
8 solenoids,
8 Red Lights,
8 Blue Lights
8 Green lights.
from 4 16 channel relay blocks
All on a 12volt system
All this from 1 Raspberry Pi,
So back to my original question can I independently control 4 16 Channel relays from 1 Raspberry pi

Every time a selenoid triggers i want 1 of the lights around it to light up. so if selenoid GPIO 3 opens I want a random colour but the GPIO number must be 3. so we get a random colour light next to the working selenoid.

Hope this makes sense
Thank you Brandon92 and Andrew.grimm3 and PCMan Bob

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Sun Dec 30, 2018 8:21 pm

Okay, I get a idea of what you want.
What for kind of leds are we talking about. The standaard 5mm leds?

So, in your current design you have 4*8 =32 outputs. And that's more than the Rpi can provide. This means that you need to add a i/o expander like the mcp23017. That will give you 8 extra inputs/ outputs. So when you are using for example 4 of them, you have 32 outputs and it only takes 2 outputs of you Rpi.

A other option would be that you connect the relays "direcly" to the rpi (with additional hardware) and that you are using addressable leds. This will save you a lot of outputs of your Rpi.

By the way, do you have experience with soldering parts and pcb? Then we know if you need something that exist or that you can make it by yourself.

LTolledo
Posts: 1385
Joined: Sat Mar 17, 2018 7:29 am

Re: Relay boards

Wed Jan 02, 2019 2:06 am

Here's a suggested block diagram of the circuit you have in mind,

the MCP23017 must be soldered to a perfboard, to be included in the perfboard are connectors for the I2C (from RPi), 5V power and output ports (for connection to relay boards). Also addresses for each MCP23017 must be set uniquely.
Make sure all grounds are common (connected together).

there are MCP23017 addon boards for RPi if you have doubts about your soldering skills. Just stack those above the RPi, again each MCP23017 address must be set uniquely

solenoid operation and lighting sequence can be controlled via software, in any sequence you prefer, just include the drivers for the MCP23017 in the code.

Hope this helps,
Attachments
RPiMCP2017x16Relayboardx4.png
RPiMCP2017x16Relayboardx4.png (77.63 KiB) Viewed 1965 times
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
mikronauts
Posts: 2698
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Relay boards

Wed Jan 02, 2019 2:03 pm

Fyi,

The MCP23017 has 16 i/o pins, so only two are needed.
Brandon92 wrote:
Sun Dec 30, 2018 8:21 pm
Okay, I get a idea of what you want.
What for kind of leds are we talking about. The standaard 5mm leds?

So, in your current design you have 4*8 =32 outputs. And that's more than the Rpi can provide. This means that you need to add a i/o expander like the mcp23017. That will give you 8 extra inputs/ outputs. So when you are using for example 4 of them, you have 32 outputs and it only takes 2 outputs of you Rpi.

A other option would be that you connect the relays "direcly" to the rpi (with additional hardware) and that you are using addressable leds. This will save you a lot of outputs of your Rpi.

By the way, do you have experience with soldering parts and pcb? Then we know if you need something that exist or that you can make it by yourself.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Thu Jan 03, 2019 8:30 pm

Hi Guys,( or Gals)
Fantastic replies for which I truly thank you.....

I want the lights and valves to work on 12V because this is going to be a water feature and the lights will be in water, I intend to use 12v decking lights.
your diagram is spot on LTolledo, that's exactly what i want.

Brandon92, I'm VERY VERY new to the Pi as in this Christmas new and I'm just learning "Python" . Although I did in the very very distant past program using basic and machine code on my Amstrad 464 and I have dabbled in electronics in the same era, so I'm very very excited to get back into these hobbies.

I purposely asked about 16 channel relays but only using 8 of them on each board because I was future thinking and was hoping to incorporate the remaining relays into my garden as in lighting some other parts or expanding my water feature.

LTolledo if you have the symantics to the diagram I would be forever in your debt.

if both of you could help me with more info on the MCP23017 and programing them, again I would be forever in your debts

Regards Frank

boyoh
Posts: 1269
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Relay boards

Fri Jan 04, 2019 4:15 pm

This water jet display project is ideal to use combination or sequential logic gates ,using Thyristors
To switch the solenoids, You could use a Decade counter to switch the thyristor gates, The
Decade counter could be clocked by the Pi, More decade counters could be cascaded to
More out puts for more solenoids, I would not use random display. I would give the display
Some order to look good, You could always change the order of the display.

You could use decade counters to switch the display lighting , using clock pulse from the Pi
The decade counters can be set to latch or momentary , and set to N and recycle.

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Fri Jan 04, 2019 5:29 pm

mikronauts wrote:
Wed Jan 02, 2019 2:03 pm
Fyi,

The MCP23017 has 16 i/o pins, so only two are needed.
Brandon92 wrote:
Sun Dec 30, 2018 8:21 pm
So, in your current design you have 4*8 =32 outputs. And that's more than the Rpi can provide. This means that you need to add a i/o expander like the mcp23017. That will give you 8 extra inputs/ outputs. So when you are using for example 4 of them, you have 32 outputs and it only takes 2 outputs of you Rpi.
Your correct. This is indeed the 16 I/O version. So, you only need two.

Or the OP find it easier to use for each relay board a dedicated I/O extension board.

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Fri Jan 04, 2019 6:04 pm

Franita wrote:
Thu Jan 03, 2019 8:30 pm
Brandon92, I'm VERY VERY new to the Pi as in this Christmas new and I'm just learning "Python" . Although I did in the very very distant past program using basic and machine code on my Amstrad 464 and I have dabbled in electronics in the same era, so I'm very very excited to get back into these hobbies.

I purposely asked about 16 channel relays but only using 8 of them on each board because I was future thinking and was hoping to incorporate the remaining relays into my garden as in lighting some other parts or expanding my water feature.
So, I can asumme that you don't have (much) soldering skills. And you prefer "extension" pcb that are (almost) done. And you only need to connect the wires between them. What is possible offcoure and I would suggest you to take a look at the following parts: So, how you connect them. First of all, why the level shifter in this case. As you might know the Rpi works on 3.3v and (most) of the relay boards are working on 5v. And if translate the 3,3v communication bus for the mcp* to 5v. Than he can easily drive the relay board. The other reason for this is also that you can use more power on the 5v rail than the 3,3v rail. What is necessary to drive all the relay boards inputs.

The link to the mcp* extension board might be easier for you, but you can also use only the ic and make your own board.

As for how you need to program it. I would suggest you to try this tutorial or one of the others:
https://learn.adafruit.com/using-mcp230 ... n/overview

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Fri Jan 11, 2019 6:22 am

Hi Brandon 92, thanks for your reply. I'm now busy revising all the information you have given me. My relay boards are going to be 12v and the Pi will have it's own usb power plug. I'm trying to keep things to 12v.
I have just ordered a breadboard and a
MCP 20317. I'm only starting with 1 of each component to make sure I can succeed. Once I do I will then add the rest of the components.

boyoh
Posts: 1269
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Relay boards

Fri Jan 11, 2019 11:19 pm

There are other things to take in to account on this project

Relays are to slow and relay bounce, causing the Solinoid
to be sluggish and slow , The water jet needs to be high
pressure (Pumped) Sugest using Thyristors, and maybe a
CDU Capacitor Discharge Unit.To give the Solinoid some
thump

Use heavy duty Solinoids to over come high pressure water
You want a high pressur jet not a dribble, The more solinoids
you have open at the same time will put alot of demand onthe
water pressure

Regards BoyOh Retired Electrical / Electronic Technician
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Tue Jan 15, 2019 7:13 pm

Hi Boyoh, unfortunately you are quite right as to the solenoids being sluggish. I connected the solenoid to my pump and opened it using a 12v transformer and the water just dribbled out. I'm looking at a height of about 6" to 9". I now have to find a solenoid that will allow the fast flow of water, I'm also thinking of using a central heating pump because these pump water all around the house. If you have any suggestions regarding the water flow I'm all 👂's .
I'm very very new to the Pi and Python. Although I did program in Basic 20years ago . The electronics part is getting above my head although I have dabbled in electronics 20yrs ago it was extremely basic. I wished you lived down the road, because I'd be knocking on your door lol

boyoh
Posts: 1269
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Relay boards

Tue Jan 15, 2019 11:32 pm

Franita wrote:
Tue Jan 15, 2019 7:13 pm
Hi Boyoh, unfortunately you are quite right as to the solenoids being sluggish. I connected the solenoid to my pump and opened it using a 12v transformer and the water just dribbled out. I'm looking at a height of about 6" to 9". I now have to find a solenoid that will allow the fast flow of water, I'm also thinking of using a central heating pump because these pump water all around the house. If you have any suggestions regarding the water flow I'm all 👂's .
I'm very very new to the Pi and Python. Although I did program in Basic 20years ago . The electronics part is getting above my head although I have dabbled in electronics 20yrs ago it was extremely basic. I wished you lived down the road, because I'd be knocking on your door lol
BoyOh I will give you a few tips, but not do the research f or you. All you want to know is on the Web
1, Do not use a central heating pump, it is a circulating pump very little pressure.
2. I suggest a rotary pump , not piston type , Piston type tend to pump in pulses
3, Thyristors are solid state switches, and are very fast .
4 Use a good high out put power supply to eliminate pull down when switching
High inductive solenoids. Also fit Diodes to snub back EMF from solenoid coils
Regards BoyOH
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay boards

Wed Jan 16, 2019 7:31 am

Franita wrote:
Wed Dec 26, 2018 4:34 pm
Hi everyone,
My question is this......
Can I control 4 "16 channel" relay boards
Here is what I want to do....
I want to make a water feature in my garden with 16 water jet's and around each jet 3 coloured lights "red-green-blue" that's a board for each colour.
Pi picks a random number for the water jet and then picks a random colour (0-2:red-green-blue) but the jet has to be the same as the light.....so jet =4, I need 4 to light on 1 of the colour boards.
Hope this makes sense.
Regards Frank

PCA9685 16 Channel PWM Driver Module

You may like to consider this module:

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 $15
https://www.adafruit.com/product/815

Tutorial
https://learn.adafruit.com/16-channel-pwm-servo-driver

The driver can do PWM to drive servo or LED. I once set PWM duty cycle to 100%, and drove 16 LEDs or DC motors on/off.

You can also chain up the I2C modules and drive 900+ LEDs! :mrgreen:

PS - My experience is that PCA9685 is 5 times easier than MCP23017.
I am an electronics and smart home hobbyist.

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Wed Jan 16, 2019 12:21 pm

Hi Boyoh,
Thanks for the reply, I wouldn't expect you to do anything except give me good advice (without blinding me with science). I found some little 12v pumps on Ebay at £8:00 each and I thought of running 8 of these in stead of 1 large pump that way I shouldn't need any water valve solenoids, just control the pumps directly (pretty much the same as window washers on a car).


Hi tlfong01,
I have had a look at the links you provided and from what i can see the board you suggested does seem easier to program, But I want to use 12v 16 channel relay boards to control 12v decking lights and 12v water pumps. the "PCA9685" you suggest only seems to do 4v LED's and Model servos. is there a way to control the 12v 16 channel relays with it..

Kindest regards to you both Frank

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay boards

Wed Jan 16, 2019 2:56 pm

Franita wrote:
Wed Jan 16, 2019 12:21 pm
Hi tlfong01,
I have had a look at the links you provided and from what i can see the board you suggested does seem easier to program, But I want to use 12v 16 channel relay boards to control 12v decking lights and 12v water pumps. the "PCA9685" you suggest only seems to do 4v LED's and Model servos. is there a way to control the 12v 16 channel relays with it..

PCA9685 Controlling Relay

1. Ah, let me see. If you use either MCP23017 or PCA9685 (set to 100% duty cycle), all you get is high low signals (3V3 or 5V0, depending on your Vcc).

2. You then use the high low signal to activate/deactivate a relay (or thyristor), which in turn switches on/off 12V power to a solenoid valve (or pump).

I have not thought about it thoroughly. Perhaps you can comment and I will think again tomorrow.
I am an electronics and smart home hobbyist.

Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Tue Jan 22, 2019 8:33 pm

Hi People, sorry about delay but I've been searching the net for anything that helps me setup my Pi, Mcp23017 and my relay board.....but found absolutely NOTHING......

I can find Pi to Relay Board or Pi to MCP23017 and LEDS but NO Pi to MCP23017 to Relays.....

Is there ANYONE out there that can help me, it is so frustrating :x , it's getting that bad I'm thinking of giving up on the Raspberry Pi and moving to the Arduino..... :lol: ..

Brandon92
Posts: 770
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay boards

Tue Jan 22, 2019 9:22 pm

Franita wrote:
Tue Jan 22, 2019 8:33 pm
I'm thinking of giving up on the Raspberry Pi and moving to the Arduino..... :lol: ..
I believe that this is done before on this forum. And I unfortunately haven't not the time to search it.

But what part is do you have trouble with. Because a arduino and the Rpi is not that big of a different when you want to drive the Mcp23017 and a relay.

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

Re: Relay boards

Tue Jan 22, 2019 9:23 pm


Franita
Posts: 11
Joined: Wed Dec 26, 2018 11:24 am

Re: Relay boards

Thu Jan 24, 2019 9:29 am

Hi kind people, great news, I believe I have managed to get my Pi, mcp23017 and my relay working.... :o BUT it's looking like it's working backwards.....
If I give it..0x00 the relay lights come on
If I give it 0xff they all go off
I thought it was supposed to be the other way round......

Return to “Beginners”