Sunrise simulator

You can check this project out on:


Warning: this circuit deals with mains voltage which is lethal. DO NOT attempt to build it unless you perfectly understand what you are doing. I am in no way responsible for any consequences which result from any use of information on this page.


Waking up in the morning is a daily and early task. Throughout my life I have used different ways of waking up: the usual alarm clock connected to a high power siren and flashing lights, a high power buzzer fed by AA batteries hooked to a portable alarm clock(for when traveling), and of course the most used is the mobile phone alarm.

All these methods have worked, but they provide a rather sudden wake up. Recently I found out about the idea of simulating the sunrise. It seems like a more pleasant way of waking up, especially in the winter, so it had to be tried. I decided to make it as simple as possible for the beginning, so getting a normal radio-alarm-clock and modifying it seemed like a great idea. These clocks are available in many models, some rather cheap, so I picked one up.

Next, off to the hardware store to buy a light source. A 150W halogen reflector seemed right for the job, especially because it was very low price. Added some cable and plug and I had all I needed.

The first task was to open the alarm clock and find the alarm signal. This was not that hard.

Looking at the components, the audio amplifier was a very known part, the TDA2822 (1). As this is one of the components that need to be turned on I followed the power supply traces. The positive led me to a transistor and a Zenner diode – there was a simple voltage stabilizer for it (2). Looking carefully I realized that it was controlled by another transistor and this by another one (3) which is turned on by signals coming from three diodes (4), (5) and (6): there is an OR function implemented there. This is because the radio is turned on by any of the three signals, two from the microcontroller which are the alarm (7) and sleep function and one from the switch. An electrolytic capacitor and some resistors were placed there and this seemed like a filter. At first, I thought that there was no need for one, until I looked at what signal the microcontroller was providing: it was the beep-beep-beep signal which is used alternatively as an alarm (instead of the radio). This is why it needed low pass filtering, to extract a steady dc which would turn on the regulator for the audio amplifier and radio.

The next step was to find a way to power my circuit which will take care of the sunrise simulator. As the function is not that complex, I decided to go for an ATTiny13 microcontroller which I already had. This requires 2.7 to 5V to operate correctly. Guessing that the clock’s controller would be in the similar range, I looked for another regulator on the board and quickly found another zenner diode + transistor pair (8). This provides 4.2V which is excellent for my circuit. Adding my circuit to the regulator’s load shouldn’t be a problem as it provides power for the clock’s display which is rather high compared to how much the ATTiny13 will consume.

In order to dim the light, I needed synchronization with the A.C. network. As there is already an A.C. output from the clock’s transformer I decided to take it from there instead of connecting somehow directly to the mains, although this means being a little offset.

It is now time to put together the little schematic that does it all. Here it is:

Things are rather simple. The “brain” is the Attiny13 microcontroller which should be enough for this simple task.

For the A.C. synchronization I’m going to use the internal comparator. This is because the input threshold of a pin is about 2V (half of VCC) and the transformer outputs about 9Vac so the error for detecting the zero cross is high. R4 and R5 form a divider which provides about 0.1V for the comparator reference.  The A.C. signal is fed through a 10K resistor which ensures a current limiting, as the protection diodes inside the microcontroller limit the input range between about -0.6V to VCC+0.6V.

The circuit that I have designed will make a bypass between the clock microcontroller and the clock’s alarm, allowing for the sunrise to be simulated before the alarm is triggered. ALARM_IN and ALARM_OUT pins allow this function to be implemented. R3 is there because it has been removed from the clock’s PCB to allow the bypass.

The lamp is controlled, as expected, via a triac. Because safety is very important, an optoisolator separates the mains from the clock and my circuit and a fuse is included.

Building it:

Building the circuit has nothing special in it, as it is rather simple. It’s build on a small prototyping PCB adapted for the free space inside the radio. A reset button was included to help with the software development, but it is not needed during normal operation.

The bypass:

Fitting it inside the clock:

Due mostly to lack of space inside the clock I have decided to split things in two parts, putting the triac and optoisolator in a small junction box near the reflector. This solution is temporary and I will improve it once I find something more suitable, the goal being to add a normal socket to allow me to plug any lamp in. A small heat sink ensures that the triac only gets slightly warm during full on with the 150W light bulb.

The software:

There is not much to explain about the software. Basically there are two parts: the lamp dimming which uses the interrupts and the control software. For more info on lamp dimming see the wiki.

Lamp dimming requires two parts: first is detecting the zero cross which takes place at the comparator toggle producing an interrupt. At this point the timer is loaded with a previously determined value. The timer overflow interrupt routine triggers the triac. Based on the value that was loaded in the timer counter this event takes place in a certain point during a half period of the A.C. which determines how much time the triac is conducting thus determining the power through the lamp. The timer may be loaded with a value that prevents the triac from ever been triggered, keeping the lamp completely off.

The main part of the software has a three stage functionality. Fist stage is to wait for the alarm. Once it is signaled the lamp is slowly turned on while periodically checking if the alarm is still on, this is the second stage. After the light reaches the maximum intensity the actual alarm in the clock is turned on, for the third stage. When the user turns off the clock alarm the light turns off and the circuit goes back to the first stage.

The time it takes for the light to reach its maximum intensity is determined by a parameter in the software and it is a multiple of 2 minutes. So the minimum is two minutes, the maximum is about 8 hours, if that could be of any use. I have set it for 20 minutes. Of course, this requires me to set the alarm 20 minutes earlier than when I want it to sound.

Software is written in C and compiled with avr gcc. It is available for free for personal use.


And finally, everything put together working:

The results:

Everything seems to be working fine, waiting real life testing. But this has to wait for a few days until my vacation is over. Still, the effect seems to be very pleasant: light starts emerging from total darkness, being reddish at the beginning and moving towards a bright white, much like a real sunrise.

If this proves to have a real benefit, I already have future plans for it: build a custom clock from zero, add a memory card for audio, maybe a brighter lamp and more functionality that this setup doesn’t provide.

Update: Apr 21, 2010

After more than a week of testing it the results are in: I managed to wake up before the sound alarm about half the times. For the rest of the times, waking in a lit room seems much better than normal. I am thinking of changing the position of the light and maybe getting a bigger one.

I am really pleased by the effect it has and I am looking forward to proving its good use in wintertime.


Update May 7, 2011

I have just added a 60Hz powerline frequency software version:  sunrisesimulator60Hz

