Skip to content

Relay not switching on at power-up with boot-preset #5312

Closed

Description

@DedeHai

What happened?

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.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. blazoncek commented on Jan 24, 2026

    @blazoncek
    Contributor

    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.

  2. DedeHai commented on Jan 25, 2026

    @DedeHai
    CollaboratorAuthor

    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.

  3. DedeHai commented on Jan 25, 2026

    @DedeHai
    CollaboratorAuthor

    I did a bi-section, this PR breaks it: #4658

  4. blazoncek commented on Jan 25, 2026

    @blazoncek
    Contributor

    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.

  5. DedeHai commented on Jan 25, 2026

    @DedeHai
    CollaboratorAuthor

    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.

  6. softhack007 commented on Jan 25, 2026

    @softhack007
    Member

    @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.

  7. DedeHai commented on Jan 25, 2026

    @DedeHai
    CollaboratorAuthor

    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.

  8. added 2 commits that reference this issue on Jan 31, 2026
    8111fc1
    a551747
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions