Timer for remote sockets
For the control of the lighting around my home (and inside if I'm on hollyday) I used to rely on 4 mechanical timers. A replacement was needed.
Timer for control of lights
For the control of the lighting around my home (and inside if I'm on hollyday) I used to rely on 4 mechanical timers. A replacement was needed.
The lights must be on from sunset until 23:00, something for which a mechanical timer alone is in fact not suitable. Settings of 4 timers must be changed regularly and if you forget it the lights are on too early or too late. And there were more problems: after a power failure of a few hours, my lights were on in the early morning and I had to set 4 separate timers on 4 separate positions. It has become time for a more comfortable solution.
Demands
The central unit will be based on Arduino (demand 4) using available libraries for rtc and wireless control.
To keep the unit simple no keyboard is build in; the unit is operated by an IR remote control of an obsolete video recorder (timer03). This make the realization of demand 5 a lot simpler.
Hardware
The circuit is build on a left-over PCB from another project, so no PCB design is available. The central unit is an Arduino Nano, but other types, like Arduino Uno, will also do the job. Pictures timer06 and timer07 show my setup.
For the transmitter a simple unit from Banggood is used (type number SKU075671). This is a set of receiver and transmitter. I used the receiver (timer08) to obtain the address of my hand transmitter, so I could use it together with the timer. Stricly this is not necessary, because the switches can be programmed to use more than one address.
The rtc is also From Banggood (type number SKUC98329). Normally this circuit uses a rechargeable lithium battery (LIR2032), but by removing the resistor in the charging circuit a standard CR2032 can be used, which should last a couple of years. And if you are modifying the pcb, also remove the resistor of the power indication LED. There is no use for this LED. See picture DS3231_hack.png
The display is a standard 2x16 character LCD-display.
A simple Hammond box is used as housing. The only holes needed are for the LCD and the power supply. A separate hole for the IR-receiver is not necessary; the plastic is transparent (enough) for IR. And be carefull if you use a knife (see the scratch on the title-picture ;-)
Software
The timer must switch on the lights if it becomes dark and switch them on at a fixed time (in the evening) or switch them on at a fixed time and off it becomes light (in the morning). Eventually one light stays on during the night.
To detect light and dark an LDR (light dependant resistor) can be used, but that would not be according to demand 2! Therefore the software must know about the time of sunrise and sunset. This is realised by an Arduino library.
The result is a simple box with has only one connection: the mini-USB power supply for the Arduino Nano. If you want to use (some or all) direct outputs of the Arduino to control your own circuit instead of the remote sockets, this is also possible: just define "HWout" and put the pins to be used in the array outarr[]. As an example I use channel A0 in the
program for this purpose.
The Fuzzilogic-433mhz library contains an example program for detection of the address of the hand transmitter: ShowReceivedCode.ino. As an alternative the zip-file contains a program which shows the address on the LCD: Light_code.ino.
Because in winter the dusk period is longer than in summer I tried to find some compensation for this. The lights inside are switched on earlier than the outside lighting. In summer there is no difference. In the program the factor myFact is included, which defines the duration of dusk during the winter. This will depend on your position on earth, which also has to be defined in the program to be able to calculate sunrise and sunset. Google maps can help you to find your coordinates. If you don't have problems connecting something external, an LDR might be the better solution.
In the Netherlands we still have summertime from the end of march until the end of october. By a simple routine, using a table for the date of start and end summertime (daylight saving) is determined. I know, there are libraries which can determine the time for any timezone on earth, but I like this simple approach. If you don't live in western Europe, you have to fill the tables Dayarr1[] and Dayarr2[] for your own situation. The tables covers 2020 to 2025. Because the situation may change after 2023, a longer table would be useless for me.
Items to be filled in the program for your own situation:
For the control of the lighting around my home (and inside if I'm on hollyday) I used to rely on 4 mechanical timers. A replacement was needed.
The lights must be on from sunset until 23:00, something for which a mechanical timer alone is in fact not suitable. Settings of 4 timers must be changed regularly and if you forget it the lights are on too early or too late. And there were more problems: after a power failure of a few hours, my lights were on in the early morning and I had to set 4 separate timers on 4 separate positions. It has become time for a more comfortable solution.
Demands
- no do-it-yourself for mains circuits (as with the mechanical timers)
- no additional wiring from a central unit to swiches/relais (but there are 4 different lights)
- real-time clock must keep running in case of power failure
- simple and available platform for hard- and software, but a little bit d.i.y. is ok
- nice appearance (must be acceptable for my wife!)
The central unit will be based on Arduino (demand 4) using available libraries for rtc and wireless control.
To keep the unit simple no keyboard is build in; the unit is operated by an IR remote control of an obsolete video recorder (timer03). This make the realization of demand 5 a lot simpler.
Hardware
The circuit is build on a left-over PCB from another project, so no PCB design is available. The central unit is an Arduino Nano, but other types, like Arduino Uno, will also do the job. Pictures timer06 and timer07 show my setup.
For the transmitter a simple unit from Banggood is used (type number SKU075671). This is a set of receiver and transmitter. I used the receiver (timer08) to obtain the address of my hand transmitter, so I could use it together with the timer. Stricly this is not necessary, because the switches can be programmed to use more than one address.
The rtc is also From Banggood (type number SKUC98329). Normally this circuit uses a rechargeable lithium battery (LIR2032), but by removing the resistor in the charging circuit a standard CR2032 can be used, which should last a couple of years. And if you are modifying the pcb, also remove the resistor of the power indication LED. There is no use for this LED. See picture DS3231_hack.png
The display is a standard 2x16 character LCD-display.
A simple Hammond box is used as housing. The only holes needed are for the LCD and the power supply. A separate hole for the IR-receiver is not necessary; the plastic is transparent (enough) for IR. And be carefull if you use a knife (see the scratch on the title-picture ;-)
Software
The timer must switch on the lights if it becomes dark and switch them on at a fixed time (in the evening) or switch them on at a fixed time and off it becomes light (in the morning). Eventually one light stays on during the night.
To detect light and dark an LDR (light dependant resistor) can be used, but that would not be according to demand 2! Therefore the software must know about the time of sunrise and sunset. This is realised by an Arduino library.
The result is a simple box with has only one connection: the mini-USB power supply for the Arduino Nano. If you want to use (some or all) direct outputs of the Arduino to control your own circuit instead of the remote sockets, this is also possible: just define "HWout" and put the pins to be used in the array outarr[]. As an example I use channel A0 in the
program for this purpose.
The Fuzzilogic-433mhz library contains an example program for detection of the address of the hand transmitter: ShowReceivedCode.ino. As an alternative the zip-file contains a program which shows the address on the LCD: Light_code.ino.
Because in winter the dusk period is longer than in summer I tried to find some compensation for this. The lights inside are switched on earlier than the outside lighting. In summer there is no difference. In the program the factor myFact is included, which defines the duration of dusk during the winter. This will depend on your position on earth, which also has to be defined in the program to be able to calculate sunrise and sunset. Google maps can help you to find your coordinates. If you don't have problems connecting something external, an LDR might be the better solution.
In the Netherlands we still have summertime from the end of march until the end of october. By a simple routine, using a table for the date of start and end summertime (daylight saving) is determined. I know, there are libraries which can determine the time for any timezone on earth, but I like this simple approach. If you don't live in western Europe, you have to fill the tables Dayarr1[] and Dayarr2[] for your own situation. The tables covers 2020 to 2025. Because the situation may change after 2023, a longer table would be useless for me.
Items to be filled in the program for your own situation:
- KakuAddr: address of kaku units (not in EEPROM yet)
- MaxChan:Ā number of devices (one RF channel can eventually control more sockets)
- HWout:Ā Ā Ā do you want some channels to be digital outputs of Arduino?
- myNB:Ā Ā Ā Ā Latitude
- myEL:Ā Ā Ā Ā Longitude
- myGMT:Ā Ā Ā Hrs to GMT
- myFact:Ā Ā Dusk duration in winter 25 minutes (tried for my location, depends on myNB
- Dayarr1:Ā startdate of summertime in Europe (march from 2020..2025)
- Dayarr2:Ā enddate of summertime in Europe (october from 2020..2025)
- outarr:Ā Ā if HWout is set, you have to define the hardware outputs
Updates van de auteur