Solutions: Input device on GPIO2
Posted: Sat Jun 27, 2015 3:39 pm
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:
If anyone else has a solution, please share it.
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:
If anyone else has a solution, please share it.