IOT-MCU / ESP-01S-Relay-v4.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Relay flickers on boot

boshkash1151 opened this issue · comments

During boot the relay turns on then off then on again.

any help would be much appreciated

I'm having the same problem!

@boshkash1151 see this issue
nodemcu/nodemcu-firmware#421

Yeap, me too.

Adding a capacitor between the gpio and ground made this go away

around 470uf is enough? will try, thanks.

Even a 47uF would work

i try with 47uf and 300uf with no result in gpio0 and ground.
Investigating a bit, the pin0 seems to start at low and im assuming that the relay also start at low.
i try to connect the capacitor to 3.3v and gpio0 to start it at high but didnt work either.
Ask for help to a friend, he will try to make a pullup resistor at gpio 0 on start.

Which version of the board do you have

didnt work either..weird. something is putting gpio 0 to low on startup. I put it in high at setup and now i have put it to high with a pullup resistor.
relay board : esp-01/01S Relay v4.0 TB:IOTMCU

Resuming:
try to put a capacitator between pin 0 and ground
try to put a capacitator between pin 0 and 3.3v
try to put a 3k3 resistor between pin 0 and 3.3v
:/ running out of ideias.

Same issue... did anyone solve it?

I have module (ESP-01S-Relay-v4.0 ) ,and I solved the problem by adding a capacitor parallel with the LED of the Optocoupler(PC817).
I used 470uF capacitor for better action.
With 330uF it will work good also.
20191207_040423

Confirmed. A 470uF capacitor worked great for me. Thanks!

A less sophisticated approach that has worked well for me ... mechanically change the connection with an "adapter" socket inserting the RX pin into the GPIO0 slot. That way you can used RX (GPIO3) to operate the relay.

I use a couple of the long header pin rows that came with a Wemos D1 mini and cut them in half so that they were 4 pins wide (the remainder will be wasted). Physically remove what might have been GPIO0 pin and bend the RX pin slightly. Hope the pictures explain better than the words.

Relay1

Relay2

commented

Do I understand correctly that the capacitor should be put between pins 3 and 5?

commented

Tested. Didn't solve the issue, then found out I actually have the Relay v1.0 (facepalm)

@Amaktronix method worked for me as well here is a pic of what i did

image

The Green Wire goes to the positive side of a 470uF Capacitor while the Black Wire goes to the negative side of the same capacitor

Also this on v4 module

It took me quite a while, finally got it working without hardware modifications. Flashed the ESP with Tasmota firmware, I had to tinker a bit with the configuration, it works now with the configuration in the picture.
Untitled

I had the same problem with my esp01 (flashed with the latest tasmota firmware) and the cheap Chinese relay board eps-01s v1.0 that uses GPIO0 that flickers the relay on boot, and finally I found a very easy solution that worked! I had already soldered a 10K resistor to Vcc (so that the ESP doesn't boot on bootloader mode on boot) and I soldered another 10K resistor from GPIO0 to GND and magically the ESP boots ok and the relay doesn't flickers! Tried a lot of times with success every time. If someone has the same problem please try my solution to see if it works for you also.

commented

Arismane, sorry for my (lack of) understanding of basic electricity, but doesn't this give you Vcc connected to GND via 20K ohm resistance? I'm afraid of heat dissipation, etc. Also, could you please share some visualization?

Arismane, sorry for my (lack of) understanding of basic electricity, but doesn't this give you Vcc connected to GND via 20K ohm resistance? I'm afraid of heat dissipation, etc. Also, could you please share some visualization?

ddppddpp, it is not exactly like a 20k resistance from vcc to gnd, it is more something like a voltage divider due to the fact that the connection point of the two resistors is connected to GPIO0. But fyi the power consumption is the same with no resistors connected at all. The best of all is that it works! :) I am going to upload a picture in a few hours.

commented

Arismane, I tried to replicate what you suggested, unfortunately with no success.
Please have a look at the setup below:

IMG_0454
Brown/Black wire soldered to the back of GPIO-0 and via 10K resistors to +5V and GND.
Again, there's the dreaded CLICK on power-up :-(
Should I try and solder it to the relay isntead?

Arismane, I tried to replicate what you suggested, unfortunately with no success.
Please have a look at the setup below:

IMG_0454
Brown/Black wire soldered to the back of GPIO-0 and via 10K resistors to +5V and GND.
Again, there's the dreaded CLICK on power-up :-(
Should I try and solder it to the relay isntead?

My friend I think your setup is the same with mine that works for me. What version is your relay board? It writes it below the PCB. Have you configured your ESP not to remember the last state of the relay output on power up?

It took me quite a while, finally got it working without hardware modifications. Flashed the ESP with Tasmota firmware, I had to tinker a bit with the configuration, it works now with the configuration in the picture.
Untitled

This works fine! My steps before reaching this screen:

  1. At the main menu, click configuration
  2. At Generic Module screen, Click configure module
  3. At the module type drop down, select Generic (18)
  4. Click Save
  5. Repeat step 2.
  6. Change first option D3 GPIO0 Button1 to Relay1i (29).

Done!

My solution is to put 5uf capacitor (can be less) between GPIO0 from ESP8266 and the PIC817.
I've tested on bread board with 2x10uF series = 5uF. (i only have 10uF around)
6.6uF is

This eliminate the flick at boot of relay about 3hz or 1/3s
(create Low Pass filter) (flick is about 3hz) so keep in mind if your program need to flick relay at higher speed this will not work.

For module v.4 (i have this model to test with)

  1. The GPIO0 has Pull-up resistor 10k ohm to it.
  2. the PC817 and Relay are trigger when GPIO0 set to Low.
    (so the Pin2 of PC817 is change from about 3v to 0v in the schematic)

From 1 and 2 this act as voltage divider with 10k ohm Resistor and 0Resistor. (turn 3.3v to 0v). So I look-up and learn that if i replace 0Resistor with Capacitor. it became low pass filter.
http://www.learningaboutelectronics.com/Articles/Low-pass-filter-calculator.php#answer1

I'm open for suggestion on how to put 5uF on though. Maybe I can solder it from Pin2 of PC817 and GPIO0 Pin

Adding 470uf capacitor worked for me. Thanks.
20200825_211406

@kbho3009 Can you confirm your solution with Tasmota is still working? How long have you been using it with Tasmota? I would like to use this as a cheap solution to activate a garage door opener, if this is still an issue it would be a security concern for sure.

@amitofile Is your solution still working as well? What software are you running on yours?

