Introduction: LUMOS: Smart Lamp for Better Sleep

There are plenty of smart lighting systems out there that let you change light colors and dim with just your smartphone (or even your voice), but this Open Source lamp called Lumos is a smart lighting system that works to benefit your health.

Lumos mimics the natural light of the sun as it passes overhead each day, generating bright blue light in the morning and warmer amber light in the evening.

Decades of research from Harvard Medical School , NASA , and leading institutions around the world have revealed a great deal of information about how light impacts and regulates our health. They explain that blue light aids in the production of cortisol, which is important to give the human body energy in the morning, and red light aids in the production of sleep-inducing melatonin.

Almost 20% of the world's population is sleep deprived & possibly spends more than 8 hours a day under an unnatural light, which can throw off the body’s internal clock and prevent it from performing at optimum levels.

The Lumos smart lamp aims to change that by pairing with WiFi and uses Machine Learning to adjust the light to match your sleep schedule.

Develop:

Are you a programmer, engineer or designer who has a great idea for a new feature in Lumos? Maybe you have a good idea for a bug fix? Feel free to grab our code, schematics & CAD files from Github and tinker with it.

LUMOS Repository Github

Step 1: Parts & Materials

MaterialDimensions/Quantity
MDF Sheet5mm, 60cm*60cm
Frosted Acrylic Sheet5mm, 60cm*60cm
Mica Sheet1mm, 2m*1m
RGB LED Strip12V, 5m
Raspberry Pi Zero
ArduinoNano/ Pro Mini
7805 Voltage Regulator1pc
IRF1404 N-MOSFET3pc

Step 2: Mechanical Design

Specifications:

MDF Base: Outer Radius: 26 cm, Inner Radius: 20 cm.

Frosted Acrylic Diffuser: Outer Radius: 26 cm, Inner Radius: 20 cm.

Mica Support Rings: Width: 4 cm, Thickness: 1 mm, Outer Ring Length: 164 cm, Inner Ring Length: 126 cm.

The circular lower base of the lamp is made out a 5mm MDF Sheet whereas the top circular diffuser is made out of a 5mm Frosted Acrylic Sheet. The laser cutter files for both the base & diffuser are in the PDF below. The base & diffuser are supported by two rings made out of 1mm Mica Strips. The distance between the diffuser & the base is 4cm. Using a Mica cutting blade, cut the two Mica strips which will form the Mica support rings. The inner circle from the remaining MDF sheet once laser cut can be used to laser cut the Electronics Enclosure Box.

Step 3: Mechanical Assembly

Start by marking the drill holes on the ends of each mica strip using the template attached below. Once the holes have been marked & drilled, bring both ends of the mica strip together such that the holes on each end are aligned. Do this for both of the mica strips which form the two support rings.

Using the leather string, weave a knot between the holes in order to securely join the two ends of the mica strips. Do this for both of the mica strips which form the two support rings. You will now have two Mica support rings: Outer & Inner Ring with a radius of 52 cm & 40 cm respectively.

Using a mixture of Super Glue/ Instant Adhesive & Baking Soda, stick the support rings to the inner & outer edges of the MDF Base. Drill a hole for the power & control wires at the bottom of the MDF base.

Remove the protective layer from the RGB LED Strip & begin sticking the strip to both support rings. Stick the LED Strip as close to the base as possible. This will ensure that the light is evenly diffused & that individual LED outlines are not visible. Ensure that the 4 wires (Power & Control) are connected to the LED Strip & are routed through the hole made in the MDF Base.

Step 4: Electronic Assembly

The Raspberry Pi uses Wi-Fi to get the location specific time zone & also uses its internal Bluetooth Module to analyze RSSI values of a Smartphone in order to calculate proximity of the smartphone

The Arduino is used to control & test the analog values which control the intensity of the RGB LED Strip. By changing the analog value using PWM we can control the color produced by the LED Strip.

The Arduino can only supply a maximum of 5V, 20mA through its I/O pins. Whereas the RGB LED Strip generally requires a power source of minimum 12V, 1A.

The solution to this is using a MOSFET as a switch. The Gate pin of the MOSFET can be used to control the ON/ OFF state of the MOSFET. The Source pin is connected to LED Strip while the Drain pin is connected to Ground. Each Gate pin of a MOSFET is controlled by a separate PWM pin on the Arduino. The LED Strip has 4 pins: +12V, R, G & B. The +12V is connected to the +12V of the 12V power adapter. The R, G & B pins are connected to Source of each MOSFET respectively.

The Arduino makes it easy to calibrate the colors of the RGB LED Strip. Calibration of the RGB values varies with the manufacturer & model of the RGB LED Strip. If calibration is achieved, the cost can be reduced by using an appropriate Digital to Analog Converter(DAC).

The Raspberry Pi & Arduino communicate using the I2C protocol.

The Eagle CAD files & Schematics are attached below.

Step 5: Software

The Raspberry Pi is used to detect the presence of a human being & monitor & track the sleeping habits of the human being. Depending on the sleeping habits of the human being, the color changing sequence will be adjusted.

The Raspberry Pi is running the latest version of NOOBS OS. It has to be configured to the location specific time zone. The MAC address of the Bluetooth Module of the user's Smartphone is verified when tracking the presence of the human being. When the human being is asleep, their smartphone should be placed as close as possible to the lamp. Hence it is recommended to place the lamp close to the bedside table. The RSSI strength will vary depending on the distance between the Raspberry Pi & the Smartphone. Once the location of the Raspberry Pi in the room is fixed, a threshold value can be set to configure the Sleep tracking.

For the first two weeks, a pre configured lighting sequence is initialized while the users sleeping habits are tracked. Once sufficient data is collected to determine the sleep & wake up times the system calculates the length & time of the Color Lighting sequence. Typically the light initializes the Sunset phase an hour before sleep is expected and Sunrise phase half an hour before a wake-up/ rising is expected.

Since there are multiple software files, the code for this Instructable can be found here:

LUMOS Software Files

Step 6: Open Source

All the files including code, electronic circuits & schematics, CAD & design files are Open Source & are available on the Github Repository.

LUMOS: Open Source Repository

The software & electronics is regularly updated & modified.

The initial design, software & electronics was created with the help of two of my friends Callum & Mark.

We encourage other Engineers, Developers, Designers, Architects, etc to help us by contributing to the Repository.

If you have any alternate design layout that you would like to make, you can upload the CAD & layout files to the repository, so that others can recreate it too. If you think that we can use an alternate Microcontroller to control the lighting sequence, you too can contribute to the Electronic Circuits & Software.

Comments

author
zaid697 (author)2017-07-23

Could it be possible to replace the wifi with a clock? I have no wifi

author
ПавелП23 (author)zaid6972017-07-23

of course, you even need no raspberry. you may use gps receiver to get time and location. but anyway you should change avr's firmware.

author

A typical GPS receiver + Breakout Board costs more than a RasPi.

author

hmmm... is it typical enough?) http://www.ebay.com/itm/GPS-Module-Ceramic-Antenna...

anyway, if you dunno want 2 use GPS, you may use somethin' like ENC28J60 or ESP8266, and get still same functions without any Pi.

you've made nice stuff, but your stuff could be made with only arduino, or only Pi. using both of them is overkill.

author

Depending on the level of GPS support you need, you can get an I2C GPS with breakout for >$10: https://www.aliexpress.com/item/For-GYNEO6MV2-GPS-Module-NEO-6M-GY-NEO6MV2-Board-with-Antenna-R179T-Drop-Shipping/32815376782.html

Not that I would consider building a lamp with GPS :) But they are great for playing with.

author

You could use an RTC, but you would be misssing out ona couple of updates and features.

author
SilkeC2 (author)zaid6972017-07-24

