I have a QtPy ESP32-S2 powered by USB, running CircuitPython. It hosts a single web page that allows setting the red, green, blue, and white values for a 12V RGBW strip. The pins A0 - A3 send PWM signals to MOSFETs (datasheet) that control the LED strip. The problem happens on boot or reset the LEDs are on at a blinding full blast until it hits the line of code that sets them to 0. I have tried using a relay on the 12V power supply but that only works on the first boot, every time that I hit save in the Mu editor it resets and blinds me. I have tried all the other pins and they all have the same behavior. Any software solutions would have the same effect. I have had the suggestion of using a resistor and capacitor with the 12V source but that would be similar to the relay in that it would only work the first time and also figuring out the exact values would be difficult. I have also had the suggestion of using a "RS flip-flop/latch" but I have never used that before so I'm unfamiliar with how to setup something like that on my breadboard. There is always a last resort option of a physical switch on the 12V supply but I'd like to avoid that if possible.

Here is the fritzing breadboard diagram: breadboard diagram

Here is my circuitpython code for the ESP32: https://github.com/dieseltravis/circuitpython-projects/blob/main/esp-leds/code.py#L9

Here is a pic of a nice orangish color that I've selected from the ESP32's web page: picture of breadboard showing LEDs a nice orange color

Here is a pic of the LEDs showing a blinding whiteness after hitting save in the Mu editor: picture of breadboard showing the LEDs lit at full blast

Update: Here is a diagram of the working circuit: functional circuit fritzing

  • 2
    \$\begingroup\$ I'm not privy to the details of your specific MCU board. But I am with respect to MCUs, more generally. They are usually designed so that their I/O pins start in a high impedance state until such time as software can inflict itself and specify which pins are supposed to be output drivers and what their values should be. You are using FETs and their gates are like floating capacitors. You probably need to do something to tie them into an OFF state up until the moment your I/O pins can be configured and active. Lots of options for that. I'm sure you'll get good suggestions. \$\endgroup\$
    – jonk
    May 15, 2022 at 3:04
  • \$\begingroup\$ Where does your MCU board get power? I see only a Vss/- wire going to it. It doesn't appear to have a 12V input. It appears it is powered through the LEDs, like old school dimmers that power themselves by leaking power through incandescents. LEDs don't like those either. \$\endgroup\$ May 15, 2022 at 4:06
  • \$\begingroup\$ The ESP32 is powered by the USB connector \$\endgroup\$
    – travis
    May 15, 2022 at 4:07
  • \$\begingroup\$ It seems you need a power on delayreset to disable LED power by some FET with gated delay \$\endgroup\$ May 15, 2022 at 4:26

2 Answers 2


According to Adafruit documentation, the pin "A0" is pulled up with 10k resistor onboard the PCB.

According to Adaruit documentation, they don't seem to even know why ESP32 documentation suggests pulling the pin up, which means they just did not read the ESP documentation about the pin.

So that explains why the at least the pin controlled by "A0" channel (red?) turns on at boot.

If the internal pull-up is important, please be aware that pulling the pin externally low may prevent the ESP32 from operating normally, like for example going into wrong boot mode.

So, when adding an external pull-down resistor two things need to be considered. The pull-up must be strong enough to overcome the internal 10k pull-up resistor. 10k pull-down would make the pin float at halfway, so 1k pull-up should work better to keep the pin low. The other thing is, it is not clearly defined if the GPIO pin must be high, or does it just need to be stable, so it can be held low too.

The other LED channels may be on just because if the PWM signal happened to be high when the MCU resets, there is nothing to turn off the FETs so the LEDs stay on. So here, a pull-down resistor will help.

As I expected, here is a quite about the pin A0 which is GPIO18:

GPIO18 works as U1RXD and is in an uncertain state when the chip is powered on, which may affect the chip’s entry into download boot mode. To solve this issue, add an external pull-up resistor.

  • \$\begingroup\$ OK, I'll try shifting the wires down to start at A1, A2, A3, and set the SDA pin to use PWM. For adding the pull-down resistors, would 10KΩ work there? \$\endgroup\$
    – travis
    May 15, 2022 at 16:30
  • \$\begingroup\$ I have shifted all the PWMs down a pin and added the 10K pull-down resistors and it is working great, no more flashing, thanks! \$\endgroup\$
    – travis
    May 15, 2022 at 22:37

The pins are likely initialized to a floating, high impedance state. A floating MOSFET gate can pick up charge and spontaneously "turn on."

A pull-down resistor on the gate would prevent this from happening.

  • \$\begingroup\$ I have a bunch of resistors on hand, any suggestions on the values? I currently have a 1KΩ between the PWM pins and the MOSFETs but can change that as well. \$\endgroup\$
    – travis
    May 15, 2022 at 4:37
  • 1
    \$\begingroup\$ The 1kΩ resistors are fine. I would go with a larger resistor for the pull-down to prevent excessive current draw from the I/O pins. 10kΩ would probably be fine. \$\endgroup\$ May 15, 2022 at 4:40
  • \$\begingroup\$ OK, I'll try that and post back with the results. 👍 \$\endgroup\$
    – travis
    May 15, 2022 at 4:57
  • 2
    \$\begingroup\$ That may not help and may make things worse. According to documentation, the pin "A0" is pulled up with 10k resistor onboard because it is an UART bootloader pin. Putting a 10k pull-down externally might just amplify any issues. \$\endgroup\$
    – Justme
    May 15, 2022 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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