Close
0%
0%

A Smart Lamp That improves sleep quality

This lamp uses sleep cycles to wake you up at the optimal time based on when you sleep and your target wake up time for better sleep quality

Similar projects worth following
This is a smart sleep-assisting lamp that could (probably) improve your sleep and help you feel more refreshed in the morning. I developed this concept with inspiration from online sleep calculators and some research I did online.

This is a smart sleep-assisting lamp that could (probably) improve your sleep and help you feel more refreshed in the morning.

Now, let me be clear, it won't magically make you feel better if you're sleep-deprived due to overworking or excessive TikToking. Think of this lamp as an enhanced alarm clock replacement that primarily does two things:

First, it gently wakes you, simulating the rising sun. When it's time to get up, the lamp gradually increases in brightness, transitioning from a warm orange to a bright white, mimicking a beautiful sunrise over a period of five to ten minutes.

The second part is even more intelligent. It actually calculates the optimal time for you to wake up, based on your desired wake-up time and your actual sleep time, and ensuring you're roused at the end of a sleep cycle.

Read on to learn more about the concept.

Theory

To understand how the lamp works, we need to understand the concept of sleep cycles.

When you fall asleep, you go through 4 main stages. Stage 1 is light sleep. This is the transition between wakefulness and sleep, lasting for about 5-10 minutes.

Then you go into a slightly deeper sleep. In this stage, your body temperature drops, and your heart rate and breathing become more regular.

Stage 3 is deep sleep. It’s harder to wake up during this stage, and if you do, you might feel disoriented.

Finally, you go into REM sleep, most vivid dreams occur during REM sleep. Your muscles are temporarily paralyzed to prevent you from actually getting up and running when you are running a marathon in your dream.

All these four stages make up one sleep cycle which lasts for about 90 minutes. And you experience several of these cycles during the night. While the duration may vary a bit from individual to individual, the average seems to be about 90 minutes based on several studies.

A fairly old paper by Vlasta Brezinova, for example, investigated the sleep cycle duration of groups of different aged individuals. While there were some differences in the durations, the average duration was about 90 minutes. Other research papers seem to agree on this too. I have written down my research on this google doc. Feel free to go through it for more details.

The Concept

Like I mentioned, the lamp figures out the best time for you to wake up, based on when you want to wake up and when you fall asleep, and makes sure you're roused at the end of a sleep cycle.

Let me explain how that works. Let's say you sleep at 10:30 PM and you want to be up by 6:00 AM. The lamp does some quick math and calculates the end times for three, four, and five sleep cycles. That would be 3:00 AM, 4:30 AM, and then right at 6:00 AM. In this case, the lamp would wake you up at 6:00 AM.

Now, if you go to bed a bit later, say 11:30 PM, the same process happens. The end of the third cycle would now be 4:00 AM, the fourth at 5:30 AM, and the fifth at 7:00 AM. Since your target wake up time is 6:00 AM, it checks which of those cycle end times is closest. Here, it's the end of the fourth cycle, at 5:30 AM. So, that's when the lamp would wake you up.

Figuring out sleep time

Now, you might be wondering, 'How on earth will this lamp know when I actually fall asleep?' Well, the truth is, it doesn't know exactly. But, it makes a very clever educated guess. And to do this, we make two key assumptions.

First, we figure that most people spend a little time winding down before sleep, maybe scrolling through their phone or reading a book in bed. Second, we rely on some past research that suggests the average adult takes about 15 minutes to fall asleep after they've laid down for the night. This 15-minute window is also commonly used by those online sleep calculators you might have seen.

So, here's what we do: we attach a little proximity sensor underneath the lamp. Once you're done with your phone or your book and you're ready to drift off, you simply place it in front of the lamp where the proximity sensor detects it. The lamp then waits...

Read more »

SClamp_optimized.ino

Main code for the lamp

ino - 7.19 kB - 01/09/2025 at 12:42

Download

WS2813_warmWhite.ino

Code to test the LED strip

ino - 778.00 bytes - 01/09/2025 at 12:41

Download

lamp_base.stl

Lamp base for 3d printing

Standard Tesselated Geometry - 53.40 kB - 01/09/2025 at 12:41

Download

lamp_frame_A.stl

Lamp frame A for 3d printing

Standard Tesselated Geometry - 3.01 kB - 01/09/2025 at 12:41

Download

lamp_frame_B.stl

Lamp frame B for 3d printing

Standard Tesselated Geometry - 3.01 kB - 01/09/2025 at 12:41

