Skip to content

Low Voltage DC Lighting with ESPHome

About a year ago I started a project to figure out if I can add lighting to my hundred-year-old house without too much work. Famous last words. Looking back at it, hiring an electrician would have been faster and maybe cheaper, but I wouldn’t have learned anything. This is a summary of the journey I took through buying parts, programming ESPs, and ultimately, making my first PCB.

Humble benginnings

Initially, I wanted to see how I could scale the ability of controlling LED lights. Analog LED strip lights were about 7 bucks for 15 ft from China and recessed lights were about the same. More importantly, being that these lights are LEDs, they very efficient especially when driven and 60%-80% of their max rating. So I went online and ordered a dozen LED recessed lights, LED strips, and some COB LEDs which are inside of the recessed lights.

My plan was to hook the LEDs up to 24vDC and see how they worked. For the LED strips, it was easy as you can order them in 24v flavor. But the recessed lights are all powered by little LED drivers that are 110/220 to 24v. I first started by burning up a few of the COB LEDs to see what they could take. It turns out the larger COBs did fine with 24v but the smaller ones burned up. Driving two of the smaller ones in series worked fine.

Now I needed to control them

At this point, I had used and flashed a few H801‘s to control analog RGBW strips. While the H801 is nice little package, it had a habit of ringing at certain PWM frequencies. Combine that with the fact that it was using an ESP8266 software PWM to drive the FETs left room for improvement.

Since this was my first foray into controlling analog LEDs, I wanted to see what I could achieve from off-the-shelf components. The key was to drive the LED with a good PWM driver at a high enough frequency that made them work well. I already had a few dozen Wemos D1 Mini, but decided to try a servo controller for the PWM generator and tie it to a MOSFET. Here is the hardware I used:

To my surprise, this setup worked flawlessly on the workbench. For a few months, I used this in my garage to see if it was going to be short-lived, but it just kept working. Initially, I powered these via a bench power supply and later moved the setup over to the DIN Rail PS above. Keep in mind, your power supply should be sized for the load you plan on powering with some headroom.

Circuit Operation

Pulse Width Modulation allows you to control the brightness of the LEDs. The way that you control an LED’s brightness is by turning it ON and OFF, many times per second (this is called PWM frequency). The longer that the LED stays ON, compared to OFF, the brighter the LED will light (this is called PWM duty cycle). In this circuit, the PCA9685 is the PWM generator. For example, the Wemos D1 controller will tell the PCA9685 to turn on channel 1 at 50% duty cycle. The PCA will then pulse that channel at half ON and half OFF based on the frequency you’ve configured for the module. This pulse is an output from the PCA and is wired up to the gate pin of an N channel MOSFET. This device will then act as the switch that turns the LED on and off.


The key thing to understand about the wiring is that the Wemos D1 mini and PCA9685 are not 24v tolerant. If you put 24v on them, you will release the magic blue smoke. So, just make sure before you turn it on, you double-check your wiring that you’re only run 5v to these devices.

Components and their wiring

One PCA9685 has 16 channels and each MOSFET module has 4 channels. This means you can go up to 4x MOSFET modules for one PCA9685. I have some channels that are running 4 and 6 recessed LEDs, and many that are running a single recessed LED. This gives you a lot of flexibility in how you wire your lights giving you much more control of your lights.

LED Wiring

The wire types that you use are up to you. It’s important to select the correct wire for the LEDs based on the current draw and the distance you’re running. My longest wire are about 40 feet and there I used bell wire. For shorter 20ft runs with only one light I used cheap CAT6. The wires between the Wemos, PCA, and MOSFET were either dupont or servo extension.


As you probably would have guessed, I used the trusty ESPHome project to create the firmware for the Wemos D1. This is pretty straightforward to configure. as you configure the PCA9685 as outputs per the documentation, and then just tie your lights to those outputs to lights.

The components above include

  • An I2C component to enable I2C communication
  • A PCA9685 component to define the PWM module
  • Outputs for each of the channels used on the PCA9685
  • Lights for each of the Outputs
  • A switch restart component to reboot the Wemos
Published inDIY HardwareESPHomeHome AssistantHome Automation