Relay Flickering at Startup

eetech00

Joined Jun 8, 2013
4,705
View attachment 350874
is this the changes you mentioned?
I have tried these but with this my esp does not boot and relay still flicks

also there are no GPIO 3 and GPIO 4 in ESP-01 module only TX RX pins and GPIO 0 and 2
I need TX RX as is to make internet connection and can only utilize GPIO 0 and 2 which needs to be momentary high for boot
Use GPIO2. Use a 2N2907, 2N3906, or 2N4403 PNP transistor.
Disable the MCU's internal weak pullup for GPIO2 so that it floats, then use R2 to pull up Q1 instead.
A ground signal on GPIO2 will energize the relay.

Like this:

1749663079920.png
 

Irving

Joined Jan 30, 2016
5,136
Use GPIO2. Use a 2N2907, 2N3906, or 2N4403 PNP transistor.
Disable the MCU's internal weak pullup for GPIO2 so that it floats, then use R2 to pull up Q1 instead.
A ground signal on GPIO2 will energize the relay.
Are you sure? when GPIO2 is floating its voltage wrt ground will rise to around 3.7v due to the internal clamp diode from GPIO2 to VCC, therefore the base of Q1 will be at (5-3.7)*10k/11k or about 1.18v wrt to the emitter... which may turn Q1 on.. I think you need a diode or two in series with R1 to avoid that possibility.

Notwithstanding that, be sure to write a '1' to GPIO2 before you use pinMode to set it to OUTPUT, else the relay will energise unexpectedly (the default setting of the GPIO2 output latch after reset is 0).
 

eetech00

Joined Jun 8, 2013
4,705
Are you sure? when GPIO2 is floating its voltage wrt ground will rise to around 3.7v due to the internal clamp diode from GPIO2 to VCC, therefore the base of Q1 will be at (5-3.7)*10k/11k or about 1.18v wrt to the emitter... which may turn Q1 on.. I think you need a diode or two in series with R1 to avoid that possibility.
The idea is to remove any dependency on the internal pullup.
The gpio output is not really floating if externally pulled up to 5v by R2, and since Q1 is a PNP, Q1 should remain off at boot.
A diode can be added but I don't think its needed.
 

ronsimpson

Joined Oct 7, 2019
4,702
I am working on a board that was designed in China and they did not understand the relays chatter at boot and reset. This table shows four outputs that are high during boot. Avoid using D0, D4, GPIO3, GPIO1.
1749671755859.png
 
Top