-->
Page 1 of 2

Solutions: Input device on GPIO2

PostPosted: Sat Jun 27, 2015 3:39 pm
by Paul Miller
As most of us know, gpio2 needs to be held high or unconnected during boot to run user applications. This makes connecting a device that triggers high problematic because it will pull gpio2 low during boot causing unwanted behavior. I searched around here and didn't find any real solutions (just work arounds) so I'm glad to share my own in case it helps someone else.

The solution was to come up with a circuit that would output gpio2 = Vcc - Sensor output. This will keep gpio2 normally high. When the sensor triggers, it will be pulled low. Then, your software can be set up to look for the LOW on gpio2. Since my ESP-01 boots before the sensor device ever sends a HIGH, this works very well.

The circuit uses 4 1K resistors and an Op Amp. I also put a 47K resistor in between gpio2 and my HC-SR501 sensor device.

Here is the circuit:
esp8266_gpio2.png


If anyone else has a solution, please share it.

Re: Solutions: Input device on GPIO2

PostPosted: Mon Jun 29, 2015 10:24 am
by j0hncc
Paul, that is good, thank you!

Unfortunately this part would be the "show-stopper" for many applications:
Paul Miller wrote: Since my ESP-01 boots before the sensor device ever sends a HIGH, this works very well.

Re: Solutions: Input device on GPIO2

PostPosted: Mon Jun 29, 2015 2:10 pm
by lethe
This circuit seems awfully complicated to me. I'm not an electrical engineer, but from what I understand you just want to invert logic levels. Why don't you just use a simple transistor inverter or any standard NOT, NAND or NOR gate from the 74xx or CD40xx logic IC series?

Re: Solutions: Input device on GPIO2

PostPosted: Tue Jun 30, 2015 5:59 am
by Paul Miller
lethe wrote:This circuit seems awfully complicated to me. I'm not an electrical engineer, but from what I understand you just want to invert logic levels. Why don't you just use a simple transistor inverter or any standard NOT, NAND or NOR gate from the 74xx or CD40xx logic IC series?


Sounds awesome. Please post the circuit so we can take a look.