loading

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

https://www.instructables.com/id/An-inexpensive-IoT...

IoT Wall Outlet with Arduino and ESP8266

https://www.instructables.com/id/IoT-Wall-Outlet-wi...

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

  1. ESP8266 ESP-01 chip
  2. Arduino Pro Mini 328 5v or clone
  3. WS2812B LED strip. I used around 3 meters.
  4. 4 x 220v to 5v 2A power supply modules
  5. LM1117 3.3v LDO
  6. 100 uF electrolytic capacitor
  7. 5v relay
  8. PN2222A transistor
  9. 1K 1/4w resistor
  10. 220 ohms resistor
  11. LED
  12. 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:

https://github.com/tangophi/iot_mood_light

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

http://netio.davideickhoff.de/editor

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:
https://github.com/tangophi/iot_house

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

https://www.instructables.com/id/IoT-Wall-Outlet-wi...

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.

They are:

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!

<p>Truly a great instructable but could you put your apk file here to. I have tried to design a app with NetIO but it is pretty hard. It would be really great if you would post your app here. </p>
<p>Thanks!</p><p>I am not sure how to post the apk file of the NetIO app here. Even if i did, its not going to help you much. Because the config of my NetIO points to the node-red instance in my house and hence wont work for you. </p><p>Instead, I have downloaded the json file of my app and have uploaded it to another git hub repo, the link to which has been updated in &quot;Step4: Code&quot; section of this instructable. You can download that json file and &quot;Upload&quot; it in NetIO UI editor and then can customize it for your needs. Remember, you need to change the IP address of the &quot;newConnection&quot; in the Connections section of the config.</p>
<p>Hi ... Gopi, </p><p>1 word AMAZING!!!</p>
<p>Thank you :)</p>
<p>Thank you for an inspiring build! I'm itching to get something similar going. Unfortunately without app-capable devices, I'm a bit dead in the water. Any chance you'd know a way to control it through a basic browser-based web app?</p><p>The capabilities are fantastic! I'd love to see some sensors, adaptation to occupancy and light level, maybe even some kind of machine learning to adapt to user behavior and preferences...but here I go going overboard again. :D</p><p>Keep being rad awesome!</p>
<p>Thanks!</p><p>Yes, it is absolutely possible to do this project without an app. You can run a web server on the ESP8266 module. And you can control the LEDs through a web page from that server. Only the code on the ESP8266 would need to be different. There are plenty of resources on the web on how to run a webserver directly on the ESP8266 module. By following such help, you can create a webserver and code it in such a way as to give you the ability to control the LEDs. Then you can send the commands to the Arduino through the serial port.</p><p>Alternatively, you can get rid of the Arduino itself and just do everything with the ESP8266 module itself. Again there are many resources on the web that show you how to control WS2812b LEDs from the ESP8266 itself.</p><p>There is another way too. You can include an IR receive on the Arduino and use a normal IR remote control to control the LEDs. Please refer to my earlier instructable (IoT Wall Outlet with Arduino and ESP8266) for some pointers.</p><p>You can also add some sensors to adjust the light level according to the occupancy. That should be possible with just the ESP8266 or a combination of ESP8266 and Arduino. For real machine leaning stuff, you may eventually find that these may not be enough and you may have to include a central raspberry pi or some other cloud based solution.</p>

About This Instructable

7,299views

110favorites

License:

More by gopinath.marappan:IoT Power Strip IoT Mood Lighting IoT Wall Outlet with Arduino and ESP8266 
Add instructable to: