Introduction: Wakeup Light

As I write this instructable it is mid winter on the Northern cerebral hemisphere and that means brusque days and long nights. I am used to getting in the lead at 06:00 and in the Summertime the Sun volition be shining by and then. In the Winter though, it gets light at 09:00 if we are fortunate to have a twenty-four hour period that it isn't cloudy (which is...non often).

Much time ago I understand about a "wakeup light" made by Philips that was used in Norway to simulate a sunny aurora. I never bought one, but I kept thinking or so making uncomparable because making one yourself is more fun than just buying IT.

Supplies

Picture frame "Ribba" 50 x 40 cm from IKEA

perforated chipboard from hardware put in

STM8S103 development circuit board via Ebay or others

DS1307 Real Time Clock (Mouser, Farnell, Conrad, etc)

32768 Hz watch crystal (Mouser, Farnell, Teodor Josef Konrad Korzeniowski, etc)

3V lithium coincell + coincell holder

BUZ11 operating room IRLZ34N N-channel MOSFETs (3x)

BC549 (or whatever other NPN junction transistor)

Eastern Samoa many white, red, blue, dark-green, etc leds as you neediness

whatever resistors and capacitors (see formal)

Powerbrick, 12V to 20V, 3A operating theater more (e.g. old laptop powersupply)

Step 1: Devising Information technology (a Itsy-bitsy) Easier to Get Astir

The musical theme is that IT is concentrated to scram out of bed in the morning when IT is still dark. And if you survive close or even higher up the Arctic Circle it will equal dark really mindful. In places as Tromsö in Norway it will not get light at all as over on that point the sun sets half November only to atomic number 75-appear halfway Januari.

So what Philips did was simulate the rising of the sun.

Philips slowly increases the cleverness of a the lamp, which is probably ready-made with several leds merely hidden behind a single diffuser. Their time from murder to full luminance takes 30 minutes.

The Philips wakeup lights aren't that expensive but it has just a single vividness and it looks a bit small. I think I can perform better.

Step 2: More Colour

My wakeup light uses four colours, empty, red, blue and greens. Inaugural
come the white leds, then come red ones, and last a few blue sky and greenness leds. My mind was that I could simulate not only the increase of luminousness but also the shifting of the morning light colour, by starting with a trifle of white, adding in cerise a second afterwards and mixing in dispiriting and super in the end. I'm not sure that it actually does resemble actual morning friable, but I like the colourful display As IT is now.

Mine is also faster than the Philips wakeup dismount, instead of the 30 minutes of the Philips light, mine goes from 0% to 100% brightness in less than 5 transactions. So my sun rises much faster.

NOTE:

It is VERY hard to make over pictures of my wakeup light, I tried with several camera's and smartphones but all pictures I ready-made manage not do the real thing justice.

Step 3: Sigmoidal Curve, Flickering and "resolution"

Of course I wanted to make the brightening arsenic smooth As possible. Human eyes are logarithmic in sensitivity, significant that in total iniquity they are more sensitive than they are in full day. A very gnomish increase in brightness when the levels are rock-bottom "feels" the same every bit a practically bigger step when the light is at say 40% brightness. To achieve this I used a exceptional curve called Colon (or S-curve) this arch starts as an exponential curve that halfway levels off again. I found that it is a selfsame nice way of increasing (and decreasing) the vividness.

The clock frequency of the microcontroller (and the timers) is 16 MHz
and I use the maximum solvent of TIMER2 (65536) to create three pulse width signals (PWM). Thus pulses come 16000000 / 65536 = 244 multiplication per second. That is far higher up the fix of the eyes to examine any aflicker.

Thusly the leds are fed with a PWM impressive that is made with this 16 bit
timer of the STM8S103 microcontroller. At minimum this PWM signal lavatory be ON is 1 pulse distance long and the remaining 65535 pulse lengths off.

So the leds connected to that PM signal will then get on 1/65536-th of the time: 0.0015%

At the supreme they are ON 65536/65536-th of the clock time: 100%.

Step 4: Electronics

Microcontroller

The brain of the wakeup light is a STM8S103 microcontroller from STMicroelectronics. I like to use parts that have just plenty capabilities for a job. For a simple task as this IT International Relations and Security Network't neccessary to use STM32 microcontrollers (my other favorites) but an Arduino UNO wasn't enough as I wanted three PWM signals with 16 bit resolution and there is No timekeeper with triad output channels on an UNO.

Realtime Clock

The time is read from a DS1307 real time clock that works with a 32768 Cycl crystal and has a 3V backup stamp battery.

Mise en scene of the new time, day and the wakeup fourth dimension is through with two buttons and shown of a 16 x 2 LCD character display. To keep my bedroom real dark at night, the backlight of the LCD display is switched on only when the leds are brighter than the backlight and when you are background the metre, daytime and wakeup metre.

Force

Power comes from an old laptop computer power provision, mine produces 12V and
can deliver 3A. When you have some other power supply IT may be necessary to adjust the resistors in series with the led-string section. (See below)

Leds

The leds are conterminous to the 12V supply, the rest of the electronics
works on 5V made with a 7805 elongate governor. In the schematic information technology says that I use a TO220 regulator, that ISN't needed every bit the microcontroller, display and real time clock use sporting a few milliamps. My clock uses a small TO92 interpretation of the 7805 capable of supplying 150mA.

The shift of the led-strings is done with N-channel MOSFETs. Again, in the schematic it shows unusual devices than I used. I happened to induce exactly three really old BUZ11 MOSFETs instead of the newer IRLZ34N MOSFETs. They work fine

.

Naturally you can put in as numerous leds as you like, as agelong as the MOSFETs and the powersupply can handle the current. In the schematic I have drawn just one string along of any colour, in reality there are several each colour parallel to the other strings of that color in.

Step 5: Resistors (for the Leds)

About the resistors in the led strings.
White and blue leds usually have a voltage of 2.8V over them when they are at full brightness.

Red leds have just 1.8V, my green leds let 2V terminated them at glutted brightness.

Another thing is that their full brightness isn't the same. So it took some experimenting to make them as bright (to my eyes). By making the leds evenly bright at full brightness, they will also look equally bright at lower levels, the pulse width signal always switches them on at full brighness just during longer and shorter times, your eyes take care of the averaging.

Begin with a calculation like this. The power supply delivers (in my case) 12V.

Four white leds in series need 4 x 2.8V = 11.2V, this leaves 0.8V for the resistor.

I had found that they were glittery enough at 30mA so the resistor necessarily to Be:

0.8 / 0.03 = 26.6 Georg Simon Ohm. In the schematic drawing you see that I inclose a 22 ohm resistor, fashioning the leds honorable a little bit brighter.

The blueing leds were too bright at 30mA, but compared discriminate to the white leds at 15 mommy, they also had about 2.8V o'er them at 15mA so the calculation was 4 x 2.8V = 11.2V again leaving 0.8V

0.8 / 0.015 = 53.3 ohm thus I chose a 47 Ohm resistor.

My red leds likewise need some 15 mama te be equally bright as the others, but they lonesome have 1.8V all over them at that current. So I could put down more in series and still have some "room" for the resistor.

Vi bolshie leds gave me 6 x 1.8 = 10.8V, so over the resistor was 12 – 10.8 = 1.2V

1.2 / 0.015 = 80 Ohm, I made it into 68 ohm. Even as the others, a tiny bit brighter.

The green leds I used are as bright as the others at about 20mA. I requisite sporty a few (even as the blue ones) and I chose to put four in series. At 20mA they have 2,1V all over them, giving 3 x 2.1 = 8.4V

12 – 8.4 = 3.6V for the resistor. And 3.6 / 0.02 = 180 ohm.

If you build this wakeup light it is unbelievable that you have the comparable mightiness render, you will feature to adjust the number of leds nonparallel and the resistors needed.

A small object lesson. Allege you have a powersupply that gives 20V. I would chose to set 6 down in the mouth (and white) leds serial, 6 x 3V = 18V so 2V for the resistance. And lets say you comparable the brightness at 40mA. The resistor and so needs to be 2V / 0.04 = 50 ohm, a 47 ohm resistor will be fine.

I advise non to go any higher than 50mA with ordinary (5mm) leds. Some can hold more, but I like to be on the safe go with.

Step 6: Software

All the code can be downloaded from:

https://gitlab.com/WilkoL/wakeup_light_stm8s103

keep the source code out-of-doors, next to the reside of this instructable if you want to succeed the account.

Main.c

Main.c first sets up the time, timers and other peripherals. Near of the "drivers" I wrote victimization the Standard Library from STMicroelectronics and if you stimulate any questions about them, write it in a annotate under the instructable.

Eeprom

I left-of-center the "text to display" code that I used to put together texts in the eeprom of the STM8S103 as comments. I wasn't sure that I had enough tasteless storage for all my code so I tried to put A much arsenic possible in eeprom to have all flash for the program. In the death that proved not obligatory and I moved the text to winkle. But I remaining it as commented unconscious schoolbook mainly.c file. It is nice to have it, when I involve to do something similar later (in other see)

The eeprom is still used, but only for storing the wakeup-time.

Once a second gear

Subsequently setting up the peripherals the code checks if one second has passed (done with a timer).

Card

If that is the lawsuit it checks if a button was pressed, if so it enters the menu where you give notice set the current time, the day of the hebdomad and the wakeup time. Remember that information technology takes near 5 proceedings to go from off to full brightness level, so set the wakeup time a piece before.

The wakeup time is stored in eeprom so that flatbottomed after a power outage IT will "know" when to wake you. The latest time is stored in the real clip clock of course.

Comparison current & wakeup time

When no release was pressed IT checks the circulating metre and compares it with the wakeup time and time unit. I don't want IT to wake me in the weekend :-)

Most of the time nothing needs to be through so it sets the variable "leds" to OFF else to ON. This variable is curbed together with the "change_intensity" signalize, that is too coming from a timer and is active 244 times per second. So when the "leds" variable star is ON the strength is increased 244 times per bit and when it is OFF is decreases 244 multiplication per second. But the increment goes in single steps where the decrease is in steps of 16 meaning that when the wakeup light has hopefully done its job, it turns off 16 times faster but still smoothly.

Smoothness and Dead OF Retentiveness

The suavity comes from the Sigmoid curve calculation. The calculation is quite acicular but it necessarily to be done in floating point variables (doubles) because of the exp() procedure, see the file sigmoid.c.

In the standard situation the Cosmic encyclopaedist / linker does not have support for floating point variables. Switching it along is pleasing (once you make institute it) but is comes with an addition in code sizing. This increase was also a great deal to make the code fit in flash memory when conjunct with the sprintf() function. And that function is needed for converting numbers racket into textual matter for the display.

Itoa()

To remediate this problem I created the itoa() function. This is a Integer To Ascii use that is preferably common, but non included with the STMicroelectronics canonical library, nor with the Big libraries.

Ill-trea 7: IKEA (what Would We Answer Without Them)

The flic from was bought from IKEA. It is a Ribba frame of 50 x 40
cm. This material body is quite unintelligible and that makes it great for concealment electronics tush IT. Alternatively of a poster OR picture I submit a piece of perforated chipboard. You hindquarters buy it at the hardware memory boar where information technology sometimes is called "bed board" It has small holes in it that successful information technology ideal for putting in leds. Alas the holes in my board were a snatch bigger than 5 mm so I had to use hot-glue to "mount" the leds.

I ready-made a orthogonal hole in the centre of the delicate board for the 16x2 display and pressed it in. The PCB with complete electronics hangs on this display, it is not mounted to anything other.

The cut hardboard was spray painted black and but in slow the mat. I drilled two holes in the frame for the buttons to set the time and date, as the frame is rather thick I had to widen the holes on the inside of the redact to draw the buttons stick out enough.

Be the First to Share

Recommendations

  • Anything Goes Contend 2022

    Anything Goes Contest 2022