Relay is able to turn ON but get stuck at OFF

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
stin88
Normal user
Posts: 5
Joined: 29 Jul 2019, 18:36

Relay is able to turn ON but get stuck at OFF

#1 Post by stin88 » 08 Aug 2019, 20:50

i manage to turn it ON using this
http://192.168.2.116/control?cmd=GPIO,2,0
and this is the setup
https://robokits.co.in/bmz_cache/3/3d23 ... 66x800.jpg
https://i.imgur.com/kIAoYd9.png
gnd to gnd
vcc to 5v
signal to 10kohm to gpio 2

its like it wont loose the connection, when i manually pull off the signal, everything goes to normal... what can i do? :(

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

Re: Relay is able to turn ON but get stuck at OFF

#2 Post by TD-er » 08 Aug 2019, 21:17

You may want to use another GPIO pin.
GPIO-2 does have pull-up resistors to make the ESP boot into the right mode.
But these pull-up resistors may have an effect on the signal.

See also this table of what pins to use: https://espeasy.readthedocs.io/en/lates ... on-esp8266

What "Vcc" did you connect to 5V?
The Vcc of the ESP, or is in another pin/board?
If you power the ESP directly (without using a voltage regulator) you should power it with 3.3V

Maybe you can make a schematic drawing of how things are connected, since just describing it is a bit hard to follow.
Also how is this 10k resistor connected?

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

Re: Relay is able to turn ON but get stuck at OFF

#3 Post by ThomasB » 08 Aug 2019, 22:04

signal to 10kohm to gpio 2
Ordinarily you would directly connect the relay board's "IN" pin to a 5V TTL compatible I/O pin. The supplier claims that 5mA is needed to actuate the relay. So that would imply that your 10K ohm series resistor is too high a value (3.3V/10000 = 0.3mA).

If the relay board has an internal 5V pull-up resistor on the relay "IN" pin then be cautious with a direct connection since that could damage the 3.3V I/O pin on the ESP board. Therefore, I suggest you temporarily remove the relay IN pin connection and measure the voltage on it. If its bias voltage greatly exceeds 3.3V then additional circuitry may be needed to protect the ESP.

As TD-er mentioned, GPIO2 is a boot configuration pin. If you use it with the relay board then confirm cold and warm booting is reliable.

- Thomas

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

Re: Relay is able to turn ON but get stuck at OFF

#4 Post by Shardan » 09 Aug 2019, 08:33

Relays usually run on 5V or higher.
The ESP runs on 3.3V.

This combination runs into problems under certain circumstances.

As you set GPIO2 to "0"" to set the Relay on it is likely the relay uses
a PNP transistor or maybe an opto coupler

The "emitter" of the PNP transistor goes to 5V, The "base" goes to the ESP via an resistor.

This says here is a small remaining voltage from basis to emmiter of 5V - 3.3V = 1,7V
if the ESP output is set to "1".

Depending of the circuit around the transistor this will result in weird behaviour.
Relay may always trigger or it may trigger once and stay triggered as in your case.

To get over this effect there's a simple solution: USe two Diodes (1N4148 or similar)
like shown here:

https://letscontrolit.com/wiki/index.ph ... th_PNP.jpg

There is a long HowTo about relays and troubleshooting in the Wiki:

https://letscontrolit.com/wiki/index.ph ... cs:_Relays

If the module uses an opto coupler the diodes may take up too much power.
In this case you'll have to use a small NPN transistor like a 2N2222 or BC547.

This is shown in the wiki mentioned above:
https://letscontrolit.com/wiki/index.ph ... lution.jpg
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest