IRIS - the Lamp That Knows When You're Around

by Arpan Mondal in Circuits > Arduino

5049 Views, 79 Favorites, 0 Comments

IRIS - the Lamp That Knows When You're Around

20200423_093204_0000-01.jpeg
IMG_20200423_082249-01.jpeg
DIY smart desk lamp

Howdy! Yup, everyone's quarantined. I'm an engineering student. I used to stay in a hostel and I'm used to doing my assignments and studies at night. Now that I'm home, my family doesn't find that comfortable because everyone here is used to sleeping early. Neither do I have a table lamp.

But if I want to make one myself, I would want it to have more features than just a standard lamp. The challenge was to find parts. Due to the countrywide lock down here in India, no electronic stores are open. This is my completely home built project. Meet Iris, the smart table lamp. It has as many features as I could push into it with the electronics I had at my house.

Manual mode: Usual desk lighting

Smart mode: Automatic detection of the user to turn on / off the light

Smart bed lamp: Automatically lights up your path when you want to go somewhere in the middle of the night

Adaptive brightness: Automatically adjusts brightness based on surrounding light

Daylight awareness: Can turn on smart mode automatically after sunset or when no other light source is around.

The last two features are yet to be added but I've mentioned the working principle so if you want to add them, you'll know what to do. Let's get making!

Supplies

Yeah I know it doesn't really make sense to give purchase links because in most countries e-commerce sites aren't active at the moment. But in case you're reading this after this virus has come under control and everything is back to normal (which I hope happens soon), then...um.. you're welcome?

Arduino Uno: https://www.amazon.com/Arduino-A000066-ARDUINO-UNO...

Warm white LED strip: https://www.amazon.com/Flexible-16-4ft-Kitchen-Chr...

Single channel Relay: https://www.amazon.com/Electrical-Equipments-Chann...

Proximity/Obstacle sensor: https://www.amazon.com/DAOKI-Infrared-Obstacle-Avo...

12v Power supply: https://www.amazon.com/100-240V-Supply-Adapter-Swi...

GI wire

Black paint

Some parts here and there can be found at home.

Making the Stand

IMG_20200422_095920-01.jpeg
IMG_20200423_112404-01.jpeg
IMG_20200422_095842-01.jpeg

Now it wouldn't really be true if I said that the design of the base is completely my own. I saw this design in a video. But the execution is different, so yeah.

First of all, I took a thick mains cable. I wanted a black one, but this was the only one lying in my house. The problem is it's too flexible. We need something that can retain its shape once bent. So I removed the Aluminium wire inside and inserted a thick GI wire instead. Then I bent the wire into shape. This was as simple as making a circle for the bottom and then bending the rest of the wire in a thin S shape for the stand.

Unfortunately there was no more space inside to pass the power cables, so we'll do something about it later. The base is pretty much done.

The Top of the Lamp

IMG_20200422_144658-01.jpeg
IMG_20200422_122910-01.jpeg

For this, I took two plastic containers from the kitchen. Both are a little tapered and one is bigger than the other. I marked a line along the larger container and cut it short.

When the small container is placed on top of the large one, it looks exactly like a lamp. Great!

The Bulb

IMG_20200422_100957-01.jpeg
IMG_20200422_095712-01.jpeg
IMG_20200422_095537-01.jpeg
IMG_20200422_095429-01.jpeg
IMG_20200422_100051-01.jpeg
IMG_20200422_123730-01.jpeg
IMG_20200422_123749-01-01.jpeg

This could be as simple as going to the stationary and buying a night light. But, I didn't want such a bright light and also, I wanted to add an automatic brightness control with the parts I had at home. So, I custom made the bulb.

First, I took the lid of the small container that I used previously, and stuck a rectangular plate of Aluminum onto it. I then stuck two small pieces of warm white LED strip on the Aluminum. Why the Aluminum strip? It acts as a heat sink for the LEDs because they get warm when used for longer periods. Everything was stuck together using heat resistant adhesive that I fortunately found lying in the store room. If you can't find it, it's okay. LED strips generally have adhesive already on the back, you can just stick it directly.

I soldered the wires keeping both the strips in parallel. I then popped open the diffuser from an old LED light bulb and stuck it on top of the lid.

Our custom LED bulb is ready!

I did a quick test with a 12v power supply. You can see how pleasant it looks already.

Paint It Black!

IMG_20200422_145844-01.jpeg
IMG_20200422_165955-01.jpeg
IMG_20200422_174509-01.jpeg

I painted everything black. Make sure to use a sandpaper to make the surface of the containers rough so that the paint can properly stick to it.

It's best to use spray paint, but I didn't have one at home. So I used acrylic paint. It was really hard to paint the base because the paint kept coming out. After three coats, I was satisfied with the look. Although I should have sanded it too before painting.

I didn't paint the top of the large container because it was semi transparent and would form a cool light ring when powered on.

Electronics

AddText_04-22-02.24.30.jpg
IMG_20200422_123108-01.jpeg
IMG_20200422_135949-01.jpeg
IMG_20200422_122713-01.jpeg
IMG_20200422_100201-01.jpeg

After I had mentioned all the features, you might be overwhelmed and think that it might have some complicated circuitry going on. But nope, it's pretty simple. Thanks to the Arduino board.

Sensor input: The obstacle sensor detects when you're in front of it. It's D0 pin goes to Arduino's pin 2. GND pin goes to Arduino's GND pin, obviously. It's +5v pin goes to Arduino's 5v pin.

Relay output: The relay switches the lamp on/off when it's in smart mode. It's input pin goes to Arduino's pin 3 and the other pin goes to Arduino's GND pin.

