Wi-Fi Controlled RGB Mood Lamp - a Philips HUE Alternative
by MatijaHardi in Circuits > LEDs
2000 Views, 16 Favorites, 0 Comments
Wi-Fi Controlled RGB Mood Lamp - a Philips HUE Alternative
In this Instructable I'll show you the process I went through to make a custom-ish mood lamp that you can control with your phone, tablet, computer or anything else that has a browser connected to the internet. I will also talk a little about how unnecessarily complicating your designs can lead to failure.
I got the idea to make this lamp when I first saw the Philips Hue GO lamp and realized how disgustingly overpriced it is. My original concept for it was a little different then how it turned out to be but that was the unnecessary complicated part. The idea I had in mind at first isn't impossible to make I just became way too frustrated with it and damaged quite a number of parts I didn't have on hand anymore. For this reason I will try to incorporate both my original idea and the final outcome into one Instructable, so if you try to make one for yourself you can choose which path to take.
Supplies
Parts needed:
3D printed parts - you have to print those yourself
5V RGB LED strip - mine was individually addressable but this is not necessary, I recommend getting the 30 per meter variant so it's easier to bend into place
An ESP board - really any will work so I used a NodeMCU board but something like a D1 Mini or an esp-01 module would work better as they are a bit smaller
Apple 5 W USB power adapter - the choice of power supply is completely up to you but I chose this one because I have a lot of them lying around but if you do choose a different wall adapter you will have to redesign the case to fit
USB connector - I found one that was already cut from a cable but you can use a new one
NFC tag - optional but recommended for extra swag
Parts that I originally thought of using but didn't in the end:
18650 li-ion battery - any will work but the higher capacity you choose the longer it will work unplugged
Power switch - I pulled mine from a remote control car
TP4056 battery charger with protection and 5V step up module - alternatively you can use a powerbank module to reduce the overall number of boards
Tools I used:
3D printer
Soldering iron
Hot glue gun
Lots and lots of super glue and epoxy (not tools but I used a lot)
The Design, the Case and Some Printing
The design of the lamp itself is heavily influenced by the aforementioned Philips Hue GO lamp. My prime thought was for it to be plugged into a wall outlet and radiate mood light from the corner of a room so it was designed to attach onto the USB wall adapter and direct the light upwards.
I began the design by first tracing the shape of the wall adaptor and using that as a shell, once I had that, I built the rest on top of it. I had to make sure that all of the components would fit and I had the most concern about the battery so I made a cylinder to act as an 18650 and constantly cross-checked with it in a SolidWorks assembly. This is the first time I started to question my idea of having the battery inside but I kept with it for the time being.
When I completed the parts I printed them and to my huge surprise everything fit together on first try, that gave me quite a boost in my confidence in the project.
I printed the parts using the normal preset in Ultimaker Cura with 0.15mm layer height.
The Circuit
The circuit in both the full, and the I gave up versions, is quite simple. It consists of the microcontroller board and the strip. If you opt to go the full send Philips route, you need to add only the charger/controller board and the battery.
The fritzing circuit I included shows the complete schematic which isn't too complicated.
Note: the charger board, battery, USB connector and LED strip are only symbolic
You can try to hook up all the parts on a breadboard beforehand to see if everything works and so you get a better understanding for what's going on when you have to solder it together. It will also make the next step easier as you will have a completed circuit to test out the code.
The Code
To make the lamp work we need some code. Nothing too complicated or difficult to figure out so you shouldn't have any problems. In the past I tried several times to make a HomeKit compatible, Siri activated, "smart" lamp but failed every time because either my code or the Homebridge server wouldn't work how I wanted it to. With numerous failures behind me, I decided to take the arguably worse but much simpler to program path of action.
The way it works is that the board, (Esp32, Esp8266, Arduino wi-fi...) basically becomes a webpage server that sends an HTML page to any client that connects to it. An added benefit to it is that because it is standard HTML, the lamp can be controlled by any device with browsing capabilities, as long as it's connected to the same local network. If you are more interested in how the code works you can check out the code comments.
For this Instructable I will assume that you know how to upload a sketch to an Arduino board but in case you don't or are having problems you can check out the guide here.
Before uploading the code to the board you have to make some adjustments that are specific to your network. First configure the ssid variable to whatever your Wi-Fi network name is and the password variable to whatever your Wi-Fi password is. Once this is done upload the sketch to your board and it should connect to the Wi-Fi, if it does, it will print out its IP address in the serial monitor. To open the serial monitor press ctrl+shift+M on your keyboard while in Arduino IDE or press the serial monitor symbol in the top right corner. Once you have the IP address, (something like 192.168.x.x) change the "1.1.1.1" part of the wifi.config() function to that address, uncomment the function and reupload the sketch. Now the board is configured to have a static IP. At this point if everything works you are done with the software part.
Downloads
This Is Where the Work Begins
The first real thing to do once you have all the parts gathered, (with your board programmed) is to fix the USB connector in place. To make sure the connector is centered and straight in place, plug it into the adapter and slide the whole thing into the case. Once it is in place and the adapter slid in all the way, apply a generous amount of hot glue to the connector from the inside of the case. Wait until the glue cools down and then pull the adapter out of the casing so it's not in the way.
Note: the connector shouldn't have anything soldered to it yet as you won't be able to pull the component through to the other side
Once the connector is in place you can test out the placement of all your components. The configuration I chose required me to bend the pins on my NodeMCU. You also might have to do that so you can consult the notes in the photos four through eight in this step.
Some Soldering
I began my soldering journey on this project by first taking the USB connector off of the step-up module, so it would be easier to solder to it and to save space inside the case. This depends on your specific module and whether or not you chose to include the battery functionality so you might not have to do this.
Once the module was free of its connector I soldered everything together with some wires so that the connection goes: USB connector --> battery charger --> step-up module --> NodeMcu, as shown in the photos. When everything was wired up I used hot glue to fix all the components in place. I also used electrical tape to cover up everything from the inside so it wouldn't leak light through the case. Mylar foil would be a better choice as it would reflect all the light back through the front but it is a bit trickier to put in place and it wouldn't make any drastic difference.
Never Ever Ever Do This
Disclaimer: you really shouldn't do it like this
This is where everything went sideways and I started to question my electronics and soldering capabilities because I gave it almost no thought whatsoever and I broke everything. For the lamp I used 15 led strip LEDs, so on a 30-per-meter strip, half a meter. I cut up the strip into individual "pixels" and then glued them to the lid piece following a circular pattern making sure they are all going in the same direction (yes, individually addressable strips are directional).
Why are you still reading this? I said you shouldn't do it like this
When all of the LEDs are glued to the lid, solder every piece together back into a strip. As you can tell on the photos it's not pretty nor easy nor better to do it this way so please don't. The reason I chose to do this is because I couldn't think of away to put the LEDs on densely enough.
What happened in my case is that I flipped one of the LEDs (left to right, not length-wise, I don't know how) and when I connected it to the board and plugged it in every single LED got fried, the step-up module freaked out and blew up and the battery went down to 1.8 volts (so... fried). I first thought it was only the step-up module so I ditched all the battery circuitry and tried to connect the USB connector directly to the NodeMcu, luckily it didn't get damaged from all my testing but when I figured out what was broken I was too frustrated to put the battery and everything else back. Hence the lite version of the lamp.
If you read all of this, congratulations, you now now why I re-did it
Take Two, Also Known As "the Correct Way"
After my initial failure I went back to thinking about how I can fix the LEDs in place and figured out that it is much easier then I thought it was and just bent the strip into place, gluing each LED in place with superglue. You need a strip 15 LEDs long as that's what's in the code and any more than that would draw too much current from the wall adaptor.
Done
Making the NFC Tag
Adding the NFC Tag
To begin with, you need to take the tag that you made in step 8 out of its casing. If it isn't in a case like mine was, you're golden, if it is take it out with super extra care not to brake it. When I was taking it out I was still frustrated by the strip malfunction so I went to aggressively and broke it so I had to commence the Solder Of Shame.
Note: the Solder Of Shame is an action you take when you have to fix something you broke while being careful not to break it
If you didn't brake your tag (or did and then fixed it) place it inside the case underneath the electrical tape, by the top. Try not to bend it too much out of a circle when putting it in place because if you do it might have issues being scanned easily. To see if you placed it right try tapping your phone to it and see if it scans, as this is a standard NFC tag it doesn't require power to be read so if it doesn't work, you did something wrong.
Connecting the Two Halves and Closing It Up
So now that everything is pretty much assembled, all that's left is to close the case and use the thing.
I began by first supergluing the switch in place on the inside of the lid. When gluing it, take care not too put too much superglue or you will glue the switch into one position, rendering it useless.
Next up is connecting the LED strip to the leads we left loose in step 5. I soldered headers to the leads from the board and had female jumper wires soldered on the strip from before so I simply plugged it in but if you don't have or don't want to put headers on, it is faster, simpler and more secure to solder it directly onto the leads.
If you (unlike me at this point) left your battery circuitry in place, connect the battery as well. For this I recommend getting a battery with solder tabs (like mine had, check the photo in the parts list) as it can be dangerous to solder directly to 18650s. If you chose to use a Li-Po add a connector to the lead instead of soldering it directly.
When everything is soldered, plug the lamp into a power outlet to make sure everything works, if it does, you can seal it. Begin by placing the lid roughly into place and then secure it with electrical tape, as you tighten each piece it should center and level itself. Once you're happy with the placement mix some epoxy and apply into the gaps to seal the lid in place.
Note: most epoxy glues take 24 hours to cure so just leave the lamp alone for at least over night or you will end up with it being misaligned
You're Done!
Congratulations! You have made your very own Philips Hue GO lamp on the cheap.
Now to go over some functionality. The lamp will automatically connect to your Wi-Fi network, if in range, as long as it is turned on and plugged in, (or battery is charged) when it connects, the led on the back will start blinking. When it is connected you can open the "app" on any device you want and set it to whatever color. Using the built-in NFC tag you can tap your phone to the lamp anytime to quickly pull up the web app. In the app you can choose colors by tapping any color on the color picker or you can turn on campfire and rainbow modes.
The lamps functionality is the same whether or not you kept the battery in, the only difference is that without the battery you can't move the light wherever you want without it being plugged in.