I had the same problem with my esp01 (flashed with the latest tasmota firmware) and the cheap Chinese relay board eps-01s v1.0 that uses GPIO0 that flickers the relay on boot, and finally I found a very easy solution that worked! I had already soldered a 10K resistor to Vcc (so that the ESP doesn't boot on bootloader mode on boot) and I soldered another 10K resistor from GPIO0 to GND and magically the ESP boots ok and the relay doesn't flickers! Tried a lot of times with success every time. If someone has the same problem please try my solution to see if it works for you also.

Thank you! I was having the same problem with that same board. After soldering a 10k resistor between GPIO0 and GND it stopped flickering after a reboot.

@kbho3009 Can you confirm your solution with Tasmota is still working? How long have you been using it with Tasmota? I would like to use this as a cheap solution to activate a garage door opener, if this is still an issue it would be a security concern for sure.

@amitofile Is your solution still working as well? What software are you running on yours?

Yup, mine work but integration to automation apps is quite a bit of setup. I've only used it on a switch where it is harder to reach.

The capacitor in parallel with the optocoupler proposed by @Amaktronix also worked for me. Thank you!

Does anybody know if there's a software-only fix for ESPHome?

I've tried restore_mode: ALWAYS_OFF on an inverted pin.

Does anybody know exactly what the Tasmota Relay1 / Relay1i is doing at boot that's so special?

I used @blynkuser 's suggestion for GPIO3 with an easy exacto knife jump and cut. Note that the relay will click a few times when reprogramming.
image
image

I have module (ESP-01S-Relay-v4.0 ) ,and I solved the problem by adding a capacitor parallel with the LED of the Optocoupler(PC817).
I used 470uF capacitor for better action.
With 330uF it will work good also.
20191207_040423

It works for me using a 220uF instead of 470, using Tasmota 9.3.1

Unfortunately this solution not worked for me, Its still flickering, I am using it with a door lock and when its reboot it turn on the lock. :(. I have solded a 470uF capacitor with Optocoupler. While I am using a blynk sketch.
in which in setup I did the following pinMode(0, OUTPUT); digitalWrite(0, HIGH);

I also tried digitalWrite(0, LOW), but in both cases result is same.

Any suggestion?

I'm using gpio3 and it's good to work
144222863-7ea81cd9-b707-440b-812d-576d925d3c67

144222836-f9399dcf-fe91-49c6-8c81-28013f94c46f

Hi did not understad all the scenario ! gpıo0 is on boot high and gpio 2 is on boot low I think.we use GPIO0 and must use a capasitor to get a latency while reaching to power on the esp.If this first part is ok then I will explain my idea about the situation.
The second part is the esp01 relay module v4 is a negative triggered relay module.when I trigger the esp and iphone says the switch is on the otuput of esp is 3.3 volts.but the relay is off now.When I turn off the switch esp is low state and 0 volt but the relay module is on and the led is on alo.the esp and relay word opposite.Dot advice to use the nc sşde of relay please.this is wrong. we must change te triggerins state from negative to positive.The module must become a positive triggered module. Do you have an idea how to convert to positive triggerd module ? hakan.gucyetmez@hotmail.com

It works fine, I programmed to turn on and off using GPIO3...
And I removed the iron inside of yellow connector, and soldered gpio3 on gpio0 pin, image bellow

6fd5660b-a4ce-4185-9bff-e611ea3d1122
f4e0c6c8-3c75-48e6-8d17-84604078cee0

Thanks :)

I had no end of problems with using the V1 module and eventually found that just about everyone else did. After failing with various soldering hacks, I switched to v4 with a 8266-01-EX programmed on Arduino IDE, using a USB interface with a push button for programming mode. The pin for the signal is GPIO0.
Although it's relatively simple to use Dupont wires and a breadboard to set the 8266 into programming mode, it's fiddly and time-consuming. The USB programming modules without programming mode switches are worse than useless. Don't even bother with trying to solder a fix, because life's way too short for that.

I think using RX pin (GPIO3) works great if you do the clever solderless mod (credit to blynkuser !), but if you are going to wield the soldering iron, GPIO2 seems a better choice, as it leaves the RX pin available for communications if needed...

I had intermittent relay operation, this is because it is a 5V relay connected to 3V3 supply rail. To fix this, I removed D1 (LL4158) and cut the 3V3 supply track to the relay coil (the one that runs almost central between the relay pins) on the back of the board. A wire link from the now unattached relay pin to the VCC input pin connects the relay coil to the 5V input. Add the diode back onto the relay coil.
You MUST remove D1 from the board, else it back feeds 5V into the 3V3 rail!
You must add a diode back across the relay coil or the back EMF will destroy the FET - I re-used the one off the board, but a leaded part like 1N4148 is less fiddly.

(I don't think anyone mentioned that GPIO0 is used as boot-load selector, so is not under program control for a short time at power up, hence the glitch. It would have been simple to design the circuit to cope with that, and eliminate the opto-coupler and a transistor, but the board is what it is...)

Photo shows D1 moved to the relay coil, and GPIO2 connected..
2022-06-19 09 18 29

With the relay coil mod, the board will run happily at 6 Vdc.

I think using RX pin (GPIO3) works great if you do the clever solderless mod (credit to blynkuser !), but if you are going to wield the soldering iron, GPIO2 seems a better choice, as it leaves the RX pin available for communications if needed...

I had intermittent relay operation, this is because it is a 5V relay connected to 3V3 supply rail. To fix this, I removed D1 (LL4158) and cut the 3V3 supply track to the relay coil (the one that runs almost central between the relay pins) on the back of the board. A wire link from the now unattached relay pin to the VCC input pin connects the relay coil to the 5V input. Add the diode back onto the relay coil. You MUST remove D1 from the board, else it back feeds 5V into the 3V3 rail! You must add a diode back across the relay coil or the back EMF will destroy the FET - I re-used the one off the board, but a leaded part like 1N4148 is less fiddly.

(I don't think anyone mentioned that GPIO0 is used as boot-load selector, so is not under program control for a short time at power up, hence the glitch. It would have been simple to design the circuit to cope with that, and eliminate the opto-coupler and a transistor, but the board is what it is...)

Photo shows D1 moved to the relay coil, and GPIO2 connected.. 2022-06-19 09 18 29

With the relay coil mod, the board will run happily at 6 Vdc.

Hi @f1andy, I followed the description of your modification and it worked so far, so the relay is triggered by GPIO2 now. However, I still get a flicker on boot, this time it sounds like it switches two times. As the builtin led is also connected to IO2, I suspect some status signaling in the software is causing this, I am using a mostly empty esphome configuration with wifi and the relay switch components.
Did you do anything special in the Firmware regarding this setup?

well, allthough the problem is rather old I just faced it today and as my first tries did't work to solve I came to this threat, which at the first point didn't solve my issue as well. After thinking a little bit about it: adding a capacitor of >200µF (initially worked with 100uF but turned to be not stable) and in parallel a resistor of ~1k (for discharging the capacitor) solved it for m
PXL_20220727_134417205_2 - Kopie
e

I am using it with esphome. 220uF is working.

I found another way. Have relay module without "big" optocoupler and solution with 2x 10k resistors did not assist as well. I put 470uF capacitor directly to relay and no boot flickers any more. Relay itself working fine. image
image

here is the solution software https://beagloboneback.blogspot.com/2020/12/arduino-al-arrancar-provoca-un-pulso-en.html

can someone tell me if this solution works, and where should i put the script? i'm using esphome to load my config file.

I had the same problem with my esp01 (flashed with the latest tasmota firmware) and the cheap Chinese relay board eps-01s v1.0 that uses GPIO0 that flickers the relay on boot, and finally I found a very easy solution that worked! I had already soldered a 10K resistor to Vcc (so that the ESP doesn't boot on bootloader mode on boot) and I soldered another 10K resistor from GPIO0 to GND and magically the ESP boots ok and the relay doesn't flickers! Tried a lot of times with success every time. If someone has the same problem please try my solution to see if it works for you also.

Thank you! I was having the same problem with that same board. After soldering a 10k resistor between GPIO0 and GND it stopped flickering after a reboot.

Yes after soldering 10K resistance between GPIO 0 and GND stop the flickering at boot time , but RST button now not working , earlier it was triggering relay now it only stopping ESP01S from wifi connection .. ( Using ESP01S V1.0)

I have a v5.0 board, newer? It does the same flicker, anyone know what can be done for the v5.0 board? Odd that they still have not redesigned the board to address the issue.

@phnahes, how did you remove the iron from the female header? Did you just de-solder it and punch it through from the bottom or the board or is there an easier way?

Edit: turns out you can just pull off the plastic case, de-solder/remove that pin, and then put the case back on. Here is an example for a single row female header.

I have module (ESP-01S-Relay-v4.0 ) ,and I solved the problem by adding a capacitor parallel with the LED of the Optocoupler(PC817). I used 470uF capacitor for better action. With 330uF it will work good also. 20191207_040423

It works for me using a 470uF capacitor. Thanks!

PXL_20240310_163639481

Thanks for the photo! And the diagram! So if I understand this, the capacity creates a delay, on initial power up, so the opto-coupler does not fire/emit on power up? It would seem this tweak (if you will) would work for any relay that you bridge via capacitor 3.3v to GPIO 0?

commented

A less sophisticated approach that has worked well for me ... mechanically change the connection with an "adapter" socket inserting the RX pin into the GPIO0 slot. That way you can used RX (GPIO3) to operate the relay.

I use a couple of the long header pin rows that came with a Wemos D1 mini and cut them in half so that they were 4 pins wide (the remainder will be wasted). Physically remove what might have been GPIO0 pin and bend the RX pin slightly. Hope the pictures explain better than the words.

Relay1

Relay2

https://www.aliexpress.com/w/wholesale-2.54mm-double-long-female.html

2x4p

commented

@Amaktronix , would a capacitor over the relay LED also work on the Wemos D1 Mini Relay Shield?

In the schematic I see an LED1 but this is a little SMD LED which makes soldering a capacitor over it a bit hard.

I have this relay on a D1 Mini ESP board and it also switches the relay on (re)boot of the ESP :(

It works fine, I programmed to turn on and off using GPIO3... And I removed the iron inside of yellow connector, and soldered gpio3 on gpio0 pin, image bellow

6fd5660b-a4ce-4185-9bff-e611ea3d1122 f4e0c6c8-3c75-48e6-8d17-84604078cee0

Thanks :)

This is the simple way. Remove yellow plastic and break gpio0 pin, put plastic back and solder RX with gpio0 and use gpio3 in code. I did that and is working. Still initialize at boot but the relay contacts are not making contact.

@Amaktronix , would a capacitor over the relay LED also work on the Wemos D1 Mini Relay Shield?

In the schematic I see an LED1 but this is a little SMD LED which makes soldering a capacitor over it a bit hard.

I have this relay on a D1 Mini ESP board and it also switches the relay on (re)boot of the ESP :(

I can confirm that @blynkuser's method works fine (I have v4.0 IOTMCU) with ESPHOME+HomeAssistant.
Couldn't you do something similar to the Wemos relay board?