Friday 19 September 2008

Wake Up Light - Alarm Clock Triggered Light Bulb

I was thinking to myself the other day how much easier I find getting up in the mornings when it's light outside. I continued to contemplate how similar the light level from a low-power light bulb was. My mental conclusion was: 'meh, fairly'. Now, how do I make a light bulb turn on when I want to wake up? Here's where my previous post, Triac Mains Switching, comes into play. Here is the schematic again:


When I want myself to wake up, I make my alarm clock turn it's radio on. So, after taking my alarm clock apart and probing numerous soldered contacts, which looked like they could provide low-voltage DC power to the radio circuit, I found one (relative to ground) which was at approximately 6V when the radio was on, and 0.5V when it was off. This was great news, 6V is just slightly larger than the logic 'high' for the Arduino Decimilla. With a simple voltage divider, and the equation Vout = (Vin * Rb) / (Ra + Rb),it would be trivial to bring that voltage down to a suitable logic-triggering level; I probably don't even need to.



I have used fairly high-valued resistors to ensure very little current is drawn from the clock's circuitry; that way there's little chance of damaging the clock.

Now I have a low-current, 5V(ish) supply, capable of triggering an Arduino digital pin. I also have a circuit which allows the Arduino to turn 240V mains devices on and off.

Can you see where this is going?

With the two circuits joined together, it is possible to turn the light bulb on when the radio turns on. Mission Completed!

Simple set-up (without voltage divider)

Arduino Code Listing:

byte bulbPin = 12;
byte radioPin = 8;

void setup(){
pinMode(bulbPin, OUTPUT);
pinMode(radioPin, INPUT);
}
void loop(){
if (digitalRead(radioPin)){
digitalWrite(bulbPin, HIGH);
for (int i=0; i<5; i++){
delay(60000);
}
digitalWrite(bulbPin, LOW);
}
}

This code will leave the light on for 5 minutes after the alarm has been turned off. If the delay wasn't required, neither would be the Arduino.

A video of it in action:



Admittedly, this light bulb is quite bright; I'm going to get a 20W pearl bulb soon.

Possible additions:

- Serial communication for triggering, eg:
- e-mail received
- Web based (switch on a website) (with serial-to-Ethernet module possibly)

- Light level (LDR triggering)

- Triggered by a break in laser beam across the entrance to the room, hmm...

Words of warning: Mains electricity is very dangerous; do not do anything like this if you're not sure what your doing. I did a fair amount of research before building my circuit. The components in this circuit can become damaged from transient voltage spikes so I'd advise against using inductive loads with this circuit - the triacs may fuse open (or worse!). Stick with resistive loads!

Have fun,

Comments/Suggestions greatly appreciated...

Chris

Triac Mains Switching

Mains switching is something I've always wandered about; relays always seemed like the way to do things, but what if you don't have a device that can supply enough current to throw the switch, or what if space is quite a limiting factor?

I looked into triacs to solve my problem, and, with my new found knowledge, I set about creating the circuit detailed below:
The MOC3020M is a triac optoisolator - basically, it's a light-sensitive triac with a small light source in one component. Pins 1 and 2 are used to turn the light source on and off, which in turn allows the internal traic (pins 4 and 6) to conduct. This internal triac is used to trigger another traic; one which is capable of dealing with larger currents. Mine, the 2N6073A, could handle 4A if heat-sunk properly. But, I've kept it well away from that with a 2.2A circuit breaker.

There's a fair amount of information on the Internet about how traics work, so I won't put any here; take a look if you're interested. Basically, the triac will conduct (through the main terminals) as long as there is a voltage/current on the 'gate'. It stops conducting, after the gate voltage/current has been removed, as soon as the voltage/current over the main terminals crosses zero.

I decided to put my circuit in a small plastic box to keep it safe and out of the way. I also attached a trailing socket so I could use it for more than one project, easily. The earth wire isn't connected in my circuit (except to the trailing socket) since the box is plastic. For the control cable, I decided to use a length of telephone cable (which normally has RJ11 connectors on the end) using just 2 of the strands - leaving room for expansion.

The mains device can be triggered 'on' by applying 5V to pin 1 of the triac optoisolator. My intention was to have the circuit triggered by my Arduino, opening a world of possibilities.


The Main Circuit

The plug, triac circuit and trailing socket

One thing I have noticed with my circuit is that when certain devices at home are turned on, but the triacs are off, the connected device (to the trailing socket) gets a bit of power for a fraction of a second. The traic miss-fires for a tiny period of time due to the magnitude of dv/dt - the change in voltage per small unit of time. These values are discussed on the triac's datasheet. If this becomes an issue, I'll have to design a snubber circuit to dampen the effect and solder it in (hence the large space to the left of the board).

Words of warning: Mains electricity is very dangerous; do not do anything like this if you're not sure what your doing. I did a fair amount of research before building my circuit. The components in this circuit can become damaged from transient voltage spikes so I'd advise against using inductive loads with this circuit - the triacs may fuse open (or worse!). Stick with resistive loads!