Controlling LED Strips Using PWM with ESPHome

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

In this tutorial, we'll explore how to control “dumb” LED strips, or those that are non-individually addressable, using ESPHome. These LED strips, unlike their popular counterparts such as WS2812B and SK6812 chips, require pulse-width modulation (PWM) for control due to their two-pin configuration. Individually addressable LED strips like the aforementioned WS2812B and SK6812 allow you to control the colour and brightness of each LED independently, meaning you can have multiple colours and patterns on the same strip at the same time. Each LED acts like a tiny smart device with its own chip to manage colours and communication. On the other hand, PWM controlled LED strips are controlled collectively; all LEDs on the strip will show the same colour and brightness at any moment. PWM dims or changes the strip's colour by rapidly turning the LEDs on and off, but you can't control each LED individually. So, while WS2812B offers more intricate and dynamic lighting possibilities, PWM strips provide uniform colour and are generally simpler and cheaper.


Diminishing Allure of Individually Addressable LED Strips

Individually addressable LED strips can infuse any smart home with exciting accent lighting. They offer a spectrum of colours and even animation options through ESPHome. However, the light quality they produce often falls short, leading many to avoid using them for primary lighting.

While colourful lights can be entertaining initially, their novelty tends to fade. Consequently, many users revert to plain white lighting. However, RGB strips without a dedicated white channel, like the WS2812B, fail to produce a satisfactory white light, making them unsuitable for primary lighting. This limitation makes high CRI white LED strips an attractive alternative.

The Colour Rendering Index (CRI) of an LED strip indicates how accurately it represents colours compared to a natural light source. A high CRI (95+ typically) is crucial for applications like video and photography, where natural color presentation is essential. Many also prefer high-quality lighting in their homes for a more authentic and visually pleasing ambiance.

Addressable LED Strips and the High CRI Challenge

Addressable LED strips, such as the popular WS2812B or SK6812, present a dilemma. Most don't mention their CRI, likely because it's not impressive. To maintain affordability, manufacturers often skip CRI measurement. While high CRI addressable LED strips exist, they are rare and expensive. For instance, YUJILEDS caters to video and photography enthusiasts, but 5 meters can cost around $300.

However, there's a silver lining with “dumb” or traditional LED strips. Though they lack individual addressability and inherent dimmability (which can be circumvented), they are affordable and available with high CRI. These strips have just two pins for power and none for commands. Their limitation is that they display only one colour temperature, which can't be adjusted as daylight changes. Yet, in spaces like kitchens where adjustable temperature isn't crucial, high CRI traditional LED strips are ideal.

A digital illustration of a room lit with many WS2812B LED strips, which are controlled by ESPHome.
An illustration of a room lit by white LED strips, which are controlled by ESPHome.

Mastering Dimming of Traditional LED Strips with ESPHome

For dimming traditional LED strips, two main methods exist: voltage regulation and pulse-width modulation (PWM). While voltage regulation has its merits, implementing it with ESPHome can be challenging. PWM, however, is user-friendly and compatible with ESPHome.

Voltage regulators can generate a lot of heat, requiring cooling solutions. PWM, in contrast, rapidly switches the LED strip on and off, allowing brightness adjustment by changing the on-to-off time ratio.

This discussion leads us to a notable ESPHome project by GitHub user eoncire, who created under-cabinet lighting in their kitchen using high CRI traditional LED strips controlled by an ESP32. The ESP32's firmware, developed ingeniously using ESPHome, showcases the potential of integrating traditional LED strips into smart home setups.

Essential Components for High CRI LED Strip Control with ESPHome

Embarking on an ESPHome project to control high CRI LED strips requires specific components beyond standard electronic equipment like a soldering iron. Essential items include an ESP32 board, a MOSFET, and a resistor. Let's delve into these crucial elements.

The Versatile ESP32 Board

The ESP32 board is the project's backbone, offering two significant advantages. Many ESP32 boards feature a built-in voltage regulator, allowing direct power from a 12V supply, which conveniently matches the LED strip's voltage needs. This negates the necessity for a separate down-regulator. Additionally, the ESP32 surpasses the ESP8266 with its hardware-based PWM output, offering multiple PWM-capable GPIO pins for controlling various zones with one board.

MOSFET: The Pulse-Handling Powerhouse

A MOSFET is pivotal for handling the PWM pulses from the ESP32. Known for high input impedance, low power consumption, and fast switching, MOSFETs regulate voltage and current flow between the source and drain, acting as a switch in this ESPHome node. Select a MOSFET compatible with the 3.3V output of the ESP32's GPIO pins.

Power Supply: The Driving Force

A suitable power supply is vital for any electronics project. Calculate your LED strip's power needs and select an appropriate power unit. For larger setups, consider multiple power supplies for different strips, as done by the project's creator.

Esphome Pwm Led 4

The Finishing Touches

Complete your project with additional items like a breadboard or prototype PCB, a 10k ohm resistor, jumper wires, a soldering iron, and screw terminals for LED strip connections. For detailed hardware lists, schematics, and wiring info, check the creator's GitHub repository.

Esphome Pwm Led 5

Crafting the Firmware with ESPHome

With all components connected to the ESP32, it's time to develop the firmware using ESPHome. The creator's firmware, available on pastebin, is simple and utilizes the ESP32 LEDC Output component in ESPHome. This integration allows the strip to appear as a dimmable light in Home Assistant.

Esphome Pwm Led 2

An Essential ESPHome Endeavour

Unlike previous ESPHome projects focused on luxury or novelty, this project addresses a fundamental need in modern smart homes. It offers high-quality, dimmable lighting for daily activities like cooking and seamlessly integrates with Home Assistant, enhancing the functionality and ambiance of your living space.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...