reef-pi :: An opensource reef tank controller based on Raspberry Pi.

Marc Kruithof

New Member
View Badges
Joined
Feb 16, 2018
Messages
14
Reaction score
15
Rating - 0%
0   0   0
Ok, each one needs 15-20mA Driver Current. still too much for the pi to handle.
It looks like it drives opto's,

http://www.mosaic-industries.com/em...spberry-pi/gpio-pin-electrical-specifications
I did a lookup what the pi can handle: the maximum you can source from all the GPIO outputs simultaneously is less than 50 mA.
4 times 15 mA for four relays means 60 mA, and we didn't considder the pi itself that also uses gpio for several stuff.
 

MaccaPopEye

Well-Known Member
View Badges
Joined
Jan 5, 2016
Messages
697
Reaction score
1,232
Rating - 0%
0   0   0
Hi MaccaPopEye,
You can't drive a mechanical relay directly from the RPI. The RPI simpely can't give enought power. So YES you need transistors or FET's to drive relays. Also why do you want two seperate for the relays? is there a specific reason? Can't you make a small drawing for what you want to build? I am sure we can help more if you do. And about ground. As you described it, it looks like you need ground connected from the pi but I'm not sure about how you are planning circuit.

Hi Marc,

This is a rough diagram of what I am looking to achieve. Hopefully it makes sense. I want a main control module with the Raspberry Pi and all probes etc will plug into that, and then I want 2x eight outlet power boards to be separate.

Inside each power board will be a 240V-5V 3A buck converter and an 8 channel relay board. 240V will come in through a fused switch and power the 8 outlets and the buck converter. The buck converter will power the relay boards (needs 5V) and then then 8 control wires (and only the 8 control wires) will go from the relay board to the Raspberry Pi via an RJ-45 socket.

I do know that multiple people are running mechanical relays directly form the Raspberry Pi board without any issue (using the 5V supply on the Pi). At the moment I have the relays running off a 5V step down and the Raspberry pi running off a separate 5V step down, but both 5V step downs are powered by the same power supply so in the end I guess they kind of share a ground? I didn't think it works like that though.



Untitled.png
 

Marc Kruithof

New Member
View Badges
Joined
Feb 16, 2018
Messages
14
Reaction score
15
Rating - 0%
0   0   0
Ok Nice. If you use the relay board like https://www.sainsmart.com/products/8-channel-5v-relay-module you will fry your pi. you need something to drive those. Are you using these?
You also need a ground from the pi to both relay boards. 240 AC are also two wires?!

Last question. Do you need Buck converter 2 and 3 for some special reason? Electricaly you can use only one for those.
 

MaccaPopEye

Well-Known Member
View Badges
Joined
Jan 5, 2016
Messages
697
Reaction score
1,232
Rating - 0%
0   0   0
Ok Nice. If you use the relay board like https://www.sainsmart.com/products/8-channel-5v-relay-module you will fry your pi. you need something to drive those. Are you using these?
You also need a ground from the pi to both relay boards. 240 AC are also two wires?!
Last question. Do you need Buck converter 2 and 3 for some special reason? Electricaly you can use only one for those.

I'm not using that specific board but I am using essentially the same thing (these ones: https://www.littlebirdelectronics.com.au/8-channels-5v-relay-module). @Ranjib will be able to confirm or not but I believe a few ReefPi users are already using these directly from the Pi with no issues? Currently I am not though, I am powering my 2 relay boards with an LM2596 to step 12V DC down to 5V and I still plan to power them separately going forward so it doesn't matter to me either way.

The ground between the Pi to both the relay boards is the bit that is confusing me haha. Because I am pretty sure I don't currently have a ground between them but they are still working fine (switching on and off when the Pi tells them to that is, I don't have the mains outlets connected yet). Is it a safety thing?

And sorry about the confusion with the diagram, I drew the green and blue cables as a single line just for simplicity, in actual fact the AC cable (green) would have 3 wires in it (live, neutral and earth) and the control cable (blue) would have 8 wires in it (one per relay to go to the Pi). I only drew the V+ and Ground wires (red & black) separately as that is the bit I am confused about.

I do understand that I could do it with only 1 buck converter, however if I did that in addition to the control cable and the mains power cable going to each power board I would also need to have a DC power cable going from the main control unit to each power board. The buck converters are fairly cheap and I will already have AC power going to the power boards so I figured why not just add one to each power board as well to power the relays locally so that I only need 2 cables going to each power board instead of 3. Does that make sense?

I also wasn't sure what amperage I would need if I was to power everything off of 1 supply, where as I know I can power the Pi and then some from a 3A supply and I know that giving each relay a 3A supply is also more than enough so I couldn't see any harm in it.

If it turns out that I do actually need the ground on the relays to go directly back to the Pi then that would bring me back to 3 cables going to each power board anyway so I might as well power the relays from the main control unit. I guess now my main question is why are my relays working fine now when the ground doesn't go back to the Pi?
 

Gareth elliott

Read, Tinker, Fail, Learn
View Badges
Joined
May 7, 2017
Messages
5,468
Reaction score
6,935
Location
NJ
Rating - 0%
0   0   0
That’s interesting, so pi gnd and relays,s psu gnd are not connected ?

Thats correct i have separate psu’s for pi and relays at the moment.(well did my build is currently taken apart to build my new one). Only connection i had for probes and relays to the pi were gpio pins. Worked flawlessly like that. The only vcc or ground pins that came from the pi were the display.
 

Bronc

Valuable Member
View Badges
Joined
Mar 1, 2016
Messages
1,348
Reaction score
2,234
Location
Tulsa, OK
Rating - 0%
0   0   0
:) exciting time. No sensors?
Those SSD based relays are very good, but remember they have 2A load limit (cross check), for me they have been very stable, the mechanical ones sometime get bad (like one of the channels in 8 channel module will be wedged), but the ssd relays are all working exactly same as they were for past two years, almost
I’ve decided to add a second 8 channel SSD relay. I remember reading that I’ll need to add something else in order to add this but can’t remember what. Can someone remind me?
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,966
Reaction score
3,360
Location
Sacramento, CA area
Rating - 0%
0   0   0
That’s interesting, so pi gnd and relays,s psu gnd are not connected ?

If they are on different power supplies, no. You should ideally always connect any signal grounds unless they are intentionally across an isolation barrier (which is great when tons of different supplies are in use, or across distances).

Power supplies are isolated and will float relative to one another.


There are of course some caveats here which can make very low current signals just appear to work: Most switch mode supplies also have a Y capacitor coupling one of the AC pins (earth ground, or one of the AC line pins - it ideally is neutral but there is no guarantee of this on two prong equipment). This lets a leakage current of up to 60uA across, which is plenty for some signalling work.
 
Last edited:

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,966
Reaction score
3,360
Location
Sacramento, CA area
Rating - 0%
0   0   0
Dont apologize for the questions. I am not an expert, and these questions are the ways we all learning :) . So more is merrier to me.

Coming back to the original point, yes, I was under the assumption that the GNDs have to be connected across all the dc psu's. I am likely wrong here, I'll let @theatrus or someone more familiar with electronics to chime in for more concrete answers. If your setup has worked without this, then clearly this is not required. I dont know then if its a good thing to do or we can completely skip it. As part of 2.0 release I am going through each of our circuits and trying to figure out if they can be improved (best practices). Each of reef-pi's current circuit works, but that does not mean they follow the best practices, like the relay's can be drive straight from GPIO but the sainsmart docs recommend using transistor and couple of resistors : https://docs.google.com/file/d/0B5-HND9HJkXWSTQtYlFTZ3VyODA/edit

The Sainsmart recommends the drive circuit as you are driving an optoisolator (see below) which requires significantly more current than an NPN or NFET to switch the inputs. The RPi has an aggregate limit of 51mA across all of the GPIO pins, hence the recommendation.

I can also see that we should recommend capacitors across all PSUs input/output (i.e. lm2596 should have a couple of capacitors in front and back). Since we are using breakout boards, not the IC directly, this might be offered by the board itself, and we dont have to use it (but if someone is using 7805/7810 style regulators directly, they have to).
Another thing I noticed, @theatrus mentioned about adding flyback diodes, I know what they do, but I was not sure if we need that for the relay or any other setup .
The Sainsmart relay board is somewhat weird as you drive an optoisolator. This lets you use a different supply for the relay coils as the relay signal, including isolated grounds between them. The stated currents for Sainsmart is actually to drive the LED inside the optoisolator. The board integrates the diode and FET post-isolator to actually switch the relay coils:

sainsmart.png
 

Gary G

Active Member
View Badges
Joined
Nov 8, 2016
Messages
128
Reaction score
66
Rating - 0%
0   0   0
man i'm going to need one heck of a how two. I trying to keep up. lol so far all I know is to buy is the pi as far as other boards and power supplies i'm lost so much talk about different boards
 

denierlexiese

Active Member
View Badges
Joined
Jul 7, 2017
Messages
106
Reaction score
68
Rating - 0%
0   0   0
i just started driving a sainsmart 5v 4 channel relay with the rpi tonight. Seems like all the tutorials on youtube say it's fine. I'm only running a 3.3Volt float switch line into the relay to communicate back to my aqua controller through the io break out box.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I'm not using that specific board but I am using essentially the same thing (these ones: https://www.littlebirdelectronics.com.au/8-channels-5v-relay-module). @Ranjib will be able to confirm or not but I believe a few ReefPi users are already using these directly from the Pi with no issues? Currently I am not though, I am powering my 2 relay boards with an LM2596 to step 12V DC down to 5V and I still plan to power them separately going forward so it doesn't matter to me either way.

The ground between the Pi to both the relay boards is the bit that is confusing me haha. Because I am pretty sure I don't currently have a ground between them but they are still working fine (switching on and off when the Pi tells them to that is, I don't have the mains outlets connected yet). Is it a safety thing?

And sorry about the confusion with the diagram, I drew the green and blue cables as a single line just for simplicity, in actual fact the AC cable (green) would have 3 wires in it (live, neutral and earth) and the control cable (blue) would have 8 wires in it (one per relay to go to the Pi). I only drew the V+ and Ground wires (red & black) separately as that is the bit I am confused about.

I do understand that I could do it with only 1 buck converter, however if I did that in addition to the control cable and the mains power cable going to each power board I would also need to have a DC power cable going from the main control unit to each power board. The buck converters are fairly cheap and I will already have AC power going to the power boards so I figured why not just add one to each power board as well to power the relays locally so that I only need 2 cables going to each power board instead of 3. Does that make sense?

I also wasn't sure what amperage I would need if I was to power everything off of 1 supply, where as I know I can power the Pi and then some from a 3A supply and I know that giving each relay a 3A supply is also more than enough so I couldn't see any harm in it.

If it turns out that I do actually need the ground on the relays to go directly back to the Pi then that would bring me back to 3 cables going to each power board anyway so I might as well power the relays from the main control unit. I guess now my main question is why are my relays working fine now when the ground doesn't go back to the Pi?
You are right. All my builds (3) have pi directly wired to ssd or mechanical relays. I never encountered any issue, I use the pi 5v out to power the vcc of relays.
But that does not mean this is right. I guess if we are not changing multiple relays at same time the current draw wont be very high. That might explain why it worked (nit sure).
Going forward, I think its safe to recommend use npn transistors in between.
The type of relay is also very interesting. On the board itself these are labeled opto couplers, so most likely they have some optical component. I used to call these optocouplers as well, but in last makerfaire couple of folks pointed out that these are mechanical relays, hence the clicky sound. Powertrail switches, (and some other model from dataloggers) has relay controlled outlets, i bought couple of those from adafruit, which are also labeled as optocoupler , and does not make sound. Ladyada had introduced those as optocoupler based relays, so I can hands down trust that those are for sure optocouplers.
This brings the question then, why some folks are calling these mechanical relays or whats in them that causes the click sound every time we turn them on.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
i just started driving a sainsmart 5v 4 channel relay with the rpi tonight. Seems like all the tutorials on youtube say it's fine. I'm only running a 3.3Volt float switch line into the relay to communicate back to my aqua controller through the io break out box.
Yes, I too learned to use them that way.
This means I have to re-investigate my buzzer and mechanical switch wiring as well :-/
 

lazybones51

New Member
View Badges
Joined
Feb 13, 2018
Messages
13
Reaction score
10
Rating - 0%
0   0   0
Hey, did we get this sorted, if not. I should look into this. RPI based pwm drivers are not second class citizen. And it should work flawlessly , if you are still encountering issue (i.e. threshold are not solving the flashing), its likely a bug with on/off thing that we are doing in the reef-pi/rpi pwm code path. I would definitely address this before a public release.
Unfortunately not, I spent a small amount of time debugging the code but I didn't get to the bottom of the issue and haven't had a chance to look at it since unfortunately. I'll try to find some time this week to take another look.
 

knuffellinda09

New Member
View Badges
Joined
Mar 12, 2018
Messages
2
Reaction score
1
Rating - 0%
0   0   0
Nederlands

I have a question

I also want to use a raspbery

but which one can I buy the best

I want to do the following with it

t5 dim

temperature

salt

ph

no 2

no3

and maybe more

hopefully you can give me info
 

Gareth elliott

Read, Tinker, Fail, Learn
View Badges
Joined
May 7, 2017
Messages
5,468
Reaction score
6,935
Location
NJ
Rating - 0%
0   0   0
Nederlands

I have a question

I also want to use a raspbery

but which one can I buy the best

I want to do the following with it

t5 dim

temperature

salt

ph

no 2

no3

and maybe more

hopefully you can give me info

Pi3 is the most recent raspberry pi available.
No3 probes are like $300-600 and only makers i believe are hach and pinpoint. Which currently dont offer open source circuits. I dont believe even apex offer selective ion probes atm. Some of these are either very inaccurate or have very short lifespan. Ie the calcium ion probe is like 6 months, $350 a probe. And not intended for constant submersion.

T5 dimming i am looking at myself and the circuit ranjib designed for the kessil should be adequate. As also requires the same pwm. 1 channel needed per ballast.

Ph is supported through the atlas scientific chip.

Temperature control is done through the ds18b20 water proof sensor.

Build guides are located here.

https://reef-pi.github.io
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Unfortunately not, I spent a small amount of time debugging the code but I didn't get to the bottom of the issue and haven't had a chance to look at it since unfortunately. I'll try to find some time this week to take another look.
No worries. I was able to reproduce this, I am seeing better result after increasing the pwm frequency. I'll push a fix soon, probably today
 

Gareth elliott

Read, Tinker, Fail, Learn
View Badges
Joined
May 7, 2017
Messages
5,468
Reaction score
6,935
Location
NJ
Rating - 0%
0   0   0
If they are on different power supplies, no. You should ideally always connect any signal grounds unless they are intentionally across an isolation barrier (which is great when tons of different supplies are in use, or across distances).

Power supplies are isolated and will float relative to one another.


There are of course some caveats here which can make very low current signals just appear to work: Most switch mode supplies also have a Y capacitor coupling one of the AC pins (earth ground, or one of the AC line pins - it ideally is neutral but there is no guarantee of this on two prong equipment). This lets a leakage current of up to 60uA across, which is plenty for some signalling work.

I will take your expertise on the subject :)

For the most part will be copying ranjib’s aio build circuitry. Will make sure all is on a common ground :).

Suggestion on psu?

https://www.amazon.com/Apevia-ITX-AP300W-Mini-ITX-Solid-Supply/dp/B01M6V8O8T
Would this work?
Housing dimensions are 17x9.06x2.36
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I will take your expertise on the subject :)

For the most part will be copying ranjib’s aio build circuitry. Will make sure all is on a common ground :).

Suggestion on psu?

https://www.amazon.com/Apevia-ITX-AP300W-Mini-ITX-Solid-Supply/dp/B01M6V8O8T
Would this work?
Housing dimensions are 17x9.06x2.36
I always pondered about using one of these , but never actually used one. The only thing I’d be verifying is probably if the circuit is 10 amp safe. I believe the perfboard I use can only deal with 4-5amp at max.

This is another area (psu) that I think we need some electronics help @theatrus @Marc Kruithof . Particularly for aio builds as we need 5v (for pi, ato sensors , pca9685 ) 3v (temp, ph ) and 10v (kessil) , 12v (doser). As of now I am using a largest voltage and then for each type a single lm2596 , but that limits 2amp. Also I am fairly sure we are missing some safety circuit across different voltage (diodes and capacitors ) . I am also curious of the effect when all the lm2596 are wired directly to the main dc source vs smaller ones are daisy chained to larger ones (I.e. 12v lm2593 feeds the 5v and so on..)
I have observed pwm flickering while using multiple output from single source using lm2596, which was resolved by increasing pwm clock frequency , but this might just be a ductape
 

Keeping it clean: Have you used a filter roller?

  • I currently use a filter roller.

    Votes: 65 34.9%
  • I don’t currently use a filter roller, but I have in the past.

    Votes: 6 3.2%
  • I have never used a filter roller, but I plan to in the future.

    Votes: 48 25.8%
  • I have never used a filter roller and have no plans to in the future.

    Votes: 59 31.7%
  • Other.

    Votes: 8 4.3%
Back
Top