Arduino has a built in timer (although it's reset every time the power unplugs), not sure about the Pi but probably has it as well. You could reset the time once a day by connecting to the smartphone's clock to ensure accuracy.

Alternatively you could use an RTC module to keep track of time.

author
agr00m (author)zaid6972017-07-23

You definitely could. It would then just change color based on time and not have all the extra features.

author
NikyN2 (author)2017-07-25

and here I am, with just a smart bulb (yeelight) automatically controlled by tasker. the phone even detects when I'm on the light sleep phase then triggers a sunrise light alarm.

I guess I could put a sunset profile too , but since I go to bed at different times, I prefer to just manually set the brightness and color as I'm getting sleepy.

nice instructable, but IMO too complicated (arduino + raspberry?! I'm too poor for that!!) and with not enough functions (... since my setup includes sleep phase detection and trust me - the difference in waking energy is HUGE).

PS: not trying to be negative - this can also be viewed as "ideas to improve the project" (ESPECIALLY the sleep phase detection! ... no alarm clock should be without that anymore. )

author
BillDauterive (author)NikyN22017-07-25

Woah, looking them up, some of the Yeelights don't look cheap. I haven't been paying much attention to what's on sale in this area.

Which Yeelight did you get/are they good?

+ Does tasker talk to it directly over local Wifi, or via a cloud service?

---

Something I've been working on (tinkering really) uses an ESP8266 wifi chip, but the addressible LEDs I'm using aren't that cheap.

I'm still simplifying set up, have no enclosure for it and it's really a testbed right now), but it is largely a "slave" device accepting commands to give max flexibility (with sensory & time context available)...

...BUT a highly focused device like the OP's could be made cheaper than mine (possibly single colour LED sets, RPi zero, or an RPi-free version just using an ESP8266). Since it's open source, it's potentially everyone's project to contribute code & design to, not just his.

author
NikyN2 (author)BillDauterive2017-07-26

I paid like $20 for an RGB yeelight bulb (NOT a lamp, but why would I want a full lamp? I already have the thing, I just needed a nice bulb for it). you gotta get it on sale or you may pay a bit more (less than $30 still). anyway, they have sales pretty often. pages like banggood, gearbest or dealextreme are where I usually buy that kind of stuff.

the official yeelight app (NOT MiHome) supports tasker (it just installs a plugin), and, my bulb at least, connects via wifi. no clouds required.

as for whether they're good, I'm very happy with it, but I have to admit, sometimes it doesn't respond too well/in time. I think it also has something to do with my router and the way it manages DHCP, since changing some addresses seems to have mostly solved the problem (... the phone wouldn't detect it was on so it wouldn't do anything). I also had problems connecting from the laptop (to the router), so it's probably all the router's fault. but still, it's something that I do have to resolve.

good thing with the bulb, it's rated at 600 lumens (IIRC), and I'd think it delivers. so e.g. for alarm clock, you just need one. though, as "ceiling lamp" for a smallish room, I would get two. but I like lots of light. :)

author
BillDauterive (author)NikyN22017-07-26

i think I've found the one now:

https://www.banggood.com/Original-Xiaomi-Mi-Yeelig...

Interestingly they're using 550 lumens of warm white LED to make up most of the max brightness figure, with the RGB LEDs on their own maxing out at 275 Lm. May well just be RGBW LEDs.

I found a teardown of the plain white version:

https://hackernoon.com/inside-the-bulb-adventures-...

------

For comparison to self-builds (this example uses more expensive, pre-wired addressable LEDs as that's what I've been working with recently):

The lumens rating for the NeoPixel type LEDs (WS2812) is (according to one seller) 18-20 Lm per chip, so 14 should match the Yeelight RGB output and 30 or so would match the peak output of the warm white.

An ESP8266 (can be used as a wifi Arduino) dev board can be picked up for $2-$3. A 30LED WS2812 strip ~$6 pre-wired

https://www.banggood.com/1M-WS2812-IC-SMD5050-Drea...

So call it $10 with wiring, components & board. Still needs a bit of coding, maybe a few dollars on a diffuser, a power supply, an enclosure for the electronics and then some work to mount it.

vs. $20 plug and play into an existing light fitting.

The home build has room to reduce the cost further and has loads of potential features through addressable LEDs, but the Yeelight bulb price is pretty impressive and it's a finished product :)

author
NikyN2 (author)BillDauterive2017-07-27

