Touchless Multicolor Lamp

3,630

54

8

Introduction: Touchless Multicolor Lamp

About: I'm always with some project, some of them works and others smokes(joking) I'm Electronic System Engineer.

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!

Supplies

For this project you need the next supplies:

- 3D printer. (Necessary to print the shell, but is not necessary to make it work)

- ESP12-F + bread board adapter.

- WS2812 8x8 LED Matrix

- Step-Down Converter

- HC-SR04 ultrasonic sensor

- 5V 3A DC adapter

- DC power Jack socket

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:

Arduino IDE download

Download the next libraries:

- NewPing

- Autoconnect

- 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.

Youtube: Flash ESP12 Arduino IDE

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.

LED Matrix:

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:

Bottom piece:

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.

Middle piece:

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.

Top piece:

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!

Thank you!

LED Strip Speed Challenge

Participated in the
LED Strip Speed Challenge

1 Person Made This Project!

Recommendations

  • Backyard Contest

    Backyard Contest
  • Stone, Concrete, Cement Challenge

    Stone, Concrete, Cement Challenge
  • Summer Fun: Student Design Challenge

    Summer Fun: Student Design Challenge

8 Comments

0
paulfecht
paulfecht

1 year ago

Do we just flash all of the .ino files onto the ESP8266 chip ? I thought that you could only flash one set of code at a time and if you flashed one over the top of the other that it would erase it.....can you explain? Thank You
you just need to open "ulight_firmware.ino", which is the main file. When you execute the compilation and flash proccess from the main file, it will include all of them
What you do is create a folder for the ulight_firmare.ino file and then you put the other 3 .ino files into that folder. Then when you open the ulight_firmware.ino file with the Arduino IDE they will appear as tabs. This means that the ulight_firmware.ino file is the main file and the others will be all compiled at compile time.

What does this line mean? "ESP12 GPIO 0 ->GPIO 0". How do you connect something to itself?
Ok, I was able to flash the ESP12 according to the directions here: https://youtu.be/37KlzYhJaQs?t=202

Getting closer.... just not sure why on power up I don't see the Access Point.

Got this after uploading the code....WARNING: library NewPing claims to run on avr, arm architecture(s) and may be incompatible with your current board which runs on esp8266 architecture(s).. Leaving .... Hard resetting vio RTS pin . . . "

When I hookup the ESP12 as per the instructions... I just get a few LEDs lit up and no access point... any help would be great. By the way, I'll help you with anything I can to this point.
getting_closer_touchless_lamp.JPGAccess_point_working.PNG
1
JuanF92
JuanF92

Reply 1 year ago

Hi paulfecht!
First thank you for being interested on my project and tried to replicate it!
Regarding your first question, the program is splitted in different files to make easier the undestanding of the code and avoid a spaghetty code. So, you just need to open "ulight_firmware.ino", which is the main file. When you execute the compilation and flash proccess from the main file, it will include all of them (I mean web_sever.ino,led_control ...)

About your seconde question (What does this line mean? "ESP12 GPIO 0 ->GPIO 0"), is my mistake wrtiing. You need to connect ESP12 GPIO 0 -> GND.

About this: "Got this after uploading the code....WARNING: library NewPing claims to run on avr, arm architecture(s) and may be incompatible with your current board which runs on esp8266 architecture(s).. Leaving .... Hard resetting vio RTS pin . . . " No worries, is not a real problem.

Finally about the real problem, could you open the terminal and check if it's bringing up the AP? Or even better, please copy the log of the terminal on a message, because I think that somenthing is not starting properly and is blocking the program process.

Thanks

0
paulfecht
paulfecht

Reply 1 year ago

Having real trouble with this, would you be able to help? The matrix and the ultrasonic are not working well. :| Thanks

update: The cheap 8x8 matrix LED boards you get on Ebay are faulty upon arrival. Sure you pay only $10 but with the cold solder joints etc. they are impossible to work with. The hours I spent trying to debug it just weren't worth it. Buy the 8x8 matrices from Adafruit and/or Digi-Key. They are super expensive ($50) but they just work.

0
paulfecht
paulfecht

Reply 1 year ago

something is definitely blocking... I replaced the New Ping.h with Ultrasonic.h and now it is not blocking but the behavior of the LEDs is very crazy... any help you could provide would be great.

Update: I went down this rabbit hole of trying new libraries as my LED matrix was behaving erratically. It was the matrix itself not the code or the ultrasonic sensor. ugh

0
paulfecht
paulfecht

Reply 1 year ago

Thanks for your response. When you say "open terminal" do you mean the serial port viewer from within the ArduinoIDE? or do you mean a command prompt in Windows or a Macintosh terminal? I'm flashing the ESP12 chip with another Node per my YouTube video link above. Maybe that is causing the code(or the chip) to be locked up or reset and not start when I plug it in and turn it on. Would you be willing to do a cell phone video chat or a Zoom meeting at some point? I'm really wanting to get this working and I'm not sure why it's not working. I'll work on a diagram tonight to show you the connections to see if that will help you understand my situation. Thanks again. I'm getting the access point to work... but still very stuck with the LEDs and the Sonar....It is behaving very erratically, I believe that maybe the NewPing is causing trouble here.

Update: When the upload works as planned you open the serial monitor on the Arduino IDE and watch. When it works you device should be handed an IP address by the router. It's that IP address that you need to navigate to in order to find the settings page for your touchless lamp.

0
Build_it_Bob
Build_it_Bob

1 year ago

Very nice! I can't wait to read through your code...you incorporated a lot of features!
Bob D

0
LaurentM
LaurentM

1 year ago on Step 6

Thanks for this. I'm going to "pinch" some of your ideas to improve on a similar project I'm working on.
Just a small note in your logic_control.ino, function ligth_mode:
If the distance equals 5 exactly, nothing happens... I know it'll be a rare occasion, but one that can happen nonetheless...

0
JuanF92
JuanF92

Reply 1 year ago

Hi LaurentM!
You're right, is a mistake.
Thank you for the advice, I'll upload again fixed!