Download

  • 1 × Xiao esp32 c3
  • 1 × Ws2813 LED strip
  • 1 × Proximity sensor

  • 1
    Lamp design

    The lamp shade itself can actually be 3D printed. If you're interested in that, you can find the STL files I made in the files section.

    Now, you might notice my lamp has this beautiful wooden frame and base. But it's not wood at all! It's foam board!

    We need two U-shaped sections. Each has a little protrusion underneath to create space for the proximity sensor, and a notch in the middle so they can connect together.

    Then I made a base out of an empty roll of cellophane tape.

  • 2
    Diffusion sheet

    To diffuse the light, we're going to use an interesting material. This is actually a diffusion sheet salvaged from a broken laptop screen.

    You can usually find these pretty easily at a local electronics scrap shop. This sheet is perfect for our project because it diffuses light beautifully, giving it a nice frosted glass look.


  • 3
    Realistic wood look

    Now, let me show you how I gave the foam board that realistic wood grain appearance. First, I mixed up a light brown acrylic paint and coated all the surfaces with it. It's important to cover the edges evenly as well. Once that's done, just let it dry completely.

    Next, I grabbed a darker shade of brown watercolor and diluted it with a bit of water. Using a sponge, I gently painted the foam pieces with long, linear strokes. Make sure to run the sponge in the same direction across all the surfaces, mimicking the natural grain of wood. Don't forget to cover those edges with the darker paint, too! Once all the pieces are coated, set them aside to dry completely.

    Finally, we need an even darker brown to really bring out the detail. I mixed some brown watercolor with just a touch of black. This time, I diluted it a little less than before. Using the same sponge technique, I applied strokes just like we did earlier, ensuring they all run in the same direction. Let it dry one last time, and you have a beautiful wooden finish! Nobody will even guess there's foam board underneath!


View all 8 instructions

Enjoy this project?

Share

Discussions

Matoslav designs wrote 01/16/2025 at 06:25 point

Interesting project! I have a lamp which simulates sunrise although at a fixed time. It also has a lovely feature which I suggest you could implement to your lamp - instead of turning the lamp off you could simulate setting sun for a preset time (I use 10 mins). I love this feature as it is gradual transition from light to dark and also helps me fall asleep better.

  Are you sure? yes | no

Makestreme wrote 01/16/2025 at 06:58 point

That's great! I thought of the same thing after publishing the project. I have updated the code with the gradual turning off animation. 

Thanks for your suggestion :) 

  Are you sure? yes | no

Dg wrote 01/15/2025 at 21:03 point

Very well done! I've once somewhat developed a lamp, but instead of following my sleep cycle, it would follow the sunrise and sunset by user location
Maybe mixing both it would be a nice lamp!

  Are you sure? yes | no

Makestreme wrote 01/16/2025 at 06:59 point

That's also a great idea and it will be much simpler to implement. Probably we could input the location info into the code and get the sunrise and sunset time from the internet. I'm sure there's a free api to get that info, just not remembering the name. 

  Are you sure? yes | no

Dg wrote 01/16/2025 at 17:11 point

The api i used was:

api.sunrise-sunset.org , having a webui to make changes, instead of hardcoding the location would be nice too!
Maybe i can share privately with you my old code that I have

  Are you sure? yes | no

zonker.harris wrote 01/15/2025 at 19:49 point

Perhaps adding a small temperature sensor that can go under the mattress, to look for the temperature drops? Perhaps that would need to be glued to a swatch of fabric, so it can be pinned ot stitched to the mattress pad?  Maybe an ambient light sensor, to tell when the sleep room goes dark? 

  Are you sure? yes | no

Makestreme wrote 01/16/2025 at 07:02 point

Those are some good options! I also have a radar motion sensor which is apparently so sensitive that it can detect a person breathing. Maybe that can be implemented, but I've not checked if it's so sensitive. 

  Are you sure? yes | no

billstewart+hackaday wrote 01/15/2025 at 17:28 point

Cool project! Unfortunately, real sleep cycles don't work that way, especially as you get older.  If you use a Fitbit or similar sleep tracker, you can see what yours are doing. It's common to get more deep sleep earlier in the night, more REM toward morning, not all cycles get all the phases, your cycle length may be shorter or longer, and things can mess it up, like alcohol or caffeine or of course noise.

I don't know if Fitbit has an easy way to integrate with other apps (probably triggers running on the phone?). There are other smart-wake alarm clock apps that use your phone's motion sensors (so you need to leave your phone on the bed), or you could roll your own motion sensor board to integrate with your clock.

  Are you sure? yes | no

Makestreme wrote 01/15/2025 at 17:42 point

You are right. Sleep cycles are never so perfect (as I've mentioned as well). What I've created is considering the average. But if you know your cycles better from maybe a fitness tracker, you can always tweak the code to perfectly suit you. 

Yup, motion sensors could be one way. Another way I was thinking is to figure out sleep patterns based on factors like breathing, heartrate, etc. And then train a simple machine learning model to accurately figure out your sleep cycles. There are lots of opportunities to improve on this! 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates