Controlling a Three-Channel LED Strip with an ESP32

Home, Bangkok, Thailand, 2019-08-18

#iot #esp32

 

Today I put together my first circuit and code for driving a three-channel 5V RGB LED strip. This is part of a larger project to put a set of lighting strips into the new media cabinet that we got for our lounge room which will consist of:

  • In-cabinet lighting for the four cupboard doors with a trigger to turn them on when the door is opened.
  • One or two strips running the full length underneath the cabinet
  • One or two strips running the full length along the back of the cabinet

Along with this will be code to set the color scheme of the full suite of strips as well as to alter the lighting automatically via a webhook when media is played in Plex.

I have a bunch of addressable LED strips on hand but I’ll just be using three-channel strips for everything on the cabinet as there’s not really a need for per-LED control in this application.

Now that I’ve got the basic hardware and software working the next step is to put together a working setup for the first under-cabinet strip controllable over the network - probably via MQTT.

Here’s what it looks like running:

Here’s the circuit:

Here’s the code:

This build was based on these two posts from randomnerdtutorials which cover three channel LED’s and how to use PWM:

  • https://randomnerdtutorials.com/esp32-esp8266-rgb-led-strip-web-server/
  • https://randomnerdtutorials.com/esp32-pwm-arduino-ide/