The body is made to wake up with the sunlight. I really hate getting up in the morning when it’s dark in my bedroom. Thats particulary bad in the winter when the sun rises after I should get up, but also in the summer, because I have very light tight curtains.
A dawn simulator is a light that gets slowly on in the morning to simulate a dawn and let the body wake up very smoothly.
There are many dawn simulators out there to buy, but I wanted to build one on my own for quite some time and now I did it.
Schematic
To finally build one was a very spontanious decision, so I had to use parts I had at home for the first prototype.
Microcontroller
I had three µC laying around, one ATmega1284P, a ATtiny45 and an Arduino Pro Mini.
The ATmega1284P is one of the most powerful ATmegas out there, with a lot of flash, SRAM, peripherals and 44 pins. This one is definitely overpowered for a dawn simulator.
The ATtiny45 is the opposite, it has only 8 pins, some flash, some SRAM and not so many timers and stuff. But a dawn simulator doesn’t have to do very much. One timer for the light PWM, an I²C Bus for the display (more on this later) and the other pins for the input. This doesn’t seem too bad.
The display I’m using comes with an Arduino library which is no problem, because you can use an Arduino library without an Arduino, but this library buffers the whole display in the RAM. And because of the size of the display this buffer takes up 512 bytes, which is more RAM than the ATtiny45 has. So it is also not usable.
The Arduino Pro Mini with its ATmega328P is in-between, but I normally don’t use Arduinos so I actually never considered it, but it is the best one for this task.
Display
I have some old mobile phone displays, LCD dot displays and two monochrome OLED displays from Adafruit laying around. The OLED display has the big advantage that the black pixels are really black, so there is no black glowing in the night.
This is the display I’m using: https://www.adafruit.com/products/931
It also comes with an Arduino library: https://github.com/adafruit/Adafruit_SSD1306
Light
For the light I choose two white 5W LEDs. They need a voltage of 17V and the µC controls them with a MOSFET. I found an IRL3803 that is rated with 140A, enough for two LEDs.
Breadboard
I built the circuit on breadboard like this:
+5V
+17V
I²C Bus
Cables to the switches
PWM signal
Other connections
I have an LDO built in my breadboard “housing” and so no need for an extra LDO on the breadboard. All the other circuit is pretty self explaining I think.
Final image of the circuit:
Here you can see I put the LEDs on the metal for cooling.
Arduino Code
To bring the circuit to life the µC needs code. I finally ended up using Arduino, its perfect for prototyping because it helps you with a lot of stuff.
Libraries
I used the following libraries:
- Adafruit SD1306 https://github.com/adafruit/Adafruit_SSD1306 it requires:
- Adafruit GFX https://github.com/adafruit/Adafruit-GFX-Library
- Time Library https://www.pjrc.com/teensy/td_libs_Time.html
- TimeAlarms https://www.pjrc.com/teensy/td_libs_TimeAlarms.html
Code Parts
The code is split up in five parts:
The core contains the setup()
and loop()
functions and the time-keeping and alarm code.
|
|
The input part handles the buttons. It detects button down and a long press.
|
|
The program can be in multiple states e.g. show time, change time or change sunrise duration.
|
|
The pwm part initializes the timer and calculates the sunrise.
|
|
This code draws everything on the display.
|
|
Download full code
Video
This video shows the dawn simulator in action.
It is very interesting to see how the camera can’t cope with the pwm of the LEDs.
Prospect
This is just a prototype, I’m already planning the next version. It will come with a internal power supply of which the high voltage (17V) part can be turned of to save power, a rotary encoder for input, a battery powered real time clock to never loose the time, red, yellow and white LEDs for an beautiful gradient and everything in a real casing.
I have already ordered the parts and will publish my progess here.