User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Advice on project components...

Fri Feb 22, 2019 6:13 pm

I am getting ready to work on my first Raspberry Pi 3B+ based electronics project. I have done a lot of research so far but don't have the experience or know how to determine if the power supply I am considering will work. I need to purchase through Amazon - as I will be using Amazon credit to pay for this project.

The project is a system that will use up to as many as 8 relays to power on/off 145w 120v fans (up to 5 at one time - or as few as 2). It will also employ 4 temperature sensors. One of these sensors could be as far as 25ft away from the Raspberry Pi, 2 others will be within 1 or 2 feet, the last will be up to 10ft away. From what I have read on this, powering this many relays as well as this many of these sensors will require a pretty good power supply with a larger than typical wattage.


This is the relays I'm planning on: https://smile.amazon.com/gp/product/B00 ... 5SV8&psc=1
This is the sensors I'm planning on: https://smile.amazon.com/gp/product/B07 ... 9OSV&psc=1
I'm also planning to use these https://smile.amazon.com/gp/product/B00 ... P2JK&psc=1 to regulate the voltage coming back from the sensors so they are brought to 3.3V on the GPIOs.

The power supply I am looking at is: https://smile.amazon.com/gp/product/B00 ... 0DER&psc=1

I know that there are resistors to be placed on the sensors from what I have seen, from 4.7Kohm to 10Kohm so that may be another question - based on the distances and power supply - as the what resistor would be best - and maybe preferably - how to determine which size is best. I am familiar with electronic devices at the basic level - but am not an electronics engineer by any means. I know how to use breadboards and have an extensive IT background with a very small amount of electronics training. I am also pretty decent at household electrical systems - 120v/240v. Just to give an idea of my background.

The main question here is if this power supply is too little/too much, or good based on these components.

Thanks!
Andrew
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

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

Re: Advice on project components...

Fri Feb 22, 2019 6:37 pm

I should start by first reading common pitfall sticky #25 problems with relay modules, as these relays are designed for the Arduino, and will NOT simply work well with 3.3V control signals, doing this wrong may blow up your PI, as RPI's don't tolerate more than 4V on a GPIO pin either.

This manufacturer does not mention the coil current, and does not seem to provide schematics, so this is just a box-shifting reseller, as most are when using this sales channel.

however 6A total current seems excessive, on average each relay should draw just a few hundred mA (0.1A).
Try to find a seller that provides more data you can base your design decisions on.

https://www.raspberrypi.org/forums/view ... 8#p1225448

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Fri Feb 22, 2019 7:08 pm

My understanding of this unit is that there is a jumper on it that you remove so that it takes power from the power supply to throw the relays vs taking the power from the GPIO to try to do it. See here: https://www.youtube.com/watch?v=Ur0w7Ve ... dex=3&t=5s

Will this not work?

Thanks!
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Fri Feb 22, 2019 7:23 pm

The regular PSU for Raspberry Pi is 2.5amp, plus with up to 8 of these relays triggered would be another .8amp (3.3amp) and the sensors also have a power draw (from here: https://www.sparkfun.com/datasheets/Sen ... /DHT22.pdf of up to 1.5mA each during measurement for another 6mA if measuring with 4 of them at once - so a total of 3.9A? I assumed to use a PSU with more available supply and I like to figure 80% of rated power for full-time use (so as not to put too much stress running at full capacity) - (6A*80%)= 4.6A. But maybe this is all incorrect thinking on my part...

Thanks!
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Fri Feb 22, 2019 8:33 pm

mahjongg wrote:
Fri Feb 22, 2019 6:37 pm
I should start by first reading common pitfall sticky #25 problems with relay modules, as these relays are designed for the Arduino, and will NOT simply work well with 3.3V control signals, doing this wrong may blow up your PI, as RPI's don't tolerate more than 4V on a GPIO pin either.

This manufacturer does not mention the coil current, and does not seem to provide schematics, so this is just a box-shifting reseller, as most are when using this sales channel.

however 6A total current seems excessive, on average each relay should draw just a few hundred mA (0.1A).
Try to find a seller that provides more data you can base your design decisions on.

https://www.raspberrypi.org/forums/view ... 8#p1225448
Ok, I see the issue. Using the setup in the YouTube video I linked to supplies the coil side of the relays with 5V from the PSU - but he's basically getting lucky that the LED/input side is working as they are being triggered by the GPIOs at 3.3V - but really should be getting at least 4V to be reliable - which would in turn be bad for the RPi (4V vs 3.3V). Well, that sucks... Does anyone have any good sources for an 8 channel relay for the RPi then? I have tried looking and have really had no luck. What about using 2 of the logic levelers I linked to? They are Bi-directional - so could they be used on the GPIO side, to come out with a 5V output that could connect to the IO pins on this relay? Then the 5V coming back form the relay would also go through the logic leveler to drop it back to 3.3V? Bit of a pain, but would require buying 2 more of those to use with the relay.


Thanks!
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Advice on project components...

Sat Feb 23, 2019 8:39 am

Those relays will require a 5 volt input on the VOC pin, a circuit common input on the GND pin and will take a 3.3 v input, low signal, to enable on the INX pins. The low in will cause the LEDS to illuminate and a click will be heard as the relays energize. Those relays have optically isolated inputs. You will not need to change the input jumper wire. I use the same relay package directly connected to the ESP32, a 3.3 volt device, GPIO pins. Those relays come with a built in diode to prevent inductive kick when powered off.
Last edited by Idahowalker on Sat Feb 23, 2019 4:43 pm, edited 1 time in total.
Without knowing why you are deleting my postings, I will not know how...

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

Re: Advice on project components...

Sat Feb 23, 2019 10:50 am

So assuming this relay board is active low ( most are but you should check) can be made to work with the pi gpio by using a simple interface circuit, that switches a ground on to the IN pins when a gpio high is applied to it.

The circuit can be built from transistors and resistors , but seeing as you are going to use an 8 way board you may as well just use a ULN2803A between the pi gpio and the relay board.

I would also feed the relay board directly from the power supply on its own cables rather than via the pi gpio pins as switching relays can cause voltage dips due to the change in current being drawn which you don't want the pi to experience.

once you have checked the relay board is active low if you need a diagram for connecting the ULN2803A just ask.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

JohnsUPS
Posts: 116
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Advice on project components...

Mon Feb 25, 2019 4:07 am

Ok, I see the issue. Using the setup in the YouTube video I linked to supplies the coil side of the relays with 5V from the PSU - but he's basically getting lucky that the LED/input side is working as they are being triggered by the GPIOs at 3.3V - but really should be getting at least 4V to be reliable - which would in turn be bad for the RPi (4V vs 3.3V). Well, that sucks... Does anyone have any good sources for an 8 channel relay for the RPi then? I have tried looking and have really had no luck. What about using 2 of the logic levelers I linked to? They are Bi-directional - so could they be used on the GPIO side, to come out with a 5V output that could connect to the IO pins on this relay? Then the 5V coming back form the relay would also go through the logic leveler to drop it back to 3.3V? Bit of a pain, but would require buying 2 more of those to use with the relay.
Yes, you can use a level shifter between the GPIO pin and the input to the relay board that you had specified. They don't have to be bi-directional though. Also, a simple transistor buffer will work, but the logic will have to be inverted.

Although the Amazon ad for the relay board states that it will switch using TTL voltage levels, this implies the 3.3V should work (typical TTL acceptable input threshold is 2V), but don't trust these inexpensive relay boards to adhere to this standard. Using a level shifter on the GPIO output will shift the input signal to the relay board closer to 5V, insuring that they will switch, and buffer the GPIO to boot. The board appears to drive the coils of the relays via a transistor, and the coils diode protected, so you should be fine.

The power supply you specified should also be OK, although it's current sourcing capability appears to be more than you will need. It should work nonetheless. I would power the relay board directly from the power supply instead of using a 5v pin off of the Pi. Just make sure that the ground of the Pi and the ground of the relay board are connected.

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Tue Feb 26, 2019 2:53 pm

JohnsUPS wrote:
Mon Feb 25, 2019 4:07 am
Ok, I see the issue. Using the setup in the YouTube video I linked to supplies the coil side of the relays with 5V from the PSU - but he's basically getting lucky that the LED/input side is working as they are being triggered by the GPIOs at 3.3V - but really should be getting at least 4V to be reliable - which would in turn be bad for the RPi (4V vs 3.3V). Well, that sucks... Does anyone have any good sources for an 8 channel relay for the RPi then? I have tried looking and have really had no luck. What about using 2 of the logic levelers I linked to? They are Bi-directional - so could they be used on the GPIO side, to come out with a 5V output that could connect to the IO pins on this relay? Then the 5V coming back form the relay would also go through the logic leveler to drop it back to 3.3V? Bit of a pain, but would require buying 2 more of those to use with the relay.
Yes, you can use a level shifter between the GPIO pin and the input to the relay board that you had specified. They don't have to be bi-directional though. Also, a simple transistor buffer will work, but the logic will have to be inverted.

Although the Amazon ad for the relay board states that it will switch using TTL voltage levels, this implies the 3.3V should work (typical TTL acceptable input threshold is 2V), but don't trust these inexpensive relay boards to adhere to this standard. Using a level shifter on the GPIO output will shift the input signal to the relay board closer to 5V, insuring that they will switch, and buffer the GPIO to boot. The board appears to drive the coils of the relays via a transistor, and the coils diode protected, so you should be fine.

The power supply you specified should also be OK, although it's current sourcing capability appears to be more than you will need. It should work nonetheless. I would power the relay board directly from the power supply instead of using a 5v pin off of the Pi. Just make sure that the ground of the Pi and the ground of the relay board are connected.

Thanks for the replies! JohnUPS, Is the "simple transistor buffer" the same as the part that pcmanbob is referencing (ULN2803A)? If so, that does look like that would be a cheaper solution than the logic leveler(s). I'm not familiar with that component and will have to look into it further on how to use it.

Thank for the explanation of the TTL voltage levels - I didn't know that. As the logic levelers would up that voltage to the inputs on the relay - and it provides a buffer to the GPIO as well - would you have a preference one way or the other with the logic leveler vs the transistor buffer? Would the transistor buffer provide a higher voltage (near 5V) to the relay as well? Does it offer the buffering effect to the GPIO as well?

I was planning to use the PSU to power the RPi, relay board, and the DHT22's all by direct connections to them from the PSU vs feeding the relay board and/or DHT22s via the RPi 5V pin. Is this what you mean as well? As I understood it, this relay board and the DHT22s would be pulling too much power to attempt it with the RPi 5V pin, but I want everything running from the same PSU as I don't want a scenario where the RPi could be on, but the relay board/DHT22s would not be powered and vice verse (like due to a failed PSU where multiple PSUs are being used).

If the 6amp PSU is too large considering my project, what amp PSU should I be targeting?

I appreciate your time! Thanks!
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

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

Re: Advice on project components...

Tue Feb 26, 2019 3:09 pm

ameador1 wrote:
Tue Feb 26, 2019 2:53 pm
Is the "simple transistor buffer" the same as the part that pcmanbob is referencing (ULN2803A)? If so, that does look like that would be a cheaper solution than the logic leveler(s). I'm not familiar with that component and will have to look into it further on how to use it.
So a simple transistor buffer would look like this

Image

So you would need a transistor and a resistor for each relay that's 8 in total.

were as the ULN2803A has 8 transistor /resistor circuits within it and you would connect it up like this.

Image

Now most of the relay boards you buy are active low that is you have to send a low signal to turn the relay on , by using the buffer circuit , which ever one you choose to use, you will now have to send a high signal to turn the relay on with is a bit more logical for someone just getting it to electronics.

ULN2803A will cost about £2 on amazon you may find then even cheaper elsewhere.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Tue Feb 26, 2019 3:52 pm

Thanks for the diagram pcmanbob! So the simple transistor resister schematic is what is in this chip x 8 - correct? So, it is using a transistor which is controlled by the GPIO to open/close the input on the relay to ground - which is what actually triggers the relay on - correct?

From Q&A on Amazon - it looks like this relay board is active low - but I will post the question to see if I get a clear answer from the seller. So this has me a little confused now. So, if this is correct - the relay needs an input grounded to turn on that relay. If this is the case, what is the issue of 3.3V being supplied to the relay input? If the relay is normally off, and it is turned on by grounding - I don't understand what either 3.3V or 5V going to a relay input pin has to do with anything. I guess my question is - do I need to use a logic leveler - or other means to try to bump up the voltage to 5V that is going to the inputs on the relay board? If so, then this logic leveler would go between the ULN2803 and the relay board - correct?
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

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

Re: Advice on project components...

Tue Feb 26, 2019 4:21 pm

ameador1 wrote:
Tue Feb 26, 2019 3:52 pm
Thanks for the diagram pcmanbob! So the simple transistor resister schematic is what is in this chip x 8 - correct? So, it is using a transistor which is controlled by the GPIO to open/close the input on the relay to ground - which is what actually triggers the relay on - correct?
There is actually 2 transistors, several resistors and a diode in each circuit in the chip, but it basically does the same as the resistor /transistor it switches a ground on and off.
From Q&A on Amazon - it looks like this relay board is active low - but I will post the question to see if I get a clear answer from the seller. So this has me a little confused now. So, if this is correct - the relay needs an input grounded to turn on that relay. If this is the case, what is the issue of 3.3V being supplied to the relay input? If the relay is normally off, and it is turned on by grounding - I don't understand what either 3.3V or 5V going to a relay input pin has to do with anything. I guess my question is - do I need to use a logic leveler - or other means to try to bump up the voltage to 5V that is going to the inputs on the relay board? If so, then this logic leveler would go between the ULN2803 and the relay board - correct?
So the problem is the relay board is designed to work with 5v feeding the opto isolator LED and resistor this is the grounded via the IN pin for each relay, so applying a low to the IN pin turn the relay on active low, but to turn the relay off you have to apply 5V to the IN pin so no current flows, but the pi only has 3.3v gpio and 3.3v will allow just enough current to flow to keep the relay on.

There is a detailed explanation and diagram here : https://www.raspberrypi.org/forums/view ... 8#p1225448

You don't need anything other than the ULN2803A or 8 x resistor/transistor buffer circuits, because you feed the relay circuit with 5V and you use the pi gpio to switch the ground for each relay circuit.

I do suggest you use a separate 5v supply to power the relay board as shown in the diagram I posted, as switching relays on and off can cause voltage dips and the pi will not like that.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Tue Feb 26, 2019 5:09 pm

Ok, pcmanbob, I think I get this. On your diagram, the External 5v PSU is connecting 5V to Vcc and Vcc-JD. Vcc-JD is powering the coils of the relays - good! Is the 5V powering the Vcc providing 5V to all the opto isolator LEDs and resistors - thus keeping the relays off?

If so, then when, for example GPIO24 is activated, this powers ULN2803A(U) in U.In1 with 3.3V - which in turn sets U.Out1 to ground - which grounds Relay(R) R.In1 to ground - turning relay 1 on? If Vcc is being supplied 5V - does this mean that 5V is coming in on U.Out1 then? Is that simply being directed to U.GND - which is tied to the RPi 5v ground - and not allowing the 5V from Vcc to come back to GPIO24?

If this example effectively connects R.In1 (Vcc 5V from External PSU) to RPi.Gnd (pin 39) then I see the 5V pathway and how the relay has everything powered properly. Does this pose any issue when the 5V PSU (via Vcc) is connected to ground of a different 5V PSU that is feeding the RPi? Would this create a requirement to use 2 PSU with the same amp rating? Like, say a 2.5amp 5V PSU for the RPi and another 2.5amp 5V PSU for the relay? So that I don't have an imbalance of a stronger 5V+ PSU connecting to the ground of a lower amp 5V PSU. Or am I not understanding something here? I read the link you provided earlier - sticky#25 - but I guess I didn't see how it addressed the issue I asked about. But I think I see it now - if my understanding now is correct - as the 5V on Vcc is feeding the R.In connectors (keeping the relays off) - and the RPi is only being used to ground them (turning the relays on) in your design.

I could possibly run the 4 DHT22s on the same PSU as the RPi - at least this way, I could monitor the temps and if the relays were down due to failed PSU - I would pick this up in out of bounds temp readings. I am trying to set this up to control multiple pathways of fans on a small data center to utilize and/or disperse the generated heat - but need to know if there is a failure that would cause the servers to overheat so that my device could potentially power them down, notify me, or something.
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

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

Re: Advice on project components...

Wed Feb 27, 2019 9:06 am

As the voltage/current in a circuit always wants to return to the point it came from the current in the 3.3v circuit will flow from the pi gpio pin in to the ULN2803A turning on the transistor then pass out of the chip on the ground pin returning to the pi via the ground,

The current in the 5v circuit will flow from the relay board through the ULN2803A ( because transistor is now on ) out of the chip on the ground and back to the relay board via the ground. the 3.3v and 5v circuits are are only connected at the ground which is effectively at zero volts so the pi is safe.

You don't need to use matched power supplies because each is only supplying its part of the circuit, you could if your project required it use power supplies of different voltages and the pi would still be safe. You are effectively doing this any way as the pi part of the circuit is 3.3v and the relay part of the circuit is 5v.

Running 4 DHT22s from the pi power supply will be fine as they only draw a vey small current, always presuming you are using the correct power supply for the pi that can supply 5v at 2.5A
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
ameador1
Posts: 89
Joined: Fri Feb 22, 2019 5:43 pm
Location: Eastern - USA

Re: Advice on project components...

Wed Feb 27, 2019 12:14 pm

Thanks pcmanbob for your help and explanations!
"When money ceases to be the tool by which men deal with one another, then men become the tools of men. Blood, whips and guns–or dollars. Take your choice–there is no other..."
- Ayn Rand - Atlas Shrugged

Return to “Advanced users”