yeah, DIY is always more flexible, and of course more fun. but I have ZERO experience with arduino or even microcontrollers, so I would have to learn first. for roughly $20, I have a bulb that I can manage from android. add tasker to the equation, and you can do pretty impressive things with it (and the official yeelight app has tasker support).

I guess it all depends on whether you want to learn, and *maybe* save a few bucks, or just get the work done.

I'm totally a DIY person, but microcontrollers are still quite advanced stuff for me, haha. someday I'll have the money and the time to learn. :)

author
Jonathanrjpereira (author)NikyN22017-07-25

I'm working on reducing the total cost now. Both alternate materials & electronics.

author

Using something like an ESP8266 and the Arduino IDE would achieve all your existing requirements, is wifi-attached and much, much cheaper than an R'Pi.

Using WS281x LEDs and the Arduino FASTLed library gives you control over colour and brightness.

You can use some of the smart networking libraries available which creates a hot-spot, allows you to connect and set up on your home network, which means you can send them to friends, etc.

author
BillDauterive (author)zootalaws2017-07-26

I agree, those WS281x LEDs are really nice to work with (code and circuits) - not that cheap if pre-wired into strips/matrices, but much cheaper if bought singly (note that the pre-wired strips include a 100k resistor per LED).

The AdaFruit NeoPixel libraries are good too.

author
senortres (author)2017-07-27

This is great man. To be honest, I woulda been better off doing stuff like this when I was as old as you guys instead of the stuff I'd get into. You're doing way better than I did!

author
AndrewM512 (author)2017-07-26

Have you tyres this with neopixels over rgb's less wires ?

author

I haven't tried using Neopixels as they are pretty expensive here in India. Although it's a great alternative if you want to create a specific lighting sequence as each LED is individually addressable.

author
ko-sinus (author)2017-07-25

Very nice instructables, interesting project :) but isn't it possible to use a Beaglebone Black Wireless to manage all of the parameters? I would try it myself for sure, but I wonder if you have thought about it and rejected it for some reason

author

I guess I could. But the Beaglebone Black is way more expensive than the RasPi.

author

Yeah well, I meant replacing both Arduino and RasPi by one single BBB Wireless, in order to gain some space and maybe some time. But I guess you're right, it would cost the same or more.

author
frarugi87 (author)2017-07-25

I see three major flaws in your electronic design (I assume you are using IRF1404, since I could not find any IRF1504)

* The MOS is not a logic level one; with a Vth of at most 4V it is risky to use 5V to power it...

* Usually it is much better to put a resistor (about 200 Ohm) between any logic pin and the gate of the MOS, because at turn on a high current can flow

* Using a rPI and an Arduino is totally overkill. I did not dig into the "machine learning" part, but if it is simple enough to be implemented on a microcontroller (e.g. by tracking the time when the user puts the phone nearby) then you can move it to an arduino (maybe with an HC-05 for the bluetooth). If it isn't, you can directly power the MOS from the rPI (of course, you need a logic level MOS - with a Vgs-th much lower). But.. Don't use another complete board just to avoid using a board properly

Best regards ;)

author

IRF1504 was a typo. Thanks for pointing it out.

1. Vgs is just the voltage from gate to source (with the red lead of the multimeter on the gate and the black one on the source). Everything else is from context.

The Absolute Maximum Vgs is the maximum voltage you should ever subject the MOSFET to under any conditions (stay well away). Usually, the actual breakdown is quite a bit different (borrowing from the IRF 1404 datasheet) as shown in the image below.

Vgs(th) is the voltage at which the MOSFET will 'turn on' to some degree(usually not very well turned on). For example, it might be 2V minimum and 4V maximum for a drain current of 0.25mA at Tj = 25°C (the die itself is at 25°C).. That means that if you want your 20A MOSFET to really turn on fully (not just conducting 250uA) you need a lot more voltage than 4V to be sure about it, but if your Vgs is well under about 2V you can be pretty sure it's well turned off (at least around room temperature).

irf1404.PNGirf1404.PNG
author

Thank you for your reply..

