Running a single cathode LED with ESPHome

I use ESPHome for many small sensor around the house, by in large it work great. However, I have struggled to get ESPHome to turn on/off a single cathode LED. I’ve tried nearly every pin on the D1 Wemos Mini and every conceivable configuration on ESPHome. I welcome any feedback or guidance.

esphome:
  name: bedroom_sensor
  platform: ESP8266
  board: d1_mini

packages:
  wifi: !include wifi.yaml

i2c:
  sda: GPIO4
  scl: GPIO5
  scan: True

sensor:
  - platform: adc
    pin: A0
    name: "Bedroom Ambient Light"
    update_interval: 120s
  - platform: htu21d
    temperature:
      name: "Bedroom Temperature"
      id: htu21d_temp
      filters:
        - lambda: return x * (9.0/5.0) + 32.0;
        - offset: -2.0
      unit_of_measurement: "°F"
    humidity:
      name: "Bedroom Humidity"
      id: htu21d_humidity
    update_interval: 120s
  - platform: sgp30
    eco2:
      name: "Bedroom eCO2"
      accuracy_decimals: 1
    tvoc:
      name: "Bedroom TVOC"
      accuracy_decimals: 1
    update_interval: 120s
    compensation:
      temperature_source: htu21d_temp
      humidity_source: htu21d_humidity
  - platform: wifi_signal
    name: "Bedroom Sensor WiFi Signal"
    update_interval: 120s

binary_sensor:
  - platform: gpio
    pin: GPIO12
    name: "PIR Sensor"
    device_class: motion
    on_press:
      then:
        - light.turn_on: single_led
    on_release:
      then:
        - light.turn_off: single_led
  - platform: status
    name: "Bedroom Sensor Status"
text_sensor:
  - platform: wifi_info
    ip_address:
      name: Bedroom Sensor IP Address
    ssid:
      name: Bedroom Sensor SSID
    mac_address:
      name: Bedroom Sensor Mac Wifi Address

light:
  - platform: binary
    name: "LED"
    output: gpio_led
    id: single_led

output:
  - platform: gpio
    pin: GPIO16
    id: gpio_led

status_led:
  pin:
    number: D4
    inverted: True

switch:
  - platform: restart
    name: "Bedroom Sensor Restart"

captive_portal:
# Enable logging

logger:
# Enable Home Assistant API

api:

ota:
  password: !secret esp_ota

The ESPHome logs show the PIR sensor is toggling and changing the LED, but no light.

[08:56:30][D][binary_sensor:036]: 'PIR Sensor': Sending state ON
[08:56:30][D][light:265]: 'LED' Setting:
[08:56:30][D][light:274]:   State: ON
[08:56:33][D][binary_sensor:036]: 'PIR Sensor': Sending state OFF
[08:56:33][D][light:265]: 'LED' Setting:
[08:56:33][D][light:274]:   State: OFF

What is a single cathode led?
The light: and output: part looks correct. Maybe your led is broken?
Can you measure the output with a voltmeter?

Sorry, it is a traditional THT breadboard anode/cathode LED. What I meant is there is not a logic device embedded within the LED that would require a different approach with ESPHome.

Following your suggestion I measured the output: pin voltage and I am getting 3.3V when the PIR is triggered, which leads me to believe the ESPHome is working correctly . . . there must be something is wrong with my wiring. This is killing me the circuit is stupid simple:

GPIO0 -> LED -> resistor (220 ohm) -> Ground

Seems correct only reasons could be:

  • broken LED
  • broken resistor
  • wrong polarity
  • broken cable

You could again measure between cathode (shorter and flat side) and anode (longer and round side) of the LED.

I fixed it, there was a fifth option. It was simpler than that and far more indicative of my stupidity . . . I had the anode and cathode of the LED on the same breadboard row :man_facepalming:. As soon as I put the anode on a different row it worked perfectly. I appreciate your patience and help.