The rest of the connections are pretty simple. Just follow the schematic diagram. It'll be a little easier if you know what's happening.

Basically, if you slide the switch to the right, you're directly powering the lamp from the supply. When you slide the switch to the left, the lamp is in smart mode. From here onward, the lamp is controlled by the Arduino. Basically by sliding the switch to the left, you're disconnecting the power supply from the lamp and powering the Arduino instead. If the Arduino wants to power the lamp, it'll trigger the relay which is just shorting the previously disconnected switch terminals.

What If I Don't Have an Arduino?

AddText_04-23-11.09.05.jpg
IMG_20200423_111239-01.jpeg

In case you don't have an Arduino, you can still make the smart mode using a BC547 or any other general purpose transistor and the obstacle sensor. Refer to the schematic diagram. This circuit should be replaced with the Arduino, relay and sensor arrangement in the schematic diagram in the previous step. Although this is a cheaper option, there will be a small power consumption when idle.

Programming

IMG_20200423_090943-01.jpeg

All these smart features are controlled by the Arduino. Our program decides how they work. If you want it to work the same was as mine does, you can just download my code and upload to your Arduino. In case you want to understand the code and tweak it to your own liking, I'll do a code walk through at the end of the instructable which you can refer.

As I mentioned earlier, this code only reads data from the obstacle sensor. The adaptive brightness and daylight awareness features aren't yet added. I'll explain this in the code walk through part so you can add them if you like

Downloads

How Does It Work?

IMG_20200423_094200-01.jpeg

Automatic user detection:

You'll be placing the obstacle sensor underneath the table, facing you. So now when you sit in front of it, it'll detect you and send a digital signal to the Arduino. The Arduino then switches the relay on, which turns on the lamp.

The bedside lamp feature:

This is not a separate feature actually. It's the existing obstacle sensor but with its range increased by turning it's potentiometer. If your lamp and desk arrangement is kept next to a bed, when you get off the bed, it detects you and turns the lamp on for 15 seconds, after which the lamp turns off. You can keep the lamp focused to your pathway before sleep so that it lights it up.

Assemble

IMG_20200422_163147-01.jpeg
IMG_20200422_190638-01.jpeg
IMG_20200423_082217-01.jpeg
IMG_20200423_082229-01.jpeg
IMG_20200422_190703-01.jpeg

Once all the electronics are properly connected and tested, I fixed them in a small box. I could attach them to the lamp, but I wanted it to look minimalistic, so the electronics were separately mounted on the bottom of the table. Perfect position for the obstacle sensor and hidden from view.

I stuck one power wire along the stand using superglue. What about the other wire? Remember we inserted a GI wire through the stand? We're going to use that as another wire. This will keep everything neat looking.

Once all the wires are properly joined and tested, I stuck the two parts of the lamp head with epoxy resin. Then the stand was attached to the head by making a hole and passing the GI wire through it. One final drop of resin and everything is sturdy and good to go.

Ready to Go!

IMG_20200422_192752-01.jpeg
IMG_20200422_222451-01.jpeg
IMG_20200423_094152-01.jpeg
IMG_20200423_082742-01.jpeg

After testing everything a couple of times, I'm really satisfied with how everything works. Not to mention how soft and pleasing the light from our custom made bulb is.

There were some minor issues though, which I could solve easily.

Obstacle sensor might detect the chair all the time. This can be overcome by using a chair which has a backrest only at the top, like mine had. The bottom is hollow so the obstacle sensor doesn't detect it.

Obstacle sensor detects people walking around and keeps turning the lamp on/off. For me, the desk was beside the bed so nobody goes there unless they want to sleep or use the desk. What you can do is adjust it's range properly so that it only detects you when you sit.

Lamp not turning off. This happens when the receiver (black bulb) of the obstacle sensor is too close to the transmitter (transparent bulb). This is simple to solve. All you have to do is bend them a little away from each other.

Additional Features and Tweaking

So now there might be one problem. How to switch between the smart mode for user detection and smart bedlamp mode? In the code I've provided, both are basically the same thing. But if you want a dedicated mode for each one and switch between them automatically, you can use a Nodemcu (esp8266) microcontroller instead of an Arduino.

You can use a service called IFTTT to trigger each mode based on the time and your schedule automatically. Also, you can add more features like controlling your lamp from your smartphone, weather alerts, timers and a lot of other things easily. This can make Iris truly smart. Unfortunately my nodemcu is back in the hostel so I'm stuck with Arduino. I'll add these features once I get back and maybe make another instructable!

Code Walk Through

IMG_20200423_090943-01.jpeg

The code not only looks, but it actually is pretty simple.

First, we declare the input and output pins of the Arduino in the setup function.

Pin 2 is receiving input from the sensor. So if it reads HIGH, which means someone is close to it, it turns on the relay (pin 3) for 15 seconds. After 15 seconds, if pin 2 is still reading high, the if block keeps getting executed and the lamp remains on. Otherwise, the relay is switched off and so is the lamp.

In case you would want it to work automatically after sunset, all you have to do is add an LDR with a general purpose transistor to another pin. Then, the whole code above is placed inside an if block. When the LDR reads no light, the if block gets executed and the process explained above is carried out by the Arduino.

Also, for the automatic brightness control, you'll need to use an LDR again. The lamp should now be powered directly from the Arduino for which another relay can be used. You can use PWM to adjust the brightness of the lamp based on the analog input from LDR. Note that for this, you'll have to use a 5v LED strip instead of a 12v.