Just to point out, my "risky" was not about breaking the MOS (the Vgs max is 20V, so no risk on this side), but on the fact that you may not be able to fully turn it on. Ok, now you have only 2.5m of leds, and I think this equates to roughly 0.5A of current, but then why choose a 75A MOS? Moreover look at figure 1 on the datasheet: look at the differences between 5V and 4.5V to understand how features degrade quickly when near the Vgsth value; then consider these are the typical values (what is typical between 2 and 4V of Vgsth?). Personally, I'd think of using even a smaller MOS (with Id-max between 2 and 20A) but with a lower Vgs-th, to be sure to fully turn it on with 5V or 3.3V.

On the other side, ok for the RSSI; but then I think the arduino is superfluous. You are NOT using a DAC peripheral on the arduino, simply because there are no DACs on arduino. And moreover a DAC will not work correctly with your setup. What you are using is creating three PWM waves (you can see this with an oscilloscope on the arduino outputs: a DAC creates a steady DC voltage, while a PWM is a square wave and the ducy cycle is adjusted so that the average value is equal to the steady voltage); the rPI is capable of generating this voltage on his own.

My personal suggestions are

- if you want to change the MOS, choose one with a Vgs-th max of about 1V; this will enable you to use it directly with the rPI

- if you don't want to change the MOS, put another stage in between, to power it with the 12V. For instance, put an NPN (or a small nMOS with Vgs-th low) with base towards the rPI, emitter to gound, emitter connected to +12 through a pull-up transistor and the gate of the MOS. This way you will be able to fully turn the IRF on and make performances better.

Just a quick search on RS showed that the IRF1404 costs about 2.4€ each; if you change it with a SOT-23 packaged MOS (SMD mount, so smaller circuit - but they are easy to solder also on a perfboard) I found the FDN337N (2.2A of max Id, 30V Vds max, 1V Vgs-th max, 0.24€ each). If you want to stich with through-hole devices, the IRL2703 is in TO-220 case (24A Id max, 30V Vds max, 1V Vgs-th max, 0.98€ each). Again, this is a very quick search on RS; other suppliers will have lots of other devices, with different prices and characteristics. Just pick your favourite ;)

author

2. I also added resistors between the MOSFETs & Arduino. Thanks again for pointing that out. I have made the appropriate updates to the Eagle files.

3. I used the Arduino-RasPi combination for a couple reasons. Firstly they are widely available across the world, even in developing nations. Here in India, Microcontrollers like the Intel Edison, Beagle Bone Black etc are not as easily available as the Arduino & RasPi. Secondly, I could have used a DAC instead of an Arduino, again my primary concern is availability & ease of use. A single channel I2C DAC costs $5 whereas an Arduino costs 10$ with 4 Analog Pins. I'm not sure if it is possible to measure RSSI values of a Bluetooth device using an HC-05.

One of the primary reasons behind focussing on the Raspberry Pi is because of the rapid development that comes along with it. There are a bunch of open source ML libraries like SciLab, Tensorflow,etc which are Python based( A lot of ML is being done in Python). In the future I plan on increasing the accuracy of the sensors by integrating the APIs of some popular smartwatches to acccurately gather sleep data.

author
vglaso (author)2017-07-25

what an exercise! (it does work to get up in daylight, and, sleep in dark) ? i love the idea! (and concept). most two-leggeds have no smart-phones and are not suffering from ...sleep apnea. Most are suffering from too much work... and lack of funds to pursue hobbies. I like this idea... to reduce stress, and, see a (multi-colored light) in the future. Good Work! (instead of psychedelic lights from the sixties)

author
onion2 (author)2017-07-24

beautiful project.
however, do you think it's possible to change pizero/Arduino by a NodeMcu v3.0 ?
it will be cheaper, will use less space and power.

author
Jonathanrjpereira (author)onion22017-07-25

I haven't used/own a NodeMCU. It looks very promising in terms of specifications & cost. It's one of the boards that I'm planning to make Lumos compatible with. If you have any experience with the NodeMCU let me know or even try contributing on GitHub.

author

I've been there - the NodeMCU is OK, but I would recommend using the WeMOS D1 Mini over the NodeMCU - cheaper, better designed: https://wiki.wemos.cc/products:d1:d1_mini

I think my best price was about $6 including shipping, plus they have a bunch of nice add-on shields, including a great little 64x48 pixel I2C OLED display.

Since I bought the D1 Mini, I haven't looked at a NodeMCU, and I have a bunch of them.

author

I've only had (useful) experience of ESP8266 dev boards with the Arduino Firmware (*) which can be flashed directly from the Arduino IDE (**).

Most Arduino libraries will work with an ESP8266. Code is in Arduino-flavoured C.

There's also a MicroPython firmware if Python's your thing - I've not even tried that FW yet.

As it happens, I have recently been playing with a Wifi RGB LED setup (same LEDs as in AdaFruit's NeoPixel line - compatible with their libraries, 5v with single line DIN to control it - keeps the circuit's nice and simple) using an ESP (a Wemos D1 mini breakout/dev board).

Will

(*) the NodeMCU modular firmware sounds great in principal, but a) I had some issues with flashing it and some stability issues andthere are more Arduino libraries out there

(**) there's some setup to get it working from Arduino IDE - you need to install drivers and add the board in Arduino board manager

author

I'm not sure if I'll get time to contribute & I am working with a rather specific LED setup (for simplicity rather than low cost) so may be more costly and slightly limiting, but features wise, the NeoPixel-style LEDs are great.

My job uses up a lot of my brain-time time, so I do move quite slowly on this stuff. *If I get the chance*, I'll see if I can get an Arduino-based ESP version started (likely to be NeoPixel-based for v1).

Note that it's still likely to need to use an external service (be that cloud or an RPi) for the "learning" part, but would be capable of taking sensor inputs, additional control buttons etc. & I believe there are NTP libraries to fetch the time from the internet.

Will

p.s.

Just a thought: full RGB LEDs might be overkill for this (fading between orange, yellow and white might be cheaper) , but RGB does give options for notifications etc. and likely less wiring than individual LEDs!

author
MakersBox (author)2017-07-25

This looks like a perfect use-case for my Arduino Mosfet Shield: https://www.instructables.com/id/Building-and-Using-a-MOSFET-Arduino-Shield/

author

I guess it is.

author

It would lock you in to using a full Uno, which is probably overkill. I've done a MOSFET shield for Raspberry Pi, but it only has one channel. If you had three MOSFET channels on the Pi, you could cut the Arduino out of the picture.

author

Arduino Pro Mini & Nano are an option too.

author
lebowski (author)2017-07-23

This is super cool!

author

Thanks.

author
deluges (author)2017-07-23

Cool

author

Thanks

author
seamster (author)2017-07-24

Very good instructable. I've noticed that when I spend the last couple hours of my day with only "red" lights (soft, warm lights rather than cool blue fluorescents or daylight bulbs), I always fall asleep better. It really does shut down your brain and lead you into a better night's sleep.

Thanks for sharing this neat project!

author

Thanks

author
Rebou (author)2017-07-25

A great Instructable. With regard to your dimensions in the text, do you mean 52 cm diameter? 52 cm radius is quite large, 1.02 metres.

Thanks a lot for a great read.

author
Jonathanrjpereira (author)Rebou2017-07-25

52cm Diameter. Just updated it. Thanks for pointing it out.

author
trainor (author)2017-07-25

Very nice project. Just a newbie question: is it possible to drive the MOSFETs using the Raspberry Pi gpio ports?

author

Yes but you would probably need to change the MOSFETs.

author
andrea biffi (author)2017-07-25

it's beautiful! congrats!

author

Thanks

About This Instructable

154,300views

464favorites

License:

Bio: I'm Jonathan Pereira, a novice Electronics Engineer. I like to make Lumen Powered Thingamajigs, Almighty Brainy Buttons, Tweeting Fart Detectors, Electronic Doohickey's and ... More »
More by Jonathanrjpereira:LUMOS: Smart Lamp for Better SleepAdruino Serial Plotter8 Twittering Thingamajigs
Add instructable to: