Skip to content

Instantly share code, notes, and snippets.

@danawoodman
Last active February 5, 2025 03:18
Show Gist options
  • Save danawoodman/a682e64ef1ef3e96e5e02c5257c2cbc5 to your computer and use it in GitHub Desktop.
Save danawoodman/a682e64ef1ef3e96e5e02c5257c2cbc5 to your computer and use it in GitHub Desktop.
ESP32 Controlled Low-Voltage Path Lights

ESP32 Controlled Low-Voltage Path Lights

Using an ESP32-C3 connected to HomeAssistant via ESPHome, control 12v yard path lights including configuring automations to turn lights on/off at sunset/sunrise and dimming.

This short guide will show you how to use HomeAssistant, and the ESPHome app for it, to control LED dimming. In this case I'm using this for low voltage yard path lights, but could be used for anything.

If you have HomeKit integrated with HomeAssistant than you can also control/dim your LEDs from your iPhone!

Parts

Setup

  • setup a new ESP32-C3 (or equivalent) device in ESPHome via HomeAssistant (you can flash the ESP via the ESPhome web interface, just make sure to setup wifi)
  • edit the device in ESPHome in HomeAssistant and place the below code
  • go to new device and set to location/give it a name, etc
  • in HA, configure automations as needed (e.g. turn on a sunset, turn off at dawn)

ESPHome Code

esphome:
  name: path-lights
  platform: ESP32
  board: esp32dev

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true # optional

logger:
api:
ota:

output:
  - platform: ledc
    pin: GPIO5  # Change to your actual GPIO
    id: pwm_led
    frequency: 1000Hz  # Adjust if flickering occurs

light:
  - platform: monochromatic
    name: "Path Lights"
    output: pwm_led
    default_transition_length: 1s

Make sure to set the above wifi secrets in ESPHome

Wiring

  • MOSFET Gate (via 220Ω resistor) → ESP32 GPIO
  • MOSFET Drain → Negative (−) of LED string
  • MOSFET Source → Ground (GND)
  • 12V Power Supply + → Positive (+) of LED string
  • 12V Power Supply - → GND (common ground with ESP32)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment