Chat freely about anything...
User avatar
By kikko_fr
#1539 Hi,

I'd like to use the ESP8266 in my next project without any external mcu.

This project needs an output pin to toggle a mosfet/relay and an input pin to detect change on a sensor.
But since these pins are being used to changed the module's mode during boot, I'm having trouble completing my circuit.

With a small capacitor, I managed to use the GPIO2 in output mode to toggle the mosfet

But I can't find how to use the GPIO0 for my sensor without getting the module stuck during boot.

Has anyone faced similar problems ? I'm new to electronics so I might be missing something simple...

Any hint would be appreciated!
User avatar
By Squonk
#1540 Instead of tying the pins directly to GND or VCC, you can use a "weak" series pull-up or pull-down resistor, a 10 k to 47k value is typical. If you take 33k with a 3.3V power supply for example, the current drained will be U/R=I=3.3/33k=100µA max, instead of relying on the ESP8266 OFF resistance value to fix the current.

And provided that your relay/sensor have their default state matching the GPIO bootstrap value, you can then both guarantee that:
  • you will have the expected value upon startup for the ESP8266 boostrap value and your relay/sensor
  • you will still be able to control/read them by "forcing" the level opposite to the weak pull resistor

By "forcing", here is what I mean: if the ON resistance of your output pin (ESP8266 or sensor output) is low enough (which is normally the case), the corresponding input (MOSFET gate or ES8266 input) will be like connected to it by a voltage divider made up of the low ON value output resistor and the high value weak pull resistor, resulting in a negligible voltage across the pull resistor and almost unchanged voltage value between output and input.