You could buy something like that for a few bucks.
Yeah, but I didn’t want to be tied to any API, app or remote control.
My intention was not to create a standard of DIY lights.
There are lots of options to buy or build better than this.
My idea was to control the whole process and use the LEDs as I please.
1.
Where to startNecessary things:A broken LED bulb (0US$).
A board with an ESP8266 chip (~5US$).
I used the Wemos D1 mini because it is widely used.
A tiny 5v adapter (~2US$).
The one I’ve used is not an iPhone adapter.
It’s a cheaper replica but it does its job pretty well.
NeoPixel LED Ring, 16 x 5050 Ws2812 (~3US$).
A few thin wires (0US$).
A broken micro-USB connector (optional).
2.
Connect and test the ringFirst, solder the ring and the Wemos like this:Basic Wiring (D6 is not mandatory)Install Arduino IDE (https://www.
arduino.
cc/en/Main/Software).
2.
Test the ring with this example made by Shae Erisson with some minor modifications:Necessary library: https://github.
com/adafruit/Adafruit_NeoPixel3.
Choose the board: LOLIN(WEMOS) D1 R2 & mini.
4.
Select the USB port:5.
Burn the example:Burning Code with Arduino IDEFinally, It should look like this:Dummy example runningBut it feels like:3.
Let’s burn the final codeYou have 2 options =>3.
1.
SHORTCUTDownload the project code: https://github.
com/cervgon/RRGGBB_Multicolor_LampOpen the lamp_begins file and change the SSID with your wifi network name and its password.
Then choose the local IP.
If you don’t know how the local IP should be, the easiest way to get it for any OS is visiting this site: https://www.
whatismybrowser.
com/detect/what-is-my-local-ip-address.
In my case, the local IP of my laptop is 192.
168.
0.
3, so I’ve chosen 192.
168.
0.
200 for the lamp.
Please, check twice the first 3 numbers of the IP and the gateway.
Otherwise it won’t work.
Lines 73 and 74 of the example.
Now, burn it in the same way you did with the project file you have changed.
3.
2.
Step by step.
Please read the comments of each code file.
4.
HTTP request.
Let’s set some colors.
It’s very simple.
Just call the local IP slash the HEX colors separated with hyphens.
That’s it.
With this code example, you can set 2^n colors up to 16: 1,2,4,8,16.
One color2 colors8 colors4.
1.
Back to the board.
Let’s make it red (#ff0000).
Go to your browser and GET:http://192.
168.
0.
200/ff0000It should look like this:http://192.
168.
x.
x/ff0000Instead of using your browser, you can use the Postman app.
4.
2.
Let’s set 2 colors(#ff0000 and #00ffa2).
GET:http://192.
168.
0.
200/ff0000-00ffa2It should look like this:4.
16.
Let’s make a rainbow.
http://192.
168.
0.
200/ff0000-ff6600-ff9900-ffff00-66ff00-99ff00-00ff00-00ff99-00ff66-00ffff-0066ff-0099ff-0000ff-9900ff-ff00ff-ff00995.
Let’s connect everything (complete wiring)WiringI left the micro USB port of the Wemos free in order to update the board and fix potential bugs.
If you want, you can solder both cables (VCC and GND) to the Wemos board, but that could be impractical.
You can use other digital pinout.
D6 isn’t mandatory.
Keep in mind that it is important to leave about 20cm (8") of cable between the 5v adapter and the tip of the cable in order to make the installation easier.
5.
1.
Detach the 5v adapter and solder the cablesProtect the soldering using hot glue6.
Assemble everythingHot glue the LED ring to the bulb caseTry to leave the antenna free like the picture abovehttp://192.
168.
x.
x/ff0000Top View: My new lock-screen wallpaper7.
Use examples7.
1.
ShortcutsIf you are an iOS user, you might use the Shortcuts application.
It’s really useful to create routines.
Let’s create one using the bulb.
Result:7.
2.
Watch OS appI’ve built this app for my apple watch in order to handle the lights from it.
You can change the quantity of colors in the picker using the crown.
Every colors triggers a GET call like GET http://192.
168.
x.
x/hex_color_hereWatchOS Color Picker7.
3.
Notifications instead of triggering manuallyI’ve crafted a Drip Irrigation System for my wife’s plants.
As you can see in the picture below, there is a tank full of water with 3 pumps inside it, one per each group.
Those pumps provide the plants with water.
At the top of the tank, there is an ultrasonic sensor connected to a Wemos which triggers notifications when the water level is too low or too high.
Too much water notification7.
4.
Etc.
Do whatever you wantMIND BLOWNConclusionThere are 256³ (16 million) possible colors using #RRGGBB notation using only one value.
If you use more than one color at the same time, the number goes too high.
I think it would be (256³)¹⁶=256⁴⁰⁹⁶ possible combinations.
So, enjoy playing with it.
In the second part, I’ll make the network changing easier without needing to burn the code again, and I’ll add more features.
Bonus Track: data backupI forgot to mention that using the lamp_with_data_backup code, every time you set a combination of colors, those values will be saved in the memory of the board.
So, if the power goes down or you unplug the power cable, the lamp will reconnect itself to the network and it will set the saved combination of colors.
Suggestions are more than welcome! Made with ❤.. More details