Introduction: Color Synchronized Touch Lamps
For this project we will make two lamps that are able to change their color by touch and that can synchronize this color with each other over the internet. We used this as a Christmas gift for a friend who moved to another city. She got one of the lamps and the other one remains with us. This way we both have a nice looking lamp while also being able to send colors to each other. This is a nice and cool way to communicate with one another even if apart and a much more lightweight form of communication than through text, voice or pictures.
This project is inspired by the Syncenlight project of the german radio show Netzbasteln, although we have modified the software quiet a bit and build more sophisticated lamps for our project. In the video you can see how it works. For demonstration purposes the two lamps are standing directly next to each other – but it would even work if they were on opposite sides of the planet (as long as there is WiFi).
Step 1: Skills, Tools and Parts Needed
As we need to solder the electronics of the lamp the only special skills required for this project are soldering skills and a basic understanding of electronics. If you understand some basic things about software development that would be a plus, because you could modify the software to your needs. But if you just want to use it the way we did it, you can just download the software and upload it to your own lamp.
The parts that are needed for the lamp can be seen in the picture above. If you want to build it exactly like we did then this is what you need :
- a 100kΩ resistor
- a Wemos D1 mini (or any other ESP8266 based board)
- some WS2812B LEDs (either single ones or a strip of those)
- some cables
- a USB cable (same kind that is used for most smartphones, needs to be a data cable)
- a metal flowerpot
- a glass vase
- a can of ice flower spray (or something similar)
- two wood sticks
- a small piece of cardboard (the size of the Wemos D1 mini)
The last five items on this list are the ones that we used for one of our specific lamp designs. This is the lamp design we will be using as an example in this Instructable. You can build your own lamp exactly like this one but of course you can also get creative at this part and design your own lamp however you want to. As you can see in the pictures the second one we build looks different than the first one and we already have ideas for new lamp designs. So this is the part where there are almost endless possibilities.
Of course we do not only need the parts but also the tools to put everything together. For this we need the following items:
- a soldering iron (plus solder)
- some sandpaper
- a pair of scissors
- a hot-melt gun
- a wood saw
Now that we have everything we need, we will explain the basic idea of the lamp, how it all works and of course how to build the lamp.
Step 2: The Basic Idea and How It Works
The basic idea can be seen in the wiring scheme. At the heart of the project is the Wemos D1 mini board which has an ESP8266 microcontroller. The advantage of the ESP8266 is that it is cheap and has WiFi directly on board, which is exactly what we need. We used the Wemos D1 mini board because with this board you do not need any extra tools to upload the software onto the microcontroller (apart from a standard USB data cable). But any ESP8266 based board should work for this project.
To control the lamp we want to use a capacitive touch sensor (so the same basic principle used in most smartphone displays). Such a touch sensor can be constructed by connecting a 100kΩ resistor with two pins of the ESP8266 (in our case pins D2 and D5) and then connecting an additional wire to pin D5 and then soldering that wire onto a metal plate. Where you solder this wire depends on the lamp design that you choose. In the wiring scheme we just used a generic metal plate but for our specific lamp design we soldered this cable to the metal pot part of the lamp. If you are interested in how this works exactly there is a good explanation at the website for the Arduino library that we used for programming the capacitive touch sensor.
Now that we have something that we can touch to control the lamp the next thing we need is a light source. For this we used WS2812B LEDs. Those are widely used in various projects and their main advantage is that you can control the color of numerous LEDs using just one data connection between the first LED and the microcontroller (in our case connected to D8 of the ESP8266). In our project we are using four WS2812B LEDs. In the wiring scheme two are shown but adding additional LEDs works exactly like adding the second one: The DOUT pin of the second LED needs to be connected to DIN of the third one and VSS and VDD need to be connected to the ground pin and the 5V pin respectively. Those WS2812B LEDs can then be programmed easily, e.g. with Adafruit's NeoPixel library.
Now we have all the ingredients we need: a microcontroller with WiFi capability, a touch sensor for controlling the lamp and the light source itself. In the next steps we will describe how to build the actual lamp and how to upload the software and what needs to be done so that two (or more) lamps can synchronize over the internet.
Step 3: Soldering the Electronics
So first of all we need to solder all the electronic parts together. We started by soldering the single WS2812B LEDs together (as shown and described in the previous step). If we would do this project again we would probably just buy the WS2812B LEDs in strip form. Those strips can be cut so that you have exactly the amount of LEDs that you want and then you just need to solder the DIN, VDD and VSS connectors of that strip to pins D8, 5V and G of the ESP8266. This would be easier than doing it the way we did it, but soldering the single WS2812B LEDs together is also possible as can be seen in the pictures (although our soldering joints are not very beautiful – but they work)
Next we soldered the resistor between pins D2 and D5. At pin D5 we also need to solder on an additional wire which will then later be soldered onto the part of the lamp that should function as the touch sensor. In the pictures you can see that we did not solder the resistor directly to the board, but instead soldered connectors to the board in which we then put the resistor. This was because we wanted to find out which resistor works best for this project but you could also solder the resistor directly to the board.
As a last step we can now connect our USB cable to the USB plug of the Wemos D1 mini (make sure that you have a USB data cable – there are also cables that work just for charging but not for transferring data, but we need the data capability to flash the software later on).
Step 4: Building the Lamp
Now that the electronic parts are ready we can start making the actual lamp. For this we want to illuminate the vase from the top with our LEDs and we want the light of the lamp to be diffuse. Because the glass of the vase we found is very clear we used Ice Flower Spray to give the glass a more frosted look. There are several versions of spray available that can give glass a more frosted or diffuse look so you can just look what you can find. If you use this spray make sure that everything is well dried before you continue. This can take several hours depending on the spray you are using.
To now build the lamp we need to make sure that the metal flower pot stays on top of the vase at the right height and that the electronics are affixed inside the pot so that the LEDs illuminate the vase. To do this we used the two wood sticks, the sand paper and the wood saw to make a cross. This cross will sit on top of the vase and the ends of the cross will be glued to the pot. That way we can make sure that the pot is at the right height (if the wood cross has the appropriate size).
To do this we first used the saw to get the wood sticks to the right size. Then we used the sand paper to sand a groove into the middle of one of the sticks. Now we glued the other one into the groove with the help of the hot-melt gun. If we would put this on top of the vase it would not fit well, because the sticks are not at the same level. So we sanded two new grooves at the ends of the stick that is at the lower level, so that the cross fits perfectly on the vase. This can be seen well in the pictures.
If everything fits well, the next step is to glue a piece of cardboard on top of the cross. This has to be on the side of the cross where there are no grooves. Then we glued the Wemos D1 mini board on top of the cardboard and the LED's on the other side of the cross.
The next step then is to solder the cable for the resistive touch sensor to the metal pot. This way we can control the color of the lamp by touching the pot. If this is done the wooden cross can be glued to the metal pot with the hot-melt gun and afterwards the cross and pot can be glued on top of the vase.
As a last step we can now glue the USB cable with the super glue to the vase so that everything looks nice and tidy. Now we are almost done.
Step 5: Put It Into Operation
The last step is to upload the software onto the lamp and to configure the server that will be used for the synchronization of the lamp. If you are interested in how the software works exactly you are welcome to study the source code, we will not go into too much detail here. But the basic idea is that each of the lamps that you want to synchronize needs to be connected to the same MQTT server. MQTT is a messaging protocol for the internet of things and machine to machine communication. If one of the lamps changes its color, it will publish this to the MQTT server which will then send a signal to all the other lamps which then tells them to change their color, too.
But don't worry, you don't need to understand anything about MQTT, how it works or how to set up a MQTT server if you just want to use the lamp. Of course you can set up and configure your own server if you want to. But if you do not want to do that there are also several services available where you can rent a MQTT server hosted in the cloud. We used CloudMQTT for this, where you can get a very limited server even for free (but with enough functionality and bandwith for our purposes). The free plan is called Cute Cat and if you get one of those you just need to look into Details→Instance Info and there you can see the Server, the User, the Password and the Port of your MQTT instance. Those values are all you need, so write them down :-)
Now to upload the software onto the lamp you need to connect the USB cable to your laptop or computer and then you can upload the software using the Arduino software. How to install and configure the Arduino software for use with ESP8266 based boards is explained well in this Instructable, so we don't need to repeat those steps here.
After you installed and configured everything you need to go to Tools→Manage Libraries in the Arduino software and install the libraries that are needed for this project: Adafruit NeoPixel, CapacativeSensor, PubSubClient, WifiManager (in version 0.11) and ArduinoJson (in version 5, not the beta 6 version). If those are installed you can download the source code for the lamp from our Github repository for this project and upload it to the lamp using the Arduino software.
If everything went well, the lamp will now start up and is ready to be used :-) While starting up it will swoosh in blue color and try to connect to a known WiFi. At the first startup the lamp obviously does not know about any WiFi's so it will start up its own Hotspot (with a name that is a combination of "Syncenlight" and a unique identifier for the ESP8266 that you used). You can connect e.g. your smartphone to this WiFi and you will be directed to the configuration page of the lamp where you can configure your WiFi credentials and also enter the required settings for the MQTT server (those you needed to write down a few paragraphs earlier). If you are done with that the lamp will reboot and is now completely ready for use!
Let us know how you liked this project or if you have any questions, we hope you liked this Instructable :-)
Participated in the
First Time Author