Bookmark the permalink.


  1. Thanks for one’s marvelous posting! I truly enjoyed reading
    it, youu haplen to be a great author.I will remember to bookmark your blog and will often come back later on.
    I want to encourage yourself to continue your great job,
    have a nice morning!

  2. Pingback: 21 Tricks Every Non-Morning Person Should Know 2015 |

  3. Pingback: 21 Tricks Every Non-Morning Person Should Know | The Lighter Side of Life

  4. Pingback: 21 Tricks Every Non-Morning Person Should Know ⋆ The NEW N!FYmagThe NEW N!FYmag

  5. If you are going for finest contents like me, only pay a quick visit this web site all the time for the reason that it provides quality contents, thanks

  6. Pingback: 21 Tricks Every Non-Morning Person Should Know |

  7. Pingback: הפטריה | 10 שעונים מעוררים מגניבים ויצירתיים במיוחד שיכריחו אתכם לקום מהמיטה

  8. Pingback: 21 Tricks Every Non-Morning Person Should Know - LowBoreDom

  9. Pingback: LOOK: 21 Tricks Every Non-Morning Person Should Know! | The New 925 Fresh FM

  10. Pingback: 21 Tricks Every Non-Morning-Person Should Know #buzzfeed | National Cubicles

  11. Pingback: A Dear Friend’s Passing

  12. Hi this is really cool but I’m not an engineer and this is all really complicated. Is there a way I could use this cheap light clock combo (see link below) but modify it to control a different lamp. With some basic soldering maybe?


    • It appears to be using a small LED light which requires a totally different control compared to a mains bulb. Sorry, it would still require a microcontroller and programming.

  13. hi bogdan,

    first of all i want to say THANK YOU for posting your project! 🙂
    it is almost exactly what i was searching for.
    but due to the fact that i am not that a profi in electronics like you are, i have one question:
    is it possible to put this circuit directly before the sound device/speaker of an alarmclock? this would allow me to easily find the place where i have to put the circuit.
    hope i described it good enough that you can understand what i mean 😉

    have a nice evening!

    • It is possible to use the speaker signal for detecting the alarm signal. But you will have to read that input with the ADC because the speaker will have a lower level, probably not enough to be read as logical 1. This means changing the software.
      You will still need the rest of the signals (power, ac sync etc).
      Do you want to turn on the speaker at the end of the sunrise?

  14. Hello,

    In treatment of SAD, we use relatively low intensity illumination (max 250 lux) over a 90 minute period (ending with wakeup time).

    Nice project!

    Derek Eder

    • I have the spotlight placed in a corner of the room, about midway between floor and ceiling, aimed upwards. The resulting illumination is comparable to the regular room light (just a 23W CFL), but it is less uniform. Just to give you an ideea…

  15. Hey check this out:
    hook up an IR led, automate your room:
    set the hifi to a predefined volume/station/track, (maybe fade up the volume)
    add any other IR scripts, TV, shades… to your awakening.

    some IR learning:

  16. Hi,
    Im trying to build a dimmer for my aquarium based on ambient light. Basically based on sunlight outside the lights should go off or go on.

    I would like to discuss more on how the above can be modified to the same. Please do let me know.


    • I always saw aquariums lit with fluorescent tubes, but those cannot be dimmed. You may only choose to turn them on or off. For this you need a different kind of circuit, do a search on ‘dusk dawn circuit’.
      You may also purchase these sensors at shops that sell stuff for your home or garden, as it is common for people to want certain lights to turn on at night. They usually have a sensitivity adjustment so you can choose how dark it gets before they turn the lights on.

  17. I considered making a sunrise simulator too, only using 12V (perhaps car) lights. I bandoned that once suitable lamps came on the market. The Philips one I have is pretty terrible (as Philips things always are, but it was the only one back then) but it seems to work.

  18. Ever try connecting a space heater to this as well? If you live in a cold place like I do, a warm room and a gentle light would do the trick!

    • There shouldn’t be any problems connecting a heater, you just need a more powerful triac.
      But i think that you might like to start it at full power just from the beginning, in this case you’ll need to connect the switching element(triac/relay) to the signal coming from the clock which gives the start of the sunrise.

      Technical details aside, it’s quite a great idea to warm up the room, but you might need a longer period than the sunrise to create a desirable effect.

  19. Thank you for this post and the link back to my site. Very interesting stuff!


  20. I really like your design and I’m gonna give it a try. I will be building this to use in the US so my line voltage for the lamp will be 120v instead of 220v as shown in your design. Will the lower line voltage require any component substitutions?

    • Whether you need to modify it or not will depend on the particular clock type you will use. THere is one major modification required: modifying the software for 60Hz which is your line frequency. That I can do for you, I will modify the software and post a 60Hz version soon.
      There is one other thing you will need to consider: the microcontroller works up to 5V only so you will need to find a regulated voltage somewhere inside the clock below that. I’m not sure that all clocks will have this.
      Feel free to contact me for more help.

      Good luck building it!

      • Hi, Electro Bob! I really like your sunrise simulator. I hope to make one using a (1980’s I think) Sony radio alarm clock, but like CaptMorgan I need it for 120V, 60Hz power instead of 220. Did you ever do that modification to your design? Or have I somehow missed it on your web page? Thanks very much for sharing this great plan! I’ll appreciate any help you can offer to make the conversion to 120V, 60 Hz.

  21. When I was in university, I’ve already wanted to build a sunrise simulator. At this time I did not know how to control a 220V lamp using a microcontroller but I kept it in mind. Having seen your tutorial I am one step closer to making it real again as soon as I have plenty of time. I appreciate the effort you put in creating this site.

    Best regards

  22. This is AWESOME!
    Great idea… 🙂

  23. Pingback: Deaf Village

  24. Pingback: Electrical / Electronics Mini Project Idea - Sunrise Simulator

  25. Pingback: Create A DIY Sunrise Simulator To Wake Up Peacefully | Lifehacker Australia

  26. I want to quote your post in my blog. It can?
    And you et an account on Twitter?

  27. Pingback: A fake “SUN” in your bedroom to wake you up… | Tech Sputter

  28. Pingback: Waking up with the (fake) sun - Hack a Day

  29. Salut!
    Pentru a programa in linux un mcu de la atmel, cel mai simplu e sa folosesti eclipse cu pluginul avr-eclipse si cu avrdude instalat.
    Apoi configurezi programatorul din pluginul pentru avr.
    Daca ai probleme sau daca vrei sa te ajut cu ceva adresa mea de mail este

  30. vinlaptesimiere


    Interesanta aplicatia !
    Ma poti ajuta, te rog, sa programez un atmega16 in linux ? Folosesc AVR 910 Serial2usb si Slax !

  31. Pingback: Microclub » Simulator de rasarit… pentru cei care se trezesc mai greu dimineata

Leave a Reply to iMacBB Cancel reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.