-->
Page 1 of 2

ESP-01 Solenoid activated at boot

PostPosted: Tue May 14, 2019 9:34 pm
by vitorrossi
I have put together a small circuit to operate a 5V solenoid from GPIO0 on the ESP8266 (01).
When power is connected, the solenoid momentarily actuates ON and back OFF (unwanted behavior).
Afterwards everything works normally, and I can open/close the solenoid from the website hosted on the ESP01.

The behavior at boot is unwanted, but I am not sure why it is happening.
R5 is the pull up resistor on GPIO0 which in my understanding should prevent this from happening.
I have attached the circuit schematic, and an oscilloscope reading of the voltage on GPIO0 when the power is turned on.
Can anyone identify what I'm doing wrong?

Thank you!

Image

Image

Re: ESP-01 Solenoid activated at boot

PostPosted: Wed May 15, 2019 12:31 am
by rudy
A high on GPIO0 is needed for the ESP8266 to run your program. This high is turning on the transistor that is driving your solenoid. When your initialization code executes, and you configure GPIO0 as an output with a low, then the high driving the transistor is no longer present and the solenoid turns off.

If you have to use GPIO0 then the off state for the solenoid needs to be a high. You can use a common emitter connected NPN transistor between the port pin and the current transistor driving the relay. I would prefer to use a PNP, with the emitter connected to VCC and the collector supplying the current for the base of the darlington transistor. (pull down resistor to turn the darlington off)

Image
For the PNP circuit, on the left, use VCC and not 5V as in the image. If you use the circuit on the right, make sure the base resistor does not prevent a sufficient for GPIO0. You may have to decrease the resistance of the pullup resistor.

I don't know why you are getting those transitions during the high time.

Re: ESP-01 Solenoid activated at boot

PostPosted: Wed May 15, 2019 8:59 am
by martinayotte
rudy wrote:I don't know why you are getting those transitions during the high time.

It is know that GPIO0 produce some clock output during reset, it cannot be avoided :
https://bbs.espressif.com/viewtopic.php?t=2101#p6636

Re: ESP-01 Solenoid activated at boot

PostPosted: Wed May 15, 2019 10:21 am
by rudy
I knew GPIO2 could put out serial at start. I didn't know that GPIO0 was a problem as well.

I have never used the ESP-01 since I disliked the lack of available IO pins. I typically only use GPIO0 and GPIO1 for I2C communications or to drive an LED as an indicator.