Skip to content

wled 16.0.x: esp8266 analog pin cannot be chosen in settings #5747

In review

Description

@makefu

What happened?

with wled 0.15.0 when choosing an analog input in the settings the pin17 (actually a0) can be used to set up the input.
with wled 0.16.x (only tested 0.16.1) only "unused" seems to be available as pin but when saving the settings the analog setting is not available in macros.

Workaround: choose an existing unused pin before choosing "analog". this results in an exclamation mark in the pin but because the pin is unused anyway it still works as intended:

Image

I found my solution but i wanted to report the issue anyway.

Thanks for this great software!

To Reproduce Bug

install wled 0.16.1 on esp8266, go to settings, choose analog and press save

Expected Behavior

the analog input is kept in settings and can be used in macros

Install Method

Binary from WLED.me

What version of WLED?

WLED 16.0.1 (2606300)

Which microcontroller/board are you seeing the problem on?

ESP8266

Relevant log/trace output

Anything else?

No response

Code of Conduct

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

Activity

  1. added
    confirmed
    on Jul 20, 2026
  2. DedeHai commented on Jul 20, 2026

    @DedeHai
    Collaborator

    Your workaround is correct, the ADC pin on ESP8266 is a very special case that falls out of the grid of how the code currently works. I need to check how to best fix this.

  3. changed the title [-]wled 0.16.x: esp8266 analog pin cannot be chosen in settings[/-] [+]wled 16.0.x: esp8266 analog pin cannot be chosen in settings[/+] on Aug 10, 2026
  4. added this to the 16.1 milestone on Sep 28, 2026
  5. DedeHai commented on Dec 3, 2026

    @DedeHai
    Collaborator

    @coderabbitai do you see an easy fix for this that does not need fundamental changes on how the pins are handled?

  6. coderabbitai commented on Dec 3, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    printf '%s\n' '--- Issue and comments ---'
    gh issue view 5747 --repo wled/WLED --comments
    printf '%s\n' '--- ADC and pin manager references ---'
    rg -n -C 2 'A0\b|isAnalogPin\s*\(|analogRead\s*\(|PinOwner::|allocatePin\s*\(' wled00 -g '*.{cpp,h}' | head -n 360

    Length of output: 24289


    Script executed:

    #!/bin/bash
    printf '%s\n' '--- Issue description ---'
    gh api repos/wled/WLED/issues/5747 --jq '{title,body,state,html_url}'
    printf '%s\n' '--- File outlines ---'
    for f in wled00/json.cpp wled00/button.cpp wled00/pin_manager.cpp wled00/xml.cpp; do
      echo "--- $f ---"
      ast-grep outline "$f" --items all --match 'serializePins|Button|button|Pin|pin' 2>&1 | head -n 100
    done
    printf '%s\n' '--- Pin serialization ---'
    cat -n wled00/json.cpp | sed -n '1070,1255p'
    printf '%s\n' '--- ESP8266 button handling references ---'
    rg -n -C 4 'BTN_TYPE_ANALOG|BTN_TYPE_ANALOG_INVERTED|buttons\[.*\]\.pin|WLED_NUM_PINS' wled00 -g '*.{cpp,h}' | head -n 260
    printf '%s\n' '--- Pin viewer file names ---'
    fd -i 'pin' | head -n 100

    Length of output: 29716


    Script executed:

    #!/bin/bash
    printf '%s\n' '--- Relevant UI references ---'
    rg -n -C 4 'd\.adc|\.adc\b|BTN_TYPE_ANALOG|analog|Analog|BT[0-9]|max_gpio|rsvd' wled00/data -g '*.{js,htm}' | head -n 300
    printf '%s\n' '--- Map source files ---'
    for f in wled00/set.cpp wled00/cfg.cpp wled00/pin_manager.cpp wled00/xml.cpp; do
      echo "--- $f ---"
      ast-grep outline "$f" --items all --match 'Settings|settings|Config|config|Pin|pin|appendGPIO' 2>&1 | head -n 100
    done
    printf '%s\n' '--- Settings button save path ---'
    cat -n wled00/set.cpp | sed -n '350,445p'
    printf '%s\n' '--- Config button load path ---'
    cat -n wled00/cfg.cpp | sed -n '380,475p'
    printf '%s\n' '--- Pin manager bounds and validity ---'
    cat -n wled00/pin_manager.cpp | sed -n '1,42p;145,215p;300,326p;390,435p'
    printf '%s\n' '--- GPIO settings output ---'
    cat -n wled00/xml.cpp | sed -n '95,205p'

    Length of output: 51697


    Script executed:

    #!/bin/bash
    printf '%s\n' '--- Button dropdown and macros ---'
    ast-grep outline wled00/data/common.js --items all --match 'pin|Pin|DD|Dropdown' 2>&1 | head -n 100
    rg -n -C 4 'btnPinDd|pinDropdowns|addBtn|buttons\[|BT[0-9]|BE[0-9]|btns|macro' wled00/data/settings_leds.htm wled00/data/settings_time.htm wled00/xml.cpp wled00/set.cpp wled00/cfg.cpp | head -n 310
    cat -n wled00/data/common.js | sed -n '300,380p'
    cat -n wled00/data/settings_leds.htm | sed -n '830,885p'
    printf '%s\n' '--- Button config save and default handling ---'
    cat -n wled00/cfg.cpp | sed -n '469,515p;1060,1125p'
    printf '%s\n' '--- Button deallocation around settings save ---'
    rg -n -C 4 'deallocatePin\(.*button|for.*button.*buttons|buttons\.clear|btn\.pin|btn\.type' wled00/set.cpp wled00/cfg.cpp wled00/xml.cpp wled00/button.cpp

    Length of output: 39496


    @DedeHai Yes. A localized fix could treat pin == -1 as implicit A0, but only for ESP8266 buttons with type BTN_TYPE_ANALOG or BTN_TYPE_ANALOG_INVERTED.

    • In wled00/set.cpp and wled00/cfg.cpp, keep those buttons without allocating a GPIO or calling pinMode(). Apply the same rule to the default-button path.
    • In the settings UI, show A0 (fixed) for those types. Use the button type to disable the button, rather than presenting -1 as “unused.”
    • When loading older analog configurations, normalize their stored pin to -1. This also releases the GPIO used by the workaround. Preserve the button’s macros.
    • Leave other pin handling unchanged. handleButton() already permits an ESP8266 analog button with a negative pin, and handleAnalog() reads A0.

    The trade-off is that A0 would remain outside PinManager, so this would not detect conflicts with usermods that also use A0. It would fix button selection and persistence, not provide general A0 ownership tracking.

    I have not tested this. I would check both analog types, save and reboot, macro visibility, migration from the workaround, and switching back to a digital button.


    Learnings used

    Learnt from: softhack007
    Repo: wled/WLED PR: 0
    File: :0-0
    Timestamp: 2026-10-03T14:59:43.661Z
    Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
    

    You are interacting with an AI system.

  7. removed this from the 16.1 milestone on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconfirmed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions