Here i will present version 2 of bird timer switch. Mainly improvements are that is added a battery to control the circuit when mainly voltage is down , a circuit to charge the battery, a second lamp aw a night lamp. I add an electronic timer color frontage with leds.
Click on schematic above , i will try to explain as more detail as i can.It consist of three block diagrams. Charginf battery ,zero cross detection ,arduino.
First circuit on the top consist of TP4056 a lion battery charger. Datasheet says about 1 Amp.charging current but it is less.I made exactly the circuit on the last page of datasheet. Blue led is when battery fully charged and red is while charging. Lm7806 is used for power tp4056. When battery is full empty 7806 is really hot.This last for around 50-60 minutes, of course it need a good heatsink.
What is the operation take care,when mains power 230v is down, relay K2 is not triggered and it is as photo show. 22-23-2021 connector , is connected 18650 lithium battery.So, battery is connected to stepup converter 600mA..JP2 is always closed. Step up input is between 3.2-4.2. Ouput is exactly 5 v.In meantime ,Q2 bc558 base is connected to ground through K2. So, Q2 is in saturation mode and 5v from step up goes to arduino. C18 3300μF , is a big capacitor that handle power and give it in the situation change, from power off 230v and power on 230v.
When mains power 230v is on again ,base of Q2 is at high level and because it is pnp is not in saturation mode. Ralay K2 is the opposite side as photo show and is connected with tp 4056 so it is in charging mode.Step up converter is not connected anywhere
Second block diagram is with 555timer as a voltage control ac light dimmer. Adjusting the input of 555 timer at pin 5 with pwm from arduino, we can control the output at pin 3 connected with moc3021 to dim a ac lamp. If you like that idea you check all here. R9 potensiometer adjust the high level of voltage. For example 0-4.5v or 0-10 v . I have adjust it at 0-4.8 volt ,this is the arduino pwm.
And fnally the arduino . It is stored the program that count 0-25 minute ,output is digital_9 that is pwm for 555 timer. That control incandescent light bulb. Other output control relay and leds
There many photos below explaining many things
Double side pcb
One problem here cost me many hours! i could n’t see that broken copper without microscope.
You can see the step up converter. It used dor step up voltage from 3.7 from lithium battery to 5 volts so that power arduino and leds. That board has a drop out voltage around 0.12 volt. It is not critical ,as i test until 4.7 volts arduino is working normal.
That small smd chip with 8 pins is TP4056. It is ideal for charging lithium batteries until 1 Amper. You can adjust the charging current, just replacing a resistor so that charge your own battery. Down side of the chip ,is a good idea to be some copper,it is good to dispatch heating from the chip. I charge this battery at 650mA and chip is hot enough
This round pcd is for protection of lithium battery. Because this cheap battery has not internal protection i add this.It is adjusted for a maximum voltage charge at 4.2 volt and its especially point is that has o lower voltage cut at 2.7 volts as i measure.Without it, when battery is not charging reach at 0 volts!! Baneful situation for a battery.Costs 2 for 1 dollar.
And here is finished
You can find info also here for schematic and code