Introduction: Touchless Multicolor Lamp
On this instructable, we will create a touchless multicolor lamp. The reason to be a touchless lamp is it can be configured through the internet and control it with gestures over the lamp!
On the next video you can see who to use it:
This is a pretty simple project in which you can do it less of one day.
This lamp has an ultrasonic sensor on the top which is continuously measuring the distance. The measured data is sent to the micro-controller which decided with the distance which actions should run: Turn on, turn off or modify the brightness of the light.
On the other hand, this microcontroller, which is an ESP8266 runs a web server. This web server, allows you to modify the Wi-Fi connection data without modifying the firmware and most importantly, allows you to set thousands of different light colors.
If you're still interested and you want to build it or at least learn more, on the next lines I'll explain to you full of details! And one last thing, if you like it, I would highly appreciate that you vote to be selected on the LED Strip contest! Let's start!
Step 1: Flash the Micro-controller
For this project we're going to use the ESP12-F board. This is very tiny board but full of resources. On the list we can see some of the most interesting features:
- 32 bits CPU.
- 4 Mb of flash memory.
- 160Kb of RAM memory.
- 16 GPIO.
- Integrated IEEE 802.11 b/g/n Wi-Fi.
This part is optional to read! Is just a brief explanation of how it works the firmware.
The firmware split into different modules. The main file is "ulight_firmware.ino", these files have the hardware initialization and the main logic loop, calling on each CPU cycle to the measure logic and the web-server.
Then we have "web_sever.ino", this file initializes the Wi-Fi connection with a very interesting library called Autoconnect. This library gives you a web menu that makes you easy to give the connection data on runtime, avoiding modifying the firmware if you need to change it. On the other hand, this file contains a web server that runs a HUE color selector, which allows you to select any color you want graphically.
Finally, we have "led_control.ino" and "logic_control.ino", the first one, is just the logic to set the colors to the LED matrix and turn on/off the required LED and the last one has the logic to decide which state it should be the LED matrix. The logic is the next:
- The measure distance is less than 5 cm, it turns off the LED matrix.
- The measure distance is more than 5 cm, it turns on the LED matrix.
- The measure distance is more than 5 cm and the light is already on, it allows you to modify the brightness of the lights by the position of your hand.
- If the measure is higher than 10 cm, it will increase sequentially the brightness of the lights.
- If the measure is lower than 10 cm, it will decrease the brightness of the lights.
Here continue the flash instructions.
First you need the Arduino IDE. You can find here:
Download the next libraries:
- Adafruit Neopixel
Now you need to configure the Arduino IDE to flash this board. In the next video, you can see a detailed explanation of how to do it.
The wiring instructions on the video are fine, but I've found that is possible to do more easily just doing the connections shows on the second attached photo. You just need to do the next connections:
ESP12 Vcc -> 3.3V
ESP12 GND -> GND
ESP12 GPIO 0 ->GND
ESP12 RX -> USB-RS232 TX
ESP12 TX -> USB-RS232 RX
That's all, your board is ready to be flashed!
Step 2: Wire Connections
In the first photo, you can see a wire schematics of how to set the wire connections, on the next lines I'm going to explain each connection in detail.
Power module: (Third photo)
For this part, we're going to use an LM2596 step-down converter. This device has 5 volts at the input at return 3.3v volts. By default the output voltage is wrong, so is necessary to do the next to set the right voltage (Is very important, is not you can destroy your micro-controller):
- Connect your power supply to the connected jack.
- The red LED light should turn on.
- Connect the polimeter to the output pin in voltage measure mode.
- Move the first potentiometer to obtain 3.3v at the output.
You can see on the next video how to set-up this device: LM 2596 DC -DC Buck converter
Micro-controller (Fourht and fith photo):
We're going to use the ESP12F module. Any ESP12 module is compatible, but I recommend this specific one because the lamp is designed to fit this one. Also, I highly recommend using, female headers wires to connect to the HC-SR04 sensor and regular wires to perform the connections with the LED matrix. We need to do the next connections:
- Solder the ESP12 to the breadboard module.
- Connect the next wires:
- Green wire to the GPIO4. This will be connected to the trigger pin of the HC-SR04.
- White wire to the GPIO5. This will connected to the echo pin of the HC-SR04.
- Brown wire to the GPIO15. This will be connected to DIN of the LED matrix.
- Red wire to VCC. This will be connected to Vout+ of the step down module.
- Black wirte GND. This will be connected to Vout- of the step down module.
This part has three connections: Vcc, GND and DIN.
- LED Matrix Vcc, connect to Vin+ of the step down converter module (Red wire of the third photo).
- LED Matrix GND, connect to Vin- of the step down converter module (Red wire of the third photo).
- LED Matrix DIN, connect to GPIO15 of the ESP12 (Brown wire of the fourth photo).
Very important note!
I highly recommend doing the LED Matrix connections at the assembly step, if you're using regular wires. You will understand the assembly step.
Step 3: 3D Print the Lamp
For this project is necessary to print 3 different parts, on the following lines I'll explain which parameters I've used to print each part:
This piece is the "base_part.stl" file. You can see the result on the right corner of the image. Use the next parameters to print:
- 0.2 mm per layer.
- No support.
- 15% Fill density.
This piece is the "middle.stl" file. You can see the result on the center of the image. Use the next parameters to print:
- 0.1 mm per layer.
- Support 20%.
- 0% Fill density.
This piece is the "top_v1.stl" file. You can see the result on the rigth corner of the image. Use the next parameters to print:
- 0.2 mm per layer.
- No support.
- 15% Fill density.
Step 4: Assembling the Project
At this point, every wire connection has been done, so it only left to join everything together. Rather than explain each step of how to assembly it, I think that it is better to see an assembly animation in which you can pause an resume.
On the image, you can see how it looks on every assembly step. I highly recommend to assembly it following the attached photo order, because it will be easier to do the final wire connections.
Step 5: How to Use It
The first time that you turn on the lamp, it will create a Wi-Fi access point.
This access point is calle "esp8266_ap". You need to access to it and insert the password 123456. (First Image)
Once you're inside it should appear the second image with no connection data. Push on the three lines icons on the rigth top corner. This will poup a menu like on the third photo.
Push on "Configure a new AP", this will show the fourth photo which is a menu with the available Wi-Fi access point. Introduce the information of yours and the continue will be ready!
Now come back to the main page and copy the value of IP.
Open a new tab on the browser and type the IP that you copied from the previous step.
Once the page is loaded it will show a HUE color selector. You can choose any color that you want and the lamp will show it.
Finally the lamp has the next gesture actions:
- If you set your hand 5 cm or less from the top of the lamp, it will turn off.
- If you set your hand 5 cm or more it will turn on.
- You can modify the brigthnes by turning on the lamp and leaving the hand on that position for 1 second. If you move down your hand, it will decrease the brigthnes. If you move up your hand, it will increase the brigthness.
Step 6: Finish
I hope that you like this instructable and you enjoy building it.
If you have any questions, please ask me on the comments below!
Participated in the
LED Strip Speed Challenge