Any way to turn off the Wemos D1 Mini onboard LED?

Just got my first node working in HA and it is awesome!!
One thing I’m trying to figure out now is how to turn off the onboard LED on my Wemos D1 Mini.
Now this is an older one and looks very different from the newer ones from Lolin.
I am trying to make a small notification light from the D1 mini and the RGB shield.

So having the blue onboard led on at all times isn’t desirable.

Thanks

You’ll probably need to do this with whatever firmware or sketch you have put on the D1. You’ll only be able to control the LED with HA, if that firmware allows you to

There are ways to do this with firmware like ESPEasy and Tasmota but assuming you’re using the ESPHOME firmware, since that’s the section you posted in, It looks like you can set it to only be active when there’s a warning or error-

esphome:
  name: xxxx
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: 'xxxx'
  password: 'xxxx'

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

light:
  - platform: neopixelbus
    type: grb
    pin: D4
    num_leds: 7
    name: "NeoPixel Light"
    variant: WS2812
    method: ESP8266_UART1
    effects:
      - strobe:
        name: Strobe Effect With Custom Values
        colors:
          - state: True
            brightness: 100%
            red: 100%
            green: 90%
            blue: 0%
            duration: 500ms
          - state: False
            duration: 250ms
          - state: True
            brightness: 100%
            red: 0%
            green: 100%
            blue: 0%
            duration: 500ms
      - flicker:
          name: Flicker Effect With Custom Values
          alpha: 95%
          intensity: 1.5%
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 50       
      - addressable_color_wipe:
          name: Color Wipe Effect With Custom Values
          colors:
            - red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 100ms
          reverse: False
      - addressable_scan:
          name: Scan Effect With Custom Values
          move_interval: 100ms
      - addressable_twinkle:
          name: Twinkle Effect With Custom Values
          twinkle_probability: 5%
          progress_interval: 4ms
      - addressable_fireworks:
          name: Fireworks Effect With Custom Values
          update_interval: 32ms
          spark_probability: 10%
          use_random_color: false
          fade_out_rate: 120    
      - addressable_flicker:
          name: Flicker Effect With Custom Values
          update_interval: 16ms
          intensity: 5%    

This is entirely controlled by esphome. The above is my yaml file for it.
This is why I was asking here…I don’t have a sketch loaded on it…esphome does that.

1 Like

That looks like what I need, thanks!
I’ll try and report back.

Thanks, could you please post your code again in https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code

Okay, so I figured out what to do to turn that pesky onboard LED off, but it comes at a price.
So if you look at the pic in my first post I take that shield and it just goes straight over the D1 mini and works.
The only way I see to turn the onboard light off turns control of the same pin that controls the shield off too.
So I can’t mount the shield directly onto the D1 mini the way I had wanted to.

In the end I guess it isn’t the worst thing since I could really use a resistor and capacitor for the newer models to smooth animations of the leds.
So in my case the onboard LED is controlled by D4 so I had to change the PIN controlling the shield leds.

status_led:
  pin:
  number: D4
  inverted: True
    
light:
  - platform: neopixelbus
    type: grb
    pin: GPIO3
    num_leds: 7
    name: "NeoPixel Light"
    variant: WS2812

Status led is a bit of a hack. Why not simply turn off the led at boot?

I know people won’t like this answer but you can short the led so it simply doesn’t work anymore.

1 Like

@nickrout: Thanks for your pointer to the core configuration. Following this link, I cannot find anything though regarding who to switch off the LED. Can you help?
My onbord LED is blinking very second despite not warning in the logs. Very annoying.

Specifically I was pointing to the on_boot code and siuggesting turning the led off at boot. What board do you have?

Thanks! Yes, I understood the hint towards the on_boot code, but still could not figure how how to switch of the LED there. I have a Wemos D1 mini.

The led is on GPIO2. Create a switch for it

switch:
  - platform: gpio
    pin: GPIO2
    name: "Wemos LED"
    inverted: true

Then follow the link to the onboot docs I posted and switch it off onboot.

5 Likes

Thanks again.
My actual problem, as it turned out, was that D4 (gpio2) was also used for the DC pin of the epaper attached to the device. That seems to have caused the constant blinking. Moving DC to D0 fixed the blinking and with your advice, I can now switch the LED on and off at boot. :slight_smile:

2 Likes

Hi, having a bit of a struglle here…I am trying to follow the nickrout (:-)).

Have this but it is complaining it can’t find the id… where is the error in my syntax?

esphome:
  name: ledstrip
  platform: ESP8266
  board: d1_mini
    # ...
  on_boot:
    priority: -10
    # ...
    then:
      - switch.turn_off: ledstripwemosled

switch:
  - platform: gpio
    pin: GPIO2
    name: ledstripwemosled
    inverted: true

I think you’d need to give the switch an id and then refer to the id in switch.turn_off

esphome:
  name: ledstrip
  platform: ESP8266
  board: d1_mini
    # ...
  on_boot:
    priority: -10
    # ...
    then:
      - switch.turn_off: annoyingled

switch:
  - platform: gpio
    pin: GPIO2
    name: ledstripwemosled
    inverted: true
    id: annoyingled

Well, at least it works for the “syntax” part.

But it’s not behaving like I want it to…

  1. Yes, it is now off after startup.
  2. But after turning on the LED strip it also turns on.
  3. After turning off the LED strip, it stays on.
  4. I can manually (a switch appears in HA) turn off the led…

But then I start at 2 again…

Can you post your whole yaml file?

esphome:
  name: ledstrip
  platform: ESP8266
  board: d1_mini
      # ...
  on_boot:
    priority: -10
    # ...
    then:
      - switch.turn_off: annoyingled


wifi:
  ssid: "no"
  password: "no"
  use_address: 192.168.6.13
  domain: .no.local


  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ledstrip"
    password: "no"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

switch:
  - platform: gpio
    pin: GPIO2
    name: ledstripwemosled
    inverted: true
    id: annoyingled
    
light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: D4
    num_leds: 59
    rgb_order: GRB
    name: "LEDstrip"
    effects:
      - addressable_rainbow:
      - addressable_rainbow:
          name: Rainbow Effect With Custom Values
          speed: 10
          width: 50
      - addressable_color_wipe:
      - addressable_color_wipe:
          name: Color Wipe Effect With Custom Values
          colors:
            - red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 100ms
          reverse: False
      - addressable_twinkle:
      - addressable_twinkle:
          name: Twinkle Effect With Custom Values
          twinkle_probability: 5%
          progress_interval: 4ms
      - addressable_fireworks:
      - addressable_fireworks:
          name: Fireworks Effect With Custom Values
          update_interval: 32ms
          spark_probability: 10%
          use_random_color: false
          fade_out_rate: 120

D4 is GPIO2 so that is not surprising :slight_smile:

https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ and https://esphome.io/guides/configuration-types.html#pin