# Wake Me Up Light

971

7

1

## Introduction: Wake Me Up Light

Can light wake you up in the morning?

Winter is coming, nights become longer than days, and it’s a nightmare for me to wake up at 6 am into a dark and cold room. What if there was a way to create artificial “sunrise” to make the room feel much warmer and pleasant?

This is an easy task, I am going to create a smart light bulb that fits into my current ceiling lamp. It will simulate a sunrise by slowly light up the room. If it works I am going to connect it with my phone to make it a proper alarm clock.

## Step 1: Lightbulb

To create a smart lightbulb you first need a "dumb" bulb because of its socket that is screwed into a lamp and provides power supply. I smashed it with a hammer. This delight procedure removed the glass from the aluminum socket and after soldering wires to socket and pin at the bottom, the base of the smart lightbulb was ready.

Next, you need a support for all the electronics. I used a perf board and cut it to fit an Arduino Nano microcontroller, 5V power supply, and all the electronics components.

## Step 2: High Voltage Circuit

Safety warning: You are working with voltages greater than 50V. Contact with high voltage may result in severe injury or death.

Since I am using a regular light bulb which is powered from AC mains voltage I cannot directly use microcontroller to control the power going to the light bulb. I need a TRIAC. This little device acts as a relay that can switch on and off pretty quickly. The microcontroller will power on and off the triac in order to alter the AC sine wave, thus dimming or brightening the light. However, AC voltage is controlled differently than DC voltage. AC sine wave needs to be cut in precise manners and so triac have to be turned on and off in precise moments to achieve that (see image below). In other words, microcontroller needs to know when the sine wave of mains voltage crosses zero to cut each of the half waves to the same size. Otherwise, the light would be flickering.

To detect zero crossing of mains voltage there is a 4N35 (U1) optocoupler with a transistor which turns on when sine wave crosses zero. The microcontroller will see that as a high signal on its input pin. Optocoupler has another function, it is to isolate the low voltage from the mains voltage circuit.

Second optocoupler - MOC3063 (U2) - with a triac on output is used to isolate microcontroller from high voltage triac (Q2). Make sure you are not using optocoupler with zero-cross feature because it only switches on when sine wave crosses zero.

## Step 3: Low Voltage Circuit

As a microcontroller, I am using Arduino Nano. Its main purpose is to control triac and to start turning on the light when the set time comes. To provide real-time clock there is DS3231 accurate real time clock module which also preserves time when power is lost.

To provider 5V for chips, I am using cheap 5V 700mA step-down power supply connected to mains voltage from bulb socket. Nice and handy solution!

## Step 4: Code

The program is pretty simple, when the lamp is powered up by the switch it will light up the room an slowly dim it into the night as a verification that electronics still work. During the night it checks the real-time clock stored in the DS3231 module and finally at 6 am the room is slowly light up to full "daylight" until the lamp is powered off by the switch.

Check out the code attached I think its self-explanatory. If it's not I am a bad developer!

## Step 5: What's Next?

Now I will experiment for a few days or weeks and if it can wake me up in the morning I will evolve this project into something more smarter and less crude!

Good night!

45 5.5K
102 5.1K
283 20K
88 9.3K