You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Relay not switching on at power-up with boot-preset #5312
At bootup, the relay pin is not switched on (or not set as an output) if "power on at boot" is not set even if the boot-up preset uses "on":true
After switching off the LEDs and switching them back on, it works as intended.
This is confusing as the UI shows everything working and the LEDs being on, even data is sent to the LEDs but they are not powered as the relay stays off.
To Reproduce Bug
disable "power on at boot" in settings.
set relay pin for example to GPIO25, power on the MCU -> relay does not switch on.
Expected Behavior
when the UI shows the LEDs are on and data is sent, the relay should also be on.
Install Method
Self-Compiled
What version of WLED?
0.16
Which microcontroller/board are you seeing the problem on?
Other
Relevant log/trace output
C3 and ESP32 classic tested.
Anything else?
maybe a comment should be added to the settings that "Turn LEDs on after power up/reset" will be overridden if the boot-preset has "on" set to true.
FYI all but a few of my devices are equipped with relay and have "turn on at boot" off and they correctly switch relay either by pressing the power button or by starting a preset.
If yours are not working you must have made changes in 0.16 to break things.
And BTW boot preset always takes precedence over "turn on at boot" setting. It has always been so.
However if you have a boot preset without "on":true or "on":false that toggle is respected. This leaves some creative freedom when creating boot presets.
Some users reported this and in my hardware tests this bug led to some head-scratching so I checked and the behaviour is indeed different to what it was. I also saw some cases where it would switch but a bit erratic.
@DedeHai I didn't look at the code in detail, but there was some comment (near the relay code) hinting at transitions.
Or check if it's a problem with tasks - for example the relay being switched on by async_tcp, and then almost at the same time switched off by something in the loop task.
I'm just doing educated guessing. There are just a few places where the relay gets written, plus another few places that set the relay pinmode. Maybe putting a DEBUG_PRINT into these places will help to understand the sequence better. Or put the relay pin into a logic analyzer to see if / when it gets switched.
I have traced it, it's a quite complicated race condition caused by a fundamental flaw in the init code. I have a fix, just one line of code but I still need to check if it has any unforeseen consequences.
Activity
blazoncek commentedon Jan 24, 2026
FYI all but a few of my devices are equipped with relay and have "turn on at boot" off and they correctly switch relay either by pressing the power button or by starting a preset.
If yours are not working you must have made changes in 0.16 to break things.
And BTW boot preset always takes precedence over "turn on at boot" setting. It has always been so.
However if you have a boot preset without "on":true or "on":false that toggle is respected. This leaves some creative freedom when creating boot presets.
DedeHai commentedon Jan 25, 2026
Some users reported this and in my hardware tests this bug led to some head-scratching so I checked and the behaviour is indeed different to what it was. I also saw some cases where it would switch but a bit erratic.
DedeHai commentedon Jan 25, 2026
I did a bi-section, this PR breaks it: #4658
blazoncek commentedon Jan 25, 2026
Not in my case. See also #4474 where actual change of relay behaviour was done.
EDIT: Adding
delay(50)is not a proper way to postpone LED output.DedeHai commentedon Jan 25, 2026
something weird is going on, it would sometimes work and sometimes not. I suspect some timing issue but in general the code sequence is correct.
softhack007 commentedon Jan 25, 2026
@DedeHai I didn't look at the code in detail, but there was some comment (near the relay code) hinting at transitions.
Or check if it's a problem with tasks - for example the relay being switched on by async_tcp, and then almost at the same time switched off by something in the loop task.
I'm just doing educated guessing. There are just a few places where the relay gets written, plus another few places that set the relay pinmode. Maybe putting a DEBUG_PRINT into these places will help to understand the sequence better. Or put the relay pin into a logic analyzer to see if / when it gets switched.
DedeHai commentedon Jan 25, 2026
I have traced it, it's a quite complicated race condition caused by a fundamental flaw in the init code. I have a fix, just one line of code but I still need to check if it has any unforeseen consequences.
quickfix for sporadic "relay does not turn on" issues
LED output delay after switching on relay
HUB75 support and LED output delay after relay switch, general improv…