Unfortunately, the out-of-the-box support of RGB LED strips in Domoticz is disappointing. With this blog post I show you how you can implement RGB LED strips in your home automation system and smart home!
Switch on your RGB (W) LED strip, change the color and brightness from domoticz with the help of a simple circuit, WiFi and ESPeasy!
Requirements for connecting an RGB LED strip to an ESP8266
There are many types and sizes of LED strips for sale. Often they are 5 meter RGB LED strips. They are for sale at the discount supermarkets, bol.com and aliexpress. Nowadays they can be bought everywhere.
The content of the package often contains a plug adapter (Note! Not always, there are also only strips for sale, for example to expand your set that you already have!) And a control box with remote control with color presets. With the solution that we are going to make, we only need the LED strip and the adapter. The controls will run via domoticz, in combination with ESPeasy and WiFi. So, to control the LED strip with WiFi and add it to your (Domoticz) home automation system, you still need:
To order in China
Wemos D1 mini , an ESP8266 WiFi chip with USB2serial converter on a compact board. You only need to connect with USB, install software once (flashing). Then works completely via WiFi. Automatically goes into flash mode etc .. Remember that you need a micro USB cable .
3 pieces of TIP31C transistors , one piece for each color. It is also handy to order cooling bodies. If you use an RGBW strip, then you need 4, if you have a warm white or another single color LED strip, then you only need 1 TIP31C transistor.
1x 12v -> 5v converter L7805 (CV). You will need this if you want to connect the ESP to the same power supply as the LED strip. In my case the LED strip was 12V DC with a maximum current of 3A so I chose the L7805. This voltage converter converts 12V to 5V, 1.2A on which the Wemos works. It does get a bit warm so it is best to order a cooling body for this too.
Other components that might be handy
It is useful to solder male headers to the LED strip and female to the PCB. So you have a neat plug connection that you can disconnect for maintenance (firmware update) or solving other problems. You can also use screw terminals , but then you lose a little more space on your circuit board.
Make sure that the components can also handle the maximum current. A long LED strip can demand quite a bit of power! The above parts work well for a 12V RGB LED strip of 5 meters.
You also need some soldering equipment such as a piece of printed circuit board (grid 2.54 mm), tin, soldering iron, some wire and patience 🙂
To complete this project you need some electronics and soldering experience. Don’t you have that? Then take a look at the beautiful Yeelight LED strips from Xiaomi . Yeelight works out of the box with Domoticz and you don’t have to solder!
Connection diagram RGB LED strip on the ESP8266
Always check whether the functions (IN / OUT / GND) of your connection pins match the connection pins of the drawing above.
ESPeasy flashing on the Wemos D1 mini
To be able to control the RGB LED strip with WiFi and home automation, we are going to flash ESPeasy. With this you can easily operate and adjust everything.
Because ESPeasy does not offer good support for LED strips as standard (only the basic PWM functions), it is best to flash a modified and self-compiled version of ESPeasy .
Do you find compiling yourself too difficult? You can download a modified version here. This version I made for a Wemos D1 mini but also works for other modules that are based on a 4MB esp8266 (see comments). I am not responsible for any form of damage or brickening of your device!
Place the above file in the same folder as the flash tool below and select the correct COM port.
Then continue below.
The ESP uses PWM (Pulse Width Modulation) to control the levels of the colors.
When we control the LED with a PWM signal, the LED will switch on and off at high speed. When the frequency used is high enough, the slowness of the eye will cause the LED to appear softer. (source: Wikipedia )
Why choose custom firmware?
With ESPeasy you can already send PWM commands out-of-the-box. You must give a separate command for each pin (= color):
IP address espeasy/control?Cmd=pwm,PIN,VALUE 0-255 for example, to enable pin 12 (that is, for example, red): IP address espeasy /control?Cmd=pwm,12,255 off: IP address espeasy /control?Cmd=pwm,12,0 To make white you have to give 3 commands (all 3 colors in full) IP address espeasy /control?Cmd=pwm,12,255 IP address espeasy /control?Cmd=pwm,13,255 IP address espeasy /control?Cmd=pwm,14,255
So you have to send the value (0 to 255) per color via the URL. Because I want to adjust the colors with one click with domoticz I have to be able to adjust all colors at once with one URL. With the standard ESPeasy version, that is not possible without all kinds of scripts. That is why we have flashed the modified version.
Set RGB LED strip in ESPeasy
If the flashing and configuration of the modified version is successful, you can set ESPeasy to control the LED strip. How to do the basic settings read in my blog post “How to flash ESPeasy on a Wemos D1 mini” . Go to the ESPeasy page in your browser.
- Click on the devices tab
- Click on line 1 on Edit
- At device choose RGB LED strip
- Enter the correct ports to which you have connected the colors.
- Also don’t forget to tick “enabled”. You do not have to enter “Send to controller”. That doesn’t work (yet).
- Click submit
- You can now control the LED strip via a URL command. A few examples: (replace the dots with the IP address of your ESP!)
LED strip off: ../control?cmd=RGB.0.0.0
You can now make a color with one URL command instead of sending 3 separate commands. The first digit stands for Red, then Green, then Blue. With the value 0 the color is off, with the value 255 it is full on. This way you can mix the colors. You can make your own colors with the RGB color mixer at the bottom of this page !
Other RGB commands
The plugin that we use has support for even more commands! Below you can see a list:
- RGB, <red 0-255>, <green 0-255>, <blue 0-255>
- HSV, <hue 0-360>, <saturation 0-100>, <value / brightness 0-100>
- HSL, <hue 0-360>, <saturation 0-100>, <lightness 0-100>
- HUE, <hue 0-360>
- SAT, <saturation 0-100>
- VAL, <value / brightness 0-100>
- DIMM, <value / brightness 0-100>
- CYCLE, <time 1-999> time for full color hue circle; 0 to return to normal mode
Add LED Strip to Domoticz
Domoticz has out-of-the-box support for RGB LED strips. That support seems nice, but it doesn’t work for a meter. The color is not stored in the database and is only sent to the device itself. We use a device that is not officially supported. That is why the command is not sent to the LED strip in the correct format, and then nothing happens. We also cannot build a script around it because the color is not saved. So we go to work ourselves, with a different approach.
- Create a “Selector switch” dummy.
- Go to the switch overview and click on customize and create (for example) the following options:
Enter the following URLs as “script url”: (where the dots: http: // is your ip address of esp /)
Has it succeeded, or is it still not working properly? Let us know in a comment!
You can expand the LED strip controller even further! In the living room it is useful to measure the temperature or the light by means of a lux meter , so that you can switch your LED strip on and off based on the available light as soon as you get home!
What did you think of this article?
Enter your vote via the stars below. Let us know what you think of the article and ask your questions in the comments!
Jammer dat de post niet behulpzaam was.
Laten we deze post verbeteren!
Wat zou er beter kunnen?