Page 1 of 1

Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 01:28
by jr_esp
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

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 01:50
by grovkillen
What is the current needed for driving the whole setup? Could it be a too small 5V power supply?

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 02:44
by jr_esp
What is the current needed for driving the whole setup? Could it be a too small 5V power supply?
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.

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 08:15
by grovkillen
Just try something with more amps.

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 11:06
by TD-er
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?

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 11:34
by jr_esp
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.
.

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 14:44
by TD-er
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.

Re: Issue with PCF8574 & Relays

Posted: 23 Sep 2019, 19:17
by rudloffl
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

Re: Issue with PCF8574 & Relays

Posted: 24 Sep 2019, 01:33
by budman1758
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

Posted: 24 Sep 2019, 08:45
by jr_esp
rudloffl wrote: 23 Sep 2019, 19:17 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
The 8 channel relay boards are powered directly from the power supply i believe.

Re: Issue with PCF8574 & Relays

Posted: 24 Sep 2019, 08:46
by jr_esp
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.
Good question, will need to check !

Re: Issue with PCF8574 & Relays

Posted: 24 Sep 2019, 11:33
by jr_esp
jr_esp wrote: 24 Sep 2019, 08:46
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.
Good question, will need 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

Posted: 25 Sep 2019, 17:32
by ThomasB
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

Re: Issue with PCF8574 & Relays

Posted: 26 Sep 2019, 04:40
by rudloffl
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
jr_esp wrote: 24 Sep 2019, 08:45
rudloffl wrote: 23 Sep 2019, 19:17 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
The 8 channel relay boards are powered directly from the power supply i believe.

Re: Issue with PCF8574 & Relays

Posted: 26 Sep 2019, 07:53
by jr_esp
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
Hi 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

Posted: 26 Sep 2019, 10:44
by TD-er
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.
I think in the end you will destroy the GPIO pins of the ESP if a missing flyback diode is the real cause.
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.
Image

Re: Issue with PCF8574 & Relays

Posted: 26 Sep 2019, 11:44
by jr_esp
Look like the relay board already has a diode across each relay. Is it possible the pcf8574 is just more sensitive ?

Re: Issue with PCF8574 & Relays

Posted: 26 Sep 2019, 15:39
by dynamicdave
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 !!!!

Re: Issue with PCF8574 & Relays

Posted: 27 Sep 2019, 08:33
by Shardan
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:
.
GroundPoint.jpg
GroundPoint.jpg (42.4 KiB) Viewed 20942 times
.
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.

Re: Issue with PCF8574 & Relays

Posted: 27 Sep 2019, 11:16
by TD-er
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 !!!!
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.
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

Posted: 01 Jun 2022, 16:29
by anudeep
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