Issue with PCF8574 & Relays

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Issue with PCF8574 & Relays

#1 Post by jr_esp » 23 Sep 2019, 01:28

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

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Issue with PCF8574 & Relays

#2 Post by grovkillen » 23 Sep 2019, 01:50

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 :idea: :idea: :idea:

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#3 Post by jr_esp » 23 Sep 2019, 02:44

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.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Issue with PCF8574 & Relays

#4 Post by grovkillen » 23 Sep 2019, 08:15

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 :idea: :idea: :idea:

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Issue with PCF8574 & Relays

#5 Post by TD-er » 23 Sep 2019, 11:06

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?

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#6 Post by jr_esp » 23 Sep 2019, 11:34

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.
.
Attachments
Screenshot_20190923-192447_Gallery.jpg
Screenshot_20190923-192447_Gallery.jpg (1.01 MiB) Viewed 20638 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Issue with PCF8574 & Relays

#7 Post by TD-er » 23 Sep 2019, 14:44

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.

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: Issue with PCF8574 & Relays

#8 Post by rudloffl » 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

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Issue with PCF8574 & Relays

#9 Post by budman1758 » 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.
"The glass is twice as big as it needs to be".

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#10 Post by jr_esp » 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.

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#11 Post by jr_esp » 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 !

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#12 Post by jr_esp » 24 Sep 2019, 11:33

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.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Issue with PCF8574 & Relays

#13 Post by ThomasB » 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

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: Issue with PCF8574 & Relays

#14 Post by rudloffl » 26 Sep 2019, 04:40

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.

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#15 Post by jr_esp » 26 Sep 2019, 07:53

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

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Issue with PCF8574 & Relays

#16 Post by TD-er » 26 Sep 2019, 10:44

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

jr_esp
New user
Posts: 8
Joined: 23 Sep 2019, 00:59

Re: Issue with PCF8574 & Relays

#17 Post by jr_esp » 26 Sep 2019, 11:44

Look like the relay board already has a diode across each relay. Is it possible the pcf8574 is just more sensitive ?

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Issue with PCF8574 & Relays

#18 Post by dynamicdave » 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 !!!!

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Issue with PCF8574 & Relays

#19 Post by Shardan » 27 Sep 2019, 08:33

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 20373 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.
Regards
Shardan

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Issue with PCF8574 & Relays

#20 Post by TD-er » 27 Sep 2019, 11:16

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 ;)

anudeep
New user
Posts: 1
Joined: 01 Jun 2022, 16:20

Re: Issue with PCF8574 & Relays

#21 Post by anudeep » 01 Jun 2022, 16:29

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

Post Reply

Who is online

Users browsing this forum: Jieffe and 28 guests