automatic switching of the GPIO

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

automatic switching of the GPIO

#1 Post by ssd » 14 Oct 2020, 13:26

Hello,

I have implemented a 4 relay circuit using ESPeasy and domoticz at my home and it's been 2 months now!! But nowadays relay connected to GPIO 4 switches off randomly without any reason. I checked the log but the connection between ESP and raspberry pi is active but still, the relay switches off. Can someone help me with this issue?

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: automatic switching of the GPIO

#2 Post by Ath » 14 Oct 2020, 13:48

Is your relay input 5V or 3.3V? It may be that the relay input isn't stable enough at the high level of the ESP (3.3V) if the relay is for 5V.
/Ton (PayPal.me)

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

Re: automatic switching of the GPIO

#3 Post by TD-er » 14 Oct 2020, 14:42

Also make sure you don't have the same IDX active on other nodes. (notorious is using IDX 0 :) )

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: automatic switching of the GPIO

#4 Post by ssd » 15 Oct 2020, 08:21

Ath wrote: 14 Oct 2020, 13:48 Is your relay input 5V or 3.3V? It may be that the relay input isn't stable enough at the high level of the ESP (3.3V) if the relay is for 5V.
But ESP8266 has no provision of 5V on its GPIO so we are bound to use 3.3V. And on checking using multimeter the input to the relay is 3.12 V and another relay switches at the same voltage.
So it is really tough to understand the issue

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: automatic switching of the GPIO

#5 Post by ssd » 15 Oct 2020, 08:22

TD-er wrote: 14 Oct 2020, 14:42 Also make sure you don't have the same IDX active on other nodes. (notorious is using IDX 0 :) )
No, the index is not the same. ESP8266 or raspberry pi cannot handle the load over a period of time, is that an issue?

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: automatic switching of the GPIO

#6 Post by Ath » 15 Oct 2020, 09:12

ssd wrote: 15 Oct 2020, 08:21 But ESP8266 has no provision of 5V on its GPIO so we are bound to use 3.3V. And on checking using multimeter the input to the relay is 3.12 V and another relay switches at the same voltage.
Well, you can use a level converter for that (a transistor and a few resistors can make you one). 3.12V is just around the borders of acceptable for a high input signal, so, some will work and sometimes it will work, but it most likely it's unstable, as you have found out.
Can you confirm that it is indeed a 5V high-active relay? A standard ESP port can only deliver up to around 25 mA, so that may be a bit low to directly activate a relay, but should be enough for a relay-board to switch. And relay-boards usually are 3.3V compatible.
/Ton (PayPal.me)

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: automatic switching of the GPIO

#7 Post by ssd » 15 Oct 2020, 10:40

Ath wrote: 15 Oct 2020, 09:12
ssd wrote: 15 Oct 2020, 08:21 But ESP8266 has no provision of 5V on its GPIO so we are bound to use 3.3V. And on checking using multimeter the input to the relay is 3.12 V and another relay switches at the same voltage.
Well, you can use a level converter for that (a transistor and a few resistors can make you one). 3.12V is just around the borders of acceptable for a high input signal, so, some will work and sometimes it will work, but it most likely it's unstable, as you have found out.
Can you confirm that it is indeed a 5V high-active relay? A standard ESP port can only deliver up to around 25 mA, so that may be a bit low to directly activate a relay, but should be enough for a relay-board to switch. And relay-boards usually are 3.3V compatible.
The relay is a 5v active relay. but all the 3 relays are the same and others are operating efficiently

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

Re: automatic switching of the GPIO

#8 Post by TD-er » 15 Oct 2020, 12:46

ssd wrote: 15 Oct 2020, 10:40 [...]
The relay is a 5v active relay. but all the 3 relays are the same and others are operating efficiently
That's what Ton suggested... With a lower than usual driving level the tolerances of parts may have a lot more effect.

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: automatic switching of the GPIO

#9 Post by ssd » 15 Oct 2020, 12:48

TD-er wrote: 15 Oct 2020, 12:46
ssd wrote: 15 Oct 2020, 10:40 [...]
The relay is a 5v active relay. but all the 3 relays are the same and others are operating efficiently
That's what Ton suggested... With a lower than usual driving level the tolerances of parts may have a lot more effect.
So i should use level converter in between ESP and relay. Am I right?

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

Re: automatic switching of the GPIO

#10 Post by TD-er » 15 Oct 2020, 13:54

Yes, or simply a transistor to switch the relay.
This transistor can be your level converter.

Something like this:
Image

This schematic assumes your relay to be connected with one pin to the higher voltage (e.g. 5V rail) and you connect them to GND via the transistor.

The diode is meant to protect the transistor when the relay is released (no more current through the coil)

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: automatic switching of the GPIO

#11 Post by ssd » 17 Oct 2020, 08:09

Thanks, everyone!!! Using 5V worked perfectly for me!

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

Re: automatic switching of the GPIO

#12 Post by TD-er » 17 Oct 2020, 09:35

Good to hear.
Thanks for the update

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 33 guests