Relay Startup

Hey Everyone,

Once again, I need your competent help with one of my projects.
I am using a NodeMCU ESP32 with a level shifter and a 2-relay module. Relay K1 is connected to the level shifter, which is controlled via Pin 22 of the ESP32. Relay K2 is also connected to a level shifter and is controlled via Pin 21 (Multi-Relay Usermod).

First of all, everything works fine, and I have no problems at all using the setup—except for the following:
I like to unplug the controller completely from the power source when I no longer need it (switching it off entirely). This means no standby mode.

The problem is as follows: When I plug in the device, the relay receives its initial current and turns on automatically for approximately 0.5 seconds before turning off again. WLED doesn’t seem to have any impact on this initial 0.5-second activation. My relay’s output connection is NC, which results in a 0.5-second flash when the relay detects the initial current. I believe this might be caused by Pins 22 and 21 being set to HIGH status during boot. Is there a way to prevent this from happening and stop the relays from switching automatically when they receive power for the first time? It would be great to achieve this without making any major changes to my hardware setup.

yes, use pins that do not have a pullup or other boot states, see ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

then add a pulldown if the relay board does not already have one or the issue persists. The bootup time of the ESP is much less than 0.5s, more like 0.1 seconds, probably even less.

Hi Dedehai,

Thank you for your quick reply and for providing the GPIO tutorial.

I checked pins 21 and 22, and according to the tutorial, neither should be high at boot. I also tried installing a 10-kiloohm resistor between pin 21 and GND, but it made no difference. Is there something I am missing or doing wrong? Also, is a 10-kiloohm resistor sufficient?

My next idea is to install a capacitor/transistor circuit at the relay’s input pin, although this would complicate my hardware setup again.

According to the tutorial, only pins 1, 3, 5, and 6–11, 14, and 15 are high at boot, which confuses me.

according to this, that relay module has inverted inputs:

low means on.

Hi Dedehai,

Thanks for your help. I thought the relay was active high, which isn’t the case. It’s active low.
I tried using pin 5 (high at boot) for instance and that changed the behavior of the relay.
Topic can be closed :slight_smile: