[How-To] AC power on/off sensor

smee

Senior Member
This writeup discusses a sensor that can be used as part of another device to monitor the status of an AC power outlet. It uses a photocell to detect light and return a variable resistance. If this is plugged into an outlet, it can be used to monitor power outages (if the rest of the system is on a UPS) or the status of a wall switch. Plugged into the auxiliary outlet of a receiver, it can monitor the on/off status of the receiver. When there is no power applied to the device, the resistance will be quite high. When power is applied, it will be much lower.

=============================
WARNING: This thread discusses modifying a light which is designed to be plugged in to a normal household outlet. No electrical modifications are made to the light and the AC voltage is never exposed. However, it does involve adding an extra layer of material to the light which may increase its temperature during operation. I have tested this and not found any significant increase in temperature, but you should exercise appropriate caution.
=============================

In this thread on monitoring appliances, the discussion turned to monitoring an applicance with an indicator light (a washer in that particular case). The monitoring was done using an Ocelot, but the strategy could be used with other input devices.

The main component required to monitor the light is a CdS (Cadmium Sulfide) photocell [1]. These are devices which have an electrical resistance which changes depending on the amount of light striking the photocell. Typically, the resistance in the dark is very high (can be several Mohms). In light, the resistance can be as low as 1 Kohm or less.

The photocells can be used as part of a voltage divider (in combination with another resistor) or may be usable directly across the terminals of some input device. For many devices, a high resistance is enough to act like an open switch. The photocells are very inexpensive, so they are easy to play with to see what works.

After that discussion, I decided to write up a project I've been thinking about for a while.

The device described here can be used as part of an input to a digital or analog I/O adapter connected to a computer or to something like an Ocelot.

This component is built by mounting a photocell to an inexpensive night light. The particular night light is more of a marker light - it glows but does not light up the room. They are labeled as 1/3 Watt, but might actually consume less power.

The picture shows a finished module along with an alternate (incomplete) version. The light is enclosed in the plastic can from a roll of 35mm film. The can prevents ambient light from affecting the resistance of the photocell. In reality, there is still some effect because light enters through the part of the night light which is still exposed. In testing, this effect was not enough to affect the results.

The can is an old Kodak can (back when they were black). Most film now comes in translucent white cans which will need to be painted to prevent light from going through the plastic.

If you don't have an old film can around, just go to a one-hour photo place and ask them for one. They should have plenty (unless everyone in the area has gone digital).

One module uses the top of the can - the cap can be removed to look at the interior. The other uses the bottom of the can. The bottom is a much tighter fit and is harder to work with.

I have had one of these night lights plugged in for several months (just as a light) to see if they get warm. They do not seem to get more than slightly warm to the touch. I have not tested them extensively with the film can over the light. It is possible that they will get warmer. I do not expect this to be a problem. But, please consider the possibility and treat them with appropriate care.

[1] There are other devices, such as phototransistors, which can also be used.
 

Attachments

  • light_detectors.jpg
    light_detectors.jpg
    60.8 KB · Views: 169
Here are the parts required:
1) night light
2) photocell [Radio Shack]
3) empty film canister
4) wire
5) heat shrink tubing (not shown in picture)

The assembly process is very simple:
1) Cut the canister to an appropriate length. This should be about 1/4 inch longer than the night light (measuring the narrower part of the light).
2) Drill a small hole in the side of the can to allow the wires to pass through.
3) Slide a short length of heat shrink tubing over each wire (this is not absolutely required, but it ensures that the wires will not be shorted).
4) Solder the wires to the photocell. This should be done close to the photocell (I cut the photocell leads to about 3/8 inch length before soldering).
5) Slide the heat shrink tubing over the solder joints and shrink.
6) Bend the wires flat behind the photocell.
7) If you are using the end of the can with the lid, follow step 7a. If you are using the bottom of the can, follow 7b.
7a) Slide the can over the lamp. If it's loose, use some glue (hot glue will work) to attach them to each other. Thread the wires through the hole in the can and place the photocell face down on the light. Use hot glue to hold it in place (see picture of completed interior). Stick the lid on the can.
7b) Place the photocell face down on the light and use hot glue to hold it in place (see picture of completed interior). Thread the wire through the hole in the can and slide the can over the light. If it's lose, you may need to use some glue to hold them together.

That's all there is to the manufacturing process. You now have a sensor with a resistance that varies depending on whether the light is lit or not.
 

