How to use ESP8266 on-board LED with ESPHome?

I built a BRUH multisensor a while ago with just the DHT22 and the AM312 PIR. I modified that Arduino code to light the on-board red LED when motion is detected. I’ve just made another such sensor with ESPHome (so easy, and it works great!) but I don’t know how to make the on-board LED light when the motion detector senses motion. Is this possible with ESPHome? Thanks for any help!

Yes it is.

You should be able to adapt the LED automation part of this video:

1 Like

Thanks. I watched the video - now I have to study up on how to apply this to my situation :thinking:

1 Like

Thanks to the video/documentation by JuanMTech, and the excellent documentation for ESPHome, I figured out how to turn on the on-board LED on my NodeMCU when the motion sensor detects motion, and turn it off when motion stops. I thought I’d post my code in case it can help someone else.

esphome:
  name: sensor4
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "REDACTED"
  password: "REDACTED"

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: 'REDACTED'

ota:
  password: 'REDACTED'
  
sensor:
  - platform: dht
    model: AM2302
    pin: D7
    temperature:
      name: "Sensor 4 Temperature"
      
    humidity:
      name: "Sensor 4 Humidity"
      
  - platform: uptime
    name: "Sensor 4 Uptime"
    
  - platform: wifi_signal
    name: "Sensor 4 WiFi Signal"
    update_interval: 60s
    
text_sensor:
  - platform: version
    name: "Sensor 4 ESPHome Version"
    
binary_sensor:
  - platform: status
    name: "Sensor 4 Status"

  - platform: gpio
    pin: D5
    name: "Sensor 4 Motion"
    device_class: motion
    on_press:
      then:
        - light.turn_on: led
    on_release:
      then:
        - light.turn_off: led
        
output:
  - platform: esp8266_pwm
    id: onboard_led
    pin:
      number: D0
      inverted: true

light:
 - platform: monochromatic
   name: "Onboard LED"
   output: onboard_led
   id: led
13 Likes