-
1Lamp 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.
-
2Diffusion 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.
-
3Realistic 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!
-
4Electronics
While those are drying, let's shift our focus to the electronics. At the heart of our lamp, we'll be using a tiny ESP32 board called the Xiao ESP32S3. This is essential for retrieving the time from the internet and ensuring the LEDs receive the correct signals.
For the light source, we're using a high-quality WS2813 addressable LED strip. A good quality strip is vital for accurately reproducing colors, particularly when you're aiming for those relaxing, ambient effects in the evening.
For both of these, I've used electronics from Seeed studio as their components are highly reliable and the LEDs are of very good quality. You can find them here: https://www.seeedstudio.com/
We'll also be using a small IR proximity sensor. You don't need a high-end one; a basic, affordable one will work just fine.
Let's get started by cutting our LED strip down to 10 LEDs.
Now for the wiring – follow the connection diagram:
To make sure everything's working correctly, I wrote a simple test code that produces a soft, warm white light. You can find the code in the files.
-
5Connections
Now we can move on to connecting all the electronics. For the Xiao ESP32, I recommend creating a small socket with wires soldered to female headers. I've shown how to make this in a previous project.
Unfortunately, right around this point, my soldering iron decided to give up on me! So, for the remaining connections, I had to use jumper wires. You can follow the wiring diagram here to make your connections.
Make sure to leave three female jumper connectors free underneath for the proximity sensor that we'll connect later.Okay, it might not be the prettiest wiring job, but since it'll be hidden inside the lamp, it's perfectly functional for now. Once my new soldering iron arrives, I'll definitely be tidying things up with proper soldered connections.
-
6Assemble
Grab the rubber adhesive and apply a generous amount to the notches of both the U sections. Let the adhesive air dry for about 5 minutes before sticking the two pieces together. This creates a much stronger bond when you press the pieces firmly together.
Next, take the diffusion sheet and carefully wrap it around the base. Apply some rubber adhesive to the overlapping ends and secure them together. Do the exact same thing for the base cover.
If you noticed, I didn't glue the diffusion sheet or the base cover directly to the base itself. This is to allow me to easily remove them later if I ever need to troubleshoot or access the electronics.
You'll also notice I've created a small slot in the base. This is specifically for the USB-C cable, allowing us to power the ESP32 and reprogram it if needed without taking everything apart.
Finally, carefully slide the entire base assembly between the two glued U-sections.
Attach the proximity sensor underneath with double sided tape. And just like that, the main structure of our lamp is complete!
-
7Code
Now it's time to upload the main code to our ESP32. It largely follows the same principles we discussed at the beginning.
The code uses the internet to fetch the current time. This can be eliminated if you're using an RTC module. It has a function named runSunriseAnimation() that simulates that beautiful sunrise animation I mentioned earlier. And the function calculateWakeTime() calculates the wake time based on the current time (sleep time). It assumes a 15 minute time to fall asleep and 90 minute sleep cycle. It then calculates the closest time to wake you up based on a set ideal wake up time (7:00 AM in the code)
Now, to be honest, my code might not be perfect, so I really encourage you to take a look at it. If you spot any areas for improvement, please do share your suggestions in the comments – I'd love to hear your ideas and learn from you. For now though, the code is functioning as intended and will get our lamp working.
You can find the code in the files.
-
8Conclusion
And there you have it! Our sleep cycle lamp is finally complete! Doesn't it look fantastic? Honestly, who would ever guess it's not real wood? Plus, we gave a new life to a discarded laptop screen – that's a win-win!
Now, using it is simple. Before you start winding down for the night – whether you're catching up on your phone or enjoying a book – just turn the lamp on. Then, when you're ready for sleep, place your phone on the table in front of it and drift off. The lamp will handle the rest, gently turning off and waking you up at the optimal time, all without disrupting your sleep cycle. I’d like to have a speaker to produce sounds along with the sunrise effect though.
Thanks for reading till here!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.