Issue with PCF8574 & Relays
Moderators: grovkillen, Stuntteam, TD-er
Issue with PCF8574 & Relays
Hi,
Long time espeasy user, but have run into the first problem i need some help with. I have just added a PCF8574 board to my Wemos D1 Mini to enable me to drive more relays for my irrigation system. Everything seems to work as expected, i can turn each relay on/off etc, but ONLY when there is no load connected to the relay. For any relay which has a load (In my case a 24V irrigation solenoid, connected to the NO contact of the relay) the relay (And Solenoid) turns on fine, in fact i can turn on multiple relays without issue. But when i turn a relay with a load connected OFF, then all the relays turn off.
Any idea what is happening or how i can trouble shoot ?
I am using a 5V power supply for the Wemos/PCF8574/Relay board and a separate 24V supply to drive the irrigation solenoids.
If i drive the relay board directly from GPIO on the Wemos, then everything works as expected, but obviously i can't connect all 8 relays to a single Wemos.
Details on what i'm running:
Espeasy Firmware: mega-20190830
8 Channel relay board: https://www.amazon.com.au/Elegoo-Channe ... 298&sr=8-1
PCF8574 board: (https://www.waveshare.com/pcf8574-io-ex ... -board.htm) - Connected to GPIO-2, GPI0-5 & VCC3.3
Thanks,
Joseph
Long time espeasy user, but have run into the first problem i need some help with. I have just added a PCF8574 board to my Wemos D1 Mini to enable me to drive more relays for my irrigation system. Everything seems to work as expected, i can turn each relay on/off etc, but ONLY when there is no load connected to the relay. For any relay which has a load (In my case a 24V irrigation solenoid, connected to the NO contact of the relay) the relay (And Solenoid) turns on fine, in fact i can turn on multiple relays without issue. But when i turn a relay with a load connected OFF, then all the relays turn off.
Any idea what is happening or how i can trouble shoot ?
I am using a 5V power supply for the Wemos/PCF8574/Relay board and a separate 24V supply to drive the irrigation solenoids.
If i drive the relay board directly from GPIO on the Wemos, then everything works as expected, but obviously i can't connect all 8 relays to a single Wemos.
Details on what i'm running:
Espeasy Firmware: mega-20190830
8 Channel relay board: https://www.amazon.com.au/Elegoo-Channe ... 298&sr=8-1
PCF8574 board: (https://www.waveshare.com/pcf8574-io-ex ... -board.htm) - Connected to GPIO-2, GPI0-5 & VCC3.3
Thanks,
Joseph
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Issue with PCF8574 & Relays
What is the current needed for driving the whole setup? Could it be a too small 5V power supply?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Issue with PCF8574 & Relays
Not sure, most of my 5V supplies are 1amp. I might swap the supply out just to be sure. I have already swapped out the PCF8574 & relay boards.What is the current needed for driving the whole setup? Could it be a too small 5V power supply?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Issue with PCF8574 & Relays
Just try something with more amps.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Issue with PCF8574 & Relays
How is the load connected to the ESP board?
For example do they share some common ground or is the load and the ESP completely separated?
Can you check if the ESP reboots when you turn it off with a load connected?
For example do they share some common ground or is the load and the ESP completely separated?
Can you check if the ESP reboots when you turn it off with a load connected?
Re: Issue with PCF8574 & Relays
Hi,
Yes loads are completly isolated. I have uploaded a picture.
The esp does not reboot when all the relays go off.
Just changed out the supply with a new one at 1.5 amps & also tried powering the pcf8574 direct from 5v without luck.
.
Yes loads are completly isolated. I have uploaded a picture.
The esp does not reboot when all the relays go off.
Just changed out the supply with a new one at 1.5 amps & also tried powering the pcf8574 direct from 5v without luck.
.
- Attachments
-
- Screenshot_20190923-192447_Gallery.jpg (1.01 MiB) Viewed 22512 times
Re: Issue with PCF8574 & Relays
I think someone with a bit more experience with these GPIO expanders may understand what's going on here.
I'm a bit out of ideas right now.
I'm a bit out of ideas right now.
Re: Issue with PCF8574 & Relays
Are you powering the relays from the PCF8574 or are you using the JD-VCC on the relay board ?
I took off the jumper and power the relay directly
I took off the jumper and power the relay directly
- budman1758
- Normal user
- Posts: 301
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Issue with PCF8574 & Relays
Do the relays need a ground signal or a positive signal to actuate? The PCF8574 can deliver way more current with a ground signal than a positive signal.
This may or may not be the problem but something to check.
This may or may not be the problem but something to check.
"The glass is twice as big as it needs to be".
Re: Issue with PCF8574 & Relays
Good question, will need to check !budman1758 wrote: ↑24 Sep 2019, 01:33 Do the relays need a ground signal or a positive signal to actuate? The PCF8574 can deliver way more current with a ground signal than a positive signal.
This may or may not be the problem but something to check.
Re: Issue with PCF8574 & Relays
jr_esp wrote: ↑24 Sep 2019, 08:46Good question, will need to check !budman1758 wrote: ↑24 Sep 2019, 01:33 Do the relays need a ground signal or a positive signal to actuate? The PCF8574 can deliver way more current with a ground signal than a positive signal.
This may or may not be the problem but something to check.
Just confirmed it's a ground signal to activate the relays. Also swapped out the wemos without luck.
Re: Issue with PCF8574 & Relays
The problem only occurs when turning off a powered solenoid (both relay and solenoid de-energize), but does not occur when solenoids are disconnected (only relay de-energizes). If that is the conditions then I would say the PCF8574 is being reset due to the solenoid's EMF inductive "kick" voltage.
Typically you would install a diode across the solenoid power leads. Plus a snubber network across it too. Check this: https://www.embedded.com/electronics-bl ... nd-snubber
But sometimes it takes more effort since the EMF voltage can be significant and radiate into all the circuitry. Things like board layout, cap bypassing, wire routing, wire length, and so on, would need to be addressed in hardship cases.
- Thomas
Typically you would install a diode across the solenoid power leads. Plus a snubber network across it too. Check this: https://www.embedded.com/electronics-bl ... nd-snubber
But sometimes it takes more effort since the EMF voltage can be significant and radiate into all the circuitry. Things like board layout, cap bypassing, wire routing, wire length, and so on, would need to be addressed in hardship cases.
- Thomas
Re: Issue with PCF8574 & Relays
did you use that scheamtic https://www.letscontrolit.com/wiki/index.php/Relais ?
The PCF is powered via 3.3 but the relay board is powered via with 5V VCC/JD
The PCF is powered via 3.3 but the relay board is powered via with 5V VCC/JD
Re: Issue with PCF8574 & Relays
Hi Thomas,ThomasB wrote: ↑25 Sep 2019, 17:32 The problem only occurs when turning off a powered solenoid (both relay and solenoid de-energize), but does not occur when solenoids are disconnected (only relay de-energizes). If that is the conditions then I would say the PCF8574 is being reset due to the solenoid's EMF inductive "kick" voltage.
Typically you would install a diode across the solenoid power leads. Plus a snubber network across it too. Check this: https://www.embedded.com/electronics-bl ... nd-snubber
But sometimes it takes more effort since the EMF voltage can be significant and radiate into all the circuitry. Things like board layout, cap bypassing, wire routing, wire length, and so on, would need to be addressed in hardship cases.
- Thomas
I think this is my problem ! I'm driving an inductive load so after a single relay is switched off there is a voltage kick/spike which is somehow forcing all the other relays off.
I'm not sure why this only affects the PCF8574 ie no issues when running the relay direct from a GPIO of the wemos.
I will need to research using a "Flyback Diode", but i think it may just be easier to add some more Wemos modules to run the relays.
Joseph
Re: Issue with PCF8574 & Relays
I think in the end you will destroy the GPIO pins of the ESP if a missing flyback diode is the real cause.I'm not sure why this only affects the PCF8574 ie no issues when running the relay direct from a GPIO of the wemos.
I will need to research using a "Flyback Diode", but i think it may just be easier to add some more Wemos modules to run the relays.
These inductive spikes can really be destructive for the chips connected to it.
And it isn't that hard to add a diode per relay.
Re: Issue with PCF8574 & Relays
Look like the relay board already has a diode across each relay. Is it possible the pcf8574 is just more sensitive ?
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Issue with PCF8574 & Relays
Where did the schematic diagram, shown above, come from???
It looks to me (the way it is wired) as if the relay contact will short-out the relay coil and destroy the transistor/FET !!!!
It looks to me (the way it is wired) as if the relay contact will short-out the relay coil and destroy the transistor/FET !!!!
Re: Issue with PCF8574 & Relays
These 8-Relay-boards have a diode in parallel to the relay coil. It's easily visible on the PCB next to the relay.
If this diode wouldn't exist the transistor switching the coil just would blow at first power-off of the relay coil.
A problem might be caused by the ground connections.
Even using optocouplers the board is not galvanically decoupled. Relay ground and input ground are conneced on the PCB,
only the power supply input (5V for relay, 5V for input) can be split or connected via jumper.
This is a construct that can cause a lot of problems. If some current goes over these thin jumper cables
you might get "pseudo grounding" - GND on one board gets a voltage difference to GND of another board.
The results are very strange.....
I'd suggest to abandon the usual jumper cables for ground connection.
Use speaker cable (0,5...0,75mm²). Put a cable on every ground pin (PCF boards, relay boards, ESP boards).
The other end of the cables should be connected together to one single "ground point". Connect the power supplies GND to this
single ground point too.
A quick and dirty drawing shows the GND circuit:
. .
This leads to a better grounding.
Another point: I'M not sure if 3,3V is enough for driving the opto coupler circuit.
It might be necessary to use a level shifter from ESP to the PCF's a nd use 5V with the PCF boards.
All these are workarounds at last.
In any way it would be better to design a PCB for this purpose.
If this diode wouldn't exist the transistor switching the coil just would blow at first power-off of the relay coil.
A problem might be caused by the ground connections.
Even using optocouplers the board is not galvanically decoupled. Relay ground and input ground are conneced on the PCB,
only the power supply input (5V for relay, 5V for input) can be split or connected via jumper.
This is a construct that can cause a lot of problems. If some current goes over these thin jumper cables
you might get "pseudo grounding" - GND on one board gets a voltage difference to GND of another board.
The results are very strange.....
I'd suggest to abandon the usual jumper cables for ground connection.
Use speaker cable (0,5...0,75mm²). Put a cable on every ground pin (PCF boards, relay boards, ESP boards).
The other end of the cables should be connected together to one single "ground point". Connect the power supplies GND to this
single ground point too.
A quick and dirty drawing shows the GND circuit:
. .
This leads to a better grounding.
Another point: I'M not sure if 3,3V is enough for driving the opto coupler circuit.
It might be necessary to use a level shifter from ESP to the PCF's a nd use 5V with the PCF boards.
All these are workarounds at last.
In any way it would be better to design a PCB for this purpose.
Regards
Shardan
Shardan
Re: Issue with PCF8574 & Relays
If you refer to the schematic I posted, it was just one of the first images Google showed me when looking for diode and relais.dynamicdave wrote: ↑26 Sep 2019, 15:39 Where did the schematic diagram, shown above, come from???
It looks to me (the way it is wired) as if the relay contact will short-out the relay coil and destroy the transistor/FET !!!!
It was just meant as an illustration on how this diode should be wired.
But it looks now like an image needs a 1000 words to explain it
Re: Issue with PCF8574 & Relays
Hi all I'm also having same issue and I'm also controlling 24V solenoids with ESP32 through PCF8574T only. Just ike you when no load is connected relays are working fine when load(solenoid valve) connected same issue. please let e know solution you've got did it worked....? I'm also struggling... don't know what to do... please help me
Thanks in advance
Thanks in advance
Who is online
Users browsing this forum: No registered users and 4 guests