Introduction: IoT Mood Lighting
In this instructable, I show how a simple app controlled mood light can be designed and constructed using an Arduino, ESP8266 and WS2812b LED strips.
This is the third instructable in the series of home automation related instructables that I have done so far. The first two are:
An inexpensive IoT Enabler using ESP8266
IoT Wall Outlet with Arduino and ESP8266
Step 1: Need and Design Considerations
In my apartment, I have just a tube light in my living room. There are of course provision to add more lighting. But thought it would be cool to have something that changes color/brightness.
Wanted to do this in a way that looks minimalist without any unnecessary wires or boxes visible. Fortunately the tube light frame that I had was ideal for this purpose as it can hide most of the circuitry inside.
Step 2: Parts
- ESP8266 ESP-01 chip
- Arduino Pro Mini 328 5v or clone
- WS2812B LED strip. I used around 3 meters.
- 4 x 220v to 5v 2A power supply modules
- LM1117 3.3v LDO
- 100 uF electrolytic capacitor
- 5v relay
- PN2222A transistor
- 1K 1/4w resistor
- 220 ohms resistor
- Perf board
The LED strip costs around US$13 a meter on eBay.com. The rest of the components would cost less than $15-20 in total.
Step 3: Circuit
The circuit is pretty straight forward. The Arduino Pro Mini is used to control both the relay and the WS2812B LED strip. The relay is used to turn on/off the tube light. ESP8266 is connected to the Arduino through the serial port and that receives commands through WiFi and sends it to the Arduino.
The Kicad files of the circuit can be found in the room_light_kicad folder at https://github.com/tangophi/iot_mood_light .
Step 4: Code
The Arduino sketch and the source code for the firmware of the ESP8266 module can be found at:
The firmware of the ESP8266 modules is based on the esp8266 open sdk. Instead of the SDK, Arduino IDE can also be used.
The general idea is the ESP8266 module subscribes to various MQTT topics. And the NetIO smartphone app sends socket messages to the node-red instance on the raspberry pi. Which in turn sends appropriate messages to the MQTT topics. When the ESP8266 receives these messages, it sends JSON strings to the Arduino Pro Mini through the serial UART port. And when the Arduino receives these strings, it will perform the appropriate action like turning on/off the tube light, turning on/off the LED strip, change the color/pattern of the LED strip, etc...
Step 5: Assembly/Installation
As can be seen from the photos, the whole circuit can be fitted inside the frame of the tube light. The wires from the mains and the tube light should be connected as shown in the circuit diagram.
For mounting the LED strip, i used pieces cut from the corners of a cardboard box. Screwed these pieces to the top of the frame. Then used two sided tapes to stick the led strip to the cardboard pieces. And finally used some wires to secure them properly.
Step 6: LED Power Requirements
Each WS2812b LED draws around 50mA with all the three component LEDs (Red, Green and Blue) at full brightness. Hence, depending on the number of LEDs that are in the strip, the power supply should be proportional.
I have used two daisy chained strips with a total of 143 LEDs. That comes up to 7.1 Amps @ 50mA each. Hence, I have installed a total of four 240 to 5v 2A power supply modules in this project.
It is not necessary to have four power supply modules. You an just do with one module with sufficient amps. The reason i have used four is because the form factor of the 2A modules perfectly fits in the tube light frame.
Step 7: Smartphone App
The smartphone app is built using the NetIO Design Editor at
Once the app is designed, the NetIO app should be downloaded to your smartphone. Note that this is a paid app, but it does not cost much.
Whenever a button/switch/slider is pressed in the app, it will send a message through sockets to the Rpi box that is running node-red. The node-red application will process the messages and then send MQTT messages to the mood lighting board.
The json files for the node-red flow and the NetIO based smartphone app are available at:
You can download these files and customise them for your needs.
For the smartphone app to work it should be in the same network as the IoT mood lighting board.
It is possible to use the smartphone app from outside the local network. If the ISP allows incoming connections, it is just a simple matter of forwarding the socket port on the router. If the ISP does not allow incoming connections, then VPN can be used as a workaround.
Step 8: Features
Using the smartphone app, I can do all of the following:
1. Turn on/off the tubelight.
2. Turn on/off the LED strip.
3. Change color/intensity of the LEDs.
4. Change patterns of the LEDs.
Step 9: More Details
For more details about how the various pieces fit together, please visit my second instructable at
That instructable is about another home automation project and has detailed descriptions about how another IoT board in my house is controlled by node-red and the smartphone app. The mood lighting project also uses the same node-red and MQTT instances.
Step 10: Suggestions for Other Makers
If you want to try to make this project yourselves, and if you don't have a tube light, you can still
1. Create this project and mount the LED strip anyway you want/need.
2. Create/modify a table lamp with LED strips.
It is also possible to make this project with just the ESP8266 (ESP-01 or ESP-12 preferably) itself. You dont need the Arduino at all. Also, there are several other ways to control the project in additon to the NetIO based smartphone app/node-red combination that i have done in my project.
1. By running a webserver on the ESP8266 module and controlling the project through a customized web page.
2. By including a IR receiver and controlling the project through a normal IR remote control.
3. By a touch screen LED.
Step 11: Conclusion
If you find this instructable useful in implementing any of your projects, it would be great if you could post some details as well as photos of them as comments.
If you have any questions/doubts, please kindly post them as a comments instead of sending a mail to my inbox. If its posted as a comment, it will be useful to all and I can reply as a comment as well.
Suggestions to improve this project as well as ideas for new features/functionalities are always welcome. Cheers!
Participated in the
Internet of Things Contest 2016