ESP-01S Using GPIO0 and GPIO2

Using GPIO0 or GPIO2 as a Button (input)

In the module's schematics, you can observe that GPIO0 is equipped with a 12K resistor and then connect to 3.3V which effectively pulling it up to a logic HIGH state as its default condition.

To employ GPIO0 as a button, you need to establish a connection between one terminal of the push-button switch and GPIO0, and the other terminal should be linked to GND. When the state of GPIO0 registers as logic LOW, this signifies that the button has been pressed.

Here's an interesting observation: if you press and hold the button while rebooting the ESP-01S, you'll notice that the module becomes unresponsive and seemingly "freezes." This is because the ESP-01S has entered flash mode. The logic level of GPIO0 during boot determines the operational mode of the ESP-01S. When GPIO0 is pulled LOW, the ESP-01S enters flash mode, whereas when it's pulled HIGH, the ESP-01S operates in normal mode.

This arrangement highlights the significance of pulling up GPIO0 in the ESP-01S. It ensures that the ESP-01S consistently enters the normal operation mode after boot, preventing unintended entry into flash mode and maintaining the desired functionality of the module.

 

Using GPIO0 and GPIO2 as Inputs: A Cautionary Approach

Utilizing GPIO0 and GPIO2 as input pins can be a bit tricky due to their specific requirements during power-up and reset. To ensure proper startup of the ESP8266 module, these pins must be pulled either up or down as needed. Consequently, it's generally not advisable to directly connect an external switch to these pins because during power-up, there's no guarantee that the switch won't inadvertently pull the input to ground, potentially preventing the module from initializing correctly.

The workaround is to avoid direct connections from the external switch to GPIO0 or GPIO2. Instead, connect the switch to another GPIO pin that is set to drive to ground (as an output) only after the ESP8266 has fully started up.

For instance, one can connect one end of the switch to GPIO0 and the other end of the switch to an alternative GPIO pin, say GPIO0, and configure GPIO0 as an output set to logic low after booting. This arrangement allows you to safely read the switch state from GPIO2 without interfering with the module's initialization process, ensuring a more reliable and predictable operation. 

Using GPIO0 or GPIO2 as output

they can only be connect to active low device

 

Addressing Initial GPIO0 State on ESP8266 Boot

Upon power-up or reset in normal mode, the ESP8266 temporarily sets GPIO0 to a LOW state for approximately 100 milliseconds. This transient state can inadvertently activate connected output devices, including relays or LEDs attached to GPIO0. To prevent any undesired relay or LED activation during the module's startup, you can apply a simple solution: solder a capacitor with a capacity ranging from 220uF to 1000uF or even higher across GPIO0 and GND.

This capacitor acts as a delay mechanism for GPIO0's output, with the duration of the delay directly proportional to the capacitor's capacitance. Therefore, the higher the capacitance of the capacitor, the longer the delay it introduces, effectively mitigating any initial flicker or activation of connected devices during the ESP8266's boot process.

RELATED ARTICLES

Leave a comment

Your email address will not be published. Required fields are marked *

Please note, comments must be approved before they are published