Attachments

  • light_parts.jpg
    light_parts.jpg
    52.5 KB · Views: 133
The completed module with the lid removed:
 

Attachments

  • light_inside.jpg
    light_inside.jpg
    54.2 KB · Views: 135
And a closer view. The photocell is under there somewhere. :D
 

Attachments

  • light_closeup.jpg
    light_closeup.jpg
    62.4 KB · Views: 113
smee:

This is an excellent idea. I'm also going to use a power monitor, but I'm taking a little different approach and will use a 120 VAC relay and have my SECU16I monitor its contacts. One nice thing about your idea, you don't have to fuse anything where I would feel a little more comfortable fusing the relay's coil (since the only other power trip would be a 20 amp breaker ;) ).

Thanks for posting this idea. It gave me something to think about even though I'm not using the exact same technique! :)

Here is something for you code gurus. My Ocelot and SECU16I are backed up by an Elk 12 volt battery plus a small UPS. My cable modem, firewall/router, and hub are also backed up by this UPS. My Homeseer machine is backed up by a different UPS.

If I monitor say my power monitor relay with the SECU16I/Ocelot I can immediately send a text message to my pagers/cell phone as well as an Email message to let me and my wife know there was a power failure at home. It would be nice to also send a message when power came back on so you would know say if the food in the fridge/freezer might be at risk when you got home.

Of course this is easy as long as the UPS battery's last, but what would you do if the power failure was beyond the batteries/UPS backup capabilities? I was thinking about setting some sort of device in Homeseer or the Ocelot (variable) when the power monitor relay tripped and have that value checked whenever Homeseer starts up. Since my PC's (and Homeseer) will autostart/resume on power failure/resumption, I could have Homeseer send a text message to my cell/pager and Email if it starts up and this value was set? I guess if power did happen to come back on, or after the code executed on startup it would reset this variable/device?

Thoughts, or better yet, code snippets?? ;)

This may seem like overkill, but we live in a new development/area and power failures occur every now and then when someone is adding another housing development leg, or doing other modifications to the system. (We have had a couple of these just this last summer when it was over 105 degrees).

Regards and thanks again,

BSR
 
Smee,
Not being electronically inclined AT ALL I have a couple of questions. You stated that the device outputs variable resistance. Could this be used with a powerflash module for example.
 
I assume most of you have your HA servers on a UPS? Aren't you monitoring the state of the UPS to represent the state of the line voltage? Or for that matter the alarm panel?

Ok, if the desire is to monitor one circuit for juice or not, what if a 110 volt relay coil was wired to be energized when there is power. Then, when power is missing the relay is open. The normally open contact points could be the sense wires of a powerflash to send an X10 when power is missing to the monitored circuit. Of course the powerflash would also have to be plugged into a non switches circuit that is accesible to the PC's X10 interface device.
 
That's a good point David, but I don't bother loading the UPS software and having to connect another serial port to my system.

I realize that monitoring just one outlet may not give you a total representation of the home power, but I was more concerned with "total loss" which happens here every now and then.
 
BSR... in answer to your question: I use a small 12vdc wall wart and a 12vdc relay to monitor my power. As I had both laying around. I find this works well as small blips in the power are not logged, it takes a full 1-2 seconds before tripping the relay. On the HS side I set a virtual device off with the power and back on when the power returns, via events, device status change. Then in my startup.txt file I check to see if this device is off, this means that the power was off and my UPS ran out of juice, then I send out a text page saying things are all O.K. You could do this with either a power flash or an Ocelot, I suggest the Ocelot.
 
Rupp:

I don't know if the resistance when the light is on is low enough to trigger a powerflash module. I don't have one to test. My guess is that it is not.

To people who would use relays:

The relay approach should work fine, of course. I know I've suggested it in the past either here on or the HomeSeer board (I think in the context of monitoring receiver power). The only real drawback is that it will probably draw more power - especially if you use a wall wart to power the relay (since they aren't usually very efficient). The light approach has a higher level of isolation (and is probably smaller) but other than that, there's no real reason not to use the relay. Didn't you always want to build your own "optoisolator?"

UPS monitoring:

When I got my first UPS, I hooked it up to the computer for monitoring. There were so many false triggers that I got tired of it and disconnected it.

The main reason for this thread was to indicate another approach. I thought it fit well in the context of the thread linked in the first post.
 
I definitely like this method and will give it a shot once my current projects are finished.
 
Back
Top