Night Light Saver V5.0

Wichit Sirichote,

Build a device that turn on and off a night light automatically. Save Energy, No EMI, No Battery, Built-in Lamp Fixture, and Peak Shaving.


The Saver V5.0 runs simple clock emulation program, turns a night light on and off with preset time, say 19:00 to 22:00 everyday. The design features low cost, easy installation, no battery backup and no EMI. The AT89C2051 uses external oscillator generated by schmitt trigger gate CD4093, ~680kHz. Reference frequency was derived from 50Hz main line. Time setting only allows at 18:00 by pressing time set button once. If main line has failed, functioning LED will blink at high rate . Since there is no battery backup, thus repressing the button is then needed. The output is capable of driving say, a 25W incandescent lamp.

Circuit Description

The schematic of the SAVER V5.0 is depicted in Figure 1.
    Caution!! High Voltage!! Do not touch any conductive parts of the circuit

    Figure 1: Schematic of the Saver V5.0
Explanation of the circuit operation for each parts is as follows;

1)Transformerless direct supply: R1 and C1 forms a simple current limitting AC source. D1 and D2 converts AC to DC with C2 performing a reservoir. D3 limits voltage across the circuit to ~5V.

2)External oscillator: A reliable schmitt gate oscillator with R8 and C5 produces clock approx. 680kHZ. One machine cycle is ~18us.

3)89C2051 circuits: C4, 33uF and R4, 10k forms a reset circuit that need time for riasing logic at least two machines cycle. S1 is a momentary button for setting time to 18:00 by pulling P3.0 to logic low. The functioning LED is connected to P3.7. Q2 is a small triac MAC97A6, and is drived by Q1, PNP transistor sinking through P1.7.

4)Reference frequency: R3 and C3 integrates a 50Hz main frequency and unwanted transients producing triangle-like waveform which is fed to U2 schmitt gate. The output pin4 is clean 50Hz square wave tied to int0.


Saver5.hex is HEX file suitable for Easy-Downloader V1.1 for writing the code to the chip. This file sets time to 18:00 when press S1 once. Time on and off is set to 19:00 to 22:00 everyday. And finally the reference main frequency is 50Hz!!

The original source program SAVER5.C was written in 'C' language. User may change set time when press S1 and change time on/off. It is a good idea to include peak shaving period, say 20:00 to 20:30 depending on living area. By placing timeOn3 and timeOff3 in the function comparetime(), see the source program. To recompile the source file you need a Micro-C Compiler from Dunfield Development System with tiny memory model and need some modification of the runtime file by putting external interrupt service routine that increments cputick variable.


The Saver may be built-in any kind of lamp fixtures. Figure 2 shows the author's concept for building-in a 25W lamp fixture.
    under preparation
    Figure 2: The author's concept lamp fixture with built-in Saver circuit
Although the Saver can operate even wrong connection of L and N to the circuit. The author suggests to correct AC line connection to L and N of the circuit. After finished installtion, turn the main switch on, functioning LED will blink at high rate. Let try press S1 once, the lamp will turn on 1 minute then off. The Saver assumes the current time is 18:00. Then wait for the clock at your home reachs 18:00, press S1 again.

Note that everytime you press S1, the lamp will turn on 1 minute only once. The day after the lamp will then turn on and off at preset time. Functioning LED will blink at low rate indicating normal operation.

If high blink rate is noticed when return home, power failed should happen, no problem just wait again 18:00 then press S1. If the LED is not blinked, someone may turn main switch off, turn it back on again and wait for 18:00.

Energy Saving Lamp

The Saver was not designed for turning such energy saving lamps on and off. They mostly use internal high frequency inverter. I have been tested with one from National, it works!! But I am not guarantee for your energy saving lamp. I would be grateful if you could test and let me know the result.

Components Listing

  1. C1 0.44 uF 250Vac AC capacitor
  2. C2 330 uF 25V electrolytic capacitor
  3. C3 1uF 16V nonpolar polyester capacitor
  4. C4 33uF 16V electrolytic capacitor
  5. C5 50pF disceramic capacitor
  6. R1 50Ohm 1/4W resistor
  7. R2 1M 1/4W
  8. R3,R4,R8 10k 1/4W
  9. R5 220Ohm 1/4W
  10. R6,R7 1k 1/4W
  11. D1,D2 1N4007 rectifying diode
  12. D3 zener diode 5.1V 1/2W
  13. D4 small LED
  14. Q1 2N2907 PNP transistor
  15. Q2 MAC97A6 triac
  16. U1 AT89C2051 Flash Microcontroller
  17. U2 CD4093 schmitt nand gate
Night Light Saver V5.0 was designed by W.Sirichote
Saver.C was wriiten by W.Sirichote

This Document is Copyright(C) 1999 by Wichit Sirichote.

Build Your Own uC Projects

Last updated, 9 October 2542