In this blog post I will explain how to create a portable WiFI controlled ambient light from scratch. Alongside these lights I built an IoT platform to control the lights that I built. I will explain how to build the IoT platform in a different blog post. I will break this blog post in to consumable chunks. I try to keep it simple as most of the things I have done can be found online.
Check the code here
- IOT Platform
- Ingredients list for the light
- Circuit Design for the Lights
- Testing the Neo Pixels
- Code for the ESP8256
- 3D Printing
- Calling the lights over the internet
This platform is almost written from scratch and uses some already existing services to have the reliability. This can be automated, but for the sake of testing I have written a web controller to control the IOT devices. I will explain on another post on how to create this platform. In the mean time you can use already existing IoT platforms to test the lights.
a. Web Controller
This is basically a UI that lets you control the devices connected to the IOT platform(MQTT broker). In order for that, it sends requests to the Python Server.
Code can be found here.
b. Python server
This server will decode the requests which it gets from the web controller and send them to the MQTT broker. You can host the server separately or in your own computer that you are running the web controller.
Code can be found here
c. MQTT broker
I have used Adafruits already existing MQTT broker. MQTT broker has the ability to send commands to the devices that are connected as well as to receive data from the connected devices.
2.Ingredients List For the lights
ESP8266, NeoPixel ring(12), Wires, Resistors (230 ohm), LiPo battery (3.7v, 850mAh) and a 3D printer.
3.Circuit Design for the Lights
This is a simple circuit design to connect all the components and you can find the sketch below. You can improve this circuit by adding switches etc. Since this was a rapid prototype, I did not add those improvements.
4. Testing the Neo Pixels
You can check if the neo-pixels are working using croc cables.
5. Code for the ESP8256
This is basically a sample code got down from the internet and adjusted according to my need. The code is basically self-explanatory and if you have any unclear parts please ask question as comments.
link to the code to be uploaded to the ESP8266.
If you want to start from scratch use this link as a template.
6. 3D Printing
I will share the designs of my light’s case, which is actually a very basic design. You can build something which is much cooler and also effective in filament usage on your own. I used the AutoDesk’s Fusion 360 software to design the case.
Link to the already finished designs.
You can place the circuit inside the box as follows.
Note : this container is different to the STL files I have provided.
8. Calling the lights over the internet
After powering up the lights, it is required to send a request to switch on the lights. I will cover this part in a separate post.
How it actually works
Let me know what your experience on building portable lights. Good luck with your lights and the IoT platform.