This should be a very simple question for most of you but confusing for a hobbyist.

I looked at the ESP-01 data sheet and the recommendation is to put a 3.3K pull-up resistor on GPIO2 to ensure the ESP-01 boots in operation mode.

The ESP-01 boots up my program fine (I have 2 blinking lights twice to denote that the ESP is running) if the OPTOTRIAC is disconnected.

But with the OPTOTRIAC connected to the GPIO2 line, the ESP won't boot. The R200 ohm is lifted from another tutorial and the 3.3K is from the datasheet. At boot, I suspect that the 200 ohm to ground through LED is stronger than the 3.3K pull up which is why the ESP won't boot to operation mode.

My question is, how do I size the 3.3K so that it pulls GPIO2 up when booting, then to operate normally as output for the OPTOTRIAC (output HIGH to activate OPTOTRIAC and LOW to deactivate it).

It might be worthy to note that I replaced the 3.3K with various resistors down to 670 ohm and that is when it started working as expected, but I don't know if this is the right way or if it is going to be reliable.

Therefore, I am not looking for just the answer, but I am looking also at the "why". How should the resistor(s) size be calculated?

Thanks in advance

Simplified Schematic

  • \$\begingroup\$ Why? Because the led in the optotriac is limiting the voltage. Change your code to pull gpio2 low to activate the opto and change the wiring so that the 200 ohm resistor goes to 3V and the negative of the opto led goes to gpio2. This should solve your problem. \$\endgroup\$ – Kartman Mar 15 at 4:14
  • \$\begingroup\$ Hi, thanks for that answer. Clarified something for me. If I just do exactly what you said, do I still need the 3.3K resistor to pull up GPIO2 during boot? \$\endgroup\$ – Azrudi Mar 15 at 4:36
  • \$\begingroup\$ 3.3K resistor? Probably not as the opto should provide enough pullup. You can use a multimeter to verify. Nevertheless, including the 3.3K resistor won’t hurt. \$\endgroup\$ – Kartman Mar 15 at 11:23
  • \$\begingroup\$ Hi there. You mean something like this, right? imgur.com/271c5hX How do I know if the opto should provide enough pull-up? What should I measure with the multimeter and how do I judge whether it is enough? \$\endgroup\$ – Azrudi Mar 15 at 14:55
  • \$\begingroup\$ Measure the voltage from gpio2 to gnd. If it is, say, 2V or greater, then that is ok. You’ll also know if it is adequate as it will not go into bootloader mode when you don’t want it to. \$\endgroup\$ – Kartman Mar 15 at 20:06

I think you are misunderstanding the datasheet and the need for the pull up resistor in the ESP-01 module. Or I misunderstood entirely your question. But, lets give it a try.

The ESP-01 is a full setup module and ready to run in a normal operation. The pull ups and pull downs required to bring the module to a normal operation are already in place. If you take off your circuitry and use a programmer like this ones https://www.ebay.ca/itm/203304682591, https://www.ebay.ca/itm/203304682591, you will be able to load code and have it it running just applying power.

Without going deeper in your design, I imagine you are using the GPIO2 to drive the OPTOTRIAC. And for that, you will have code to set GPIO2 LOW or HIGH according to your needs. So, the GPIO2 will never be floating. It will be either HIGH or LOW. For that, you dont need any any pull up resistor as you already setting in the code the state of the pin.

I am under the impression you are looking to the ESP8266EX IC datasheet. Or any hardware recommendation guidance for the ESP-12E/F module. Which would be another story entirely.

By the way, what is happening is not that the module is not going to normal operation. The module is working as expected by the circuitry. But, the pin is held HIGH and you are under the impression the module is not working. If you put something in the GPIO0 you will probably see that it is still working.

In other note for the design you implemented, it is not that your circuitry is working when you go lower in the resistors. What you are doing is creating a short. The way I see from the image, you are always setting the OPTOTRIAC to HIGH. When your PIN is HIGH, the value from your PIN to the OPTOTRIAC will be high just because all nodes are HIGH. But, when your pin is LOW, the OPTOTRIAC still going to be HIGH as there is a connection from it to 3V3 through the resistor.

The fact that is working with lower resistor is because you are creating a short from 3V3 to GPIO2, when you set the PIN to LOW and the resistance is LOW. So, all the current will be sunk to the PIN instead of going to the OPTOTRIAC. And that will cause it to turn OFF giving the impression that this is working. It is just a fake impression that it is working. But, I believe that is not what you wanted to do.

So, take the resistor off and give it another try. The OPTOTRIAC will follow whatever you set in the PIN via code.

Take a look at this video as it goes all the way to the IC on ESP8266


  • \$\begingroup\$ The GPIO2 definitely is floating during reset and until execution reaches the code that configures it as an output. OP's problem is the behavior during bootstrapping, before his code begins to execute. \$\endgroup\$ – Ben Voigt Mar 25 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.