Introduction: IRIS - the Lamp That Knows When You're Around
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!
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?
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...
Step 1: Making the Stand
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.
Step 2: The Top of the Lamp
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!
Step 3: The Bulb
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.
Step 4: Paint It Black!
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.
Step 5: Electronics
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.
Step 6: What If I Don't Have an Arduino?
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.
Step 7: Programming
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
Step 8: How Does It Work?
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.
Step 9: Assemble
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.
Step 10: Ready to Go!
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.
Step 11: 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!
Step 12: Code Walk Through
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.
Second Prize in the
Work From Home Speed Challenge