I just had a look at the 'guts' of your project box, please make sure that you maintain minimal spacing between the high voltage and low voltage parts of your circuit.
As it is it looks like they are much too close to each other.
Just having them electrically separated is not enough, you have to account for arcing in all kinds of conditions as well as temporary over voltage (spikes) on the current carrying wires.
[Disclaimer: I've put products successfully through UL]
The OP is correct, for a non-isolated product (one with user exposed metal bits and connectors) you're not paying enough attention to separation and protection. UL would probably require double insulated wires, wire guides, and moving your wire lug away from logic circuits, adding a fuse, along with all sorts of requirements on labeling, etc etc.
Also, are you calculating RMS current or average current? Without a voltage tap, you also can't determine power due to power factor.
Do you have any recommended documentation for doing these things properly? I'm pretty naive when it comes to this stuff, so any information about best practices would be appreciated.
I think the easiest way for you to significantly improve the circuit from a safety perspective is to modify the layout in such a way that the high voltage part of the circuit is on one end of it and the low voltage part on the other.
A (very safe) alternative to using the hall sensor the way it is wired up right now: consider wrapping the current carrying wire around a ferrite core and putting a number of turns around the other side of the core to pick up the current (a very basic transformer). That way there is absolutely no need to go 'near' to the low voltage part of the circuit with the high voltage portion of the wiring.
That's called a current sensing transformer.
You could also place the hall sensor if you really want to use that in the gap of a slotted toroid around which the primary wire is wound a number of turns.
Adding a fuse is a basic precaution, you should size it based on the wire thickness that you are using.
You are doing pretty good but beware of knowing 'just enough to be dangerous'.
Alternatively once you've finished prototyping the circuit you could hand off the process of packaging it in a way that complies with the various standards to an electrical engineering firm, from a liability perspective that might be a good idea anyway.
I don't think he cares about accuracy of the result; all he needs is a binary on off. So you measure the output of the circuit with the TV off, make a note, measure the output of the circuit with the TV on, make a note, and set the threshold (in software), somewhere in between. Then you know if the TV is off or not.
(I would personally have pasted a photocell onto the power LED, if I really needed to know the TV's state, but that's just me. My TV doesn't have a button for "power on", but it responds to a remote code for one.)
I don't disagree with your advice, but in this case I think it's not so bad. It's a current sensor, there's practically no voltage across those power wires. And assuming he wired it into the ground part of the circuit and not the phase, no voltage to the electronics either.
(However, low voltage doesn't mean that an accidentally dropped conductor wouldn't ruin your day, so insulating them would still be a good idea.)
If you look closely you can see a wire running from the mains straight to the sensor board next to the arduino, clearance is on the order of a few mm. All it takes is a little bit of condensation for a nasty accident, the voltage between those two conductors is 110V AC on one side and +5 V with some unknown level of insulation from mains on the other.
Making assumptions about which line carries phase and which is neutral can cause very nasty surprises and should never be a factor. You're one broken circuit away from being the shortest path to ground, even in the neutral line (you'll still have the load as a drop resistor but it's not good).
Interesting, but I wonder if passing the load through any physical device is necessary? I would think that a few loops of wire wrapped around the power cable would be good enough for detecting on/off.
Yes, but they aren't connecting it to line voltage. I imagine the intended application for this particular chip is to be part of a battery charge circuit, and so those pins are going to be at 1.2V instead of 120V as in your application.
(The datasheet doesn't mention this because the IC can theoretically sink infinite voltage. The input current is put into the chip only to go through a carefully-placed piece of copper that maximizes the effectiveness of the Hall effect sensor. The only limit that matters to the chip is heat production, which depends on the resistance of that piece of copper and the amount of current flowing through it. Voltage simply doesn't affect the chip in any way, so there's no reason to set any limits.)
The problem I see with your current design is that isolating the line voltage from the container is going to be difficult. Line voltage appears on 8 different places; the four connection areas (top and bottom), and the four input pins on the IC itself. Without potting it in epoxy, you're not going to be able to isolate all that from an errant chip of metal that happens to enter the enclosure. And that's all it would take to burn down your house; a little chip of metal gets between the pins but doesn't make very good contact. As current flows, it gets hotter and hotter until it sets the enclosure on fire. (Your circuit breaker will trip if this causes your device to draw more than 20 amps, as a clean short would, but 2400W is more than enough to start a fire.)
Ultimately, you have to keep in mind that you can pull a lot of power out of your house's outlets. This power can kill you or start a fire, so when you are wiring it up to something, you need to think about how your device could possibly fail and protect against it. What if the cover falls off? What if a piece of metal shorts the line voltage to your Arduino's USB port? What if a connection is faulty and gets hot?
This much paranoia is warranted when a minor mistake could kill someone. Is knowing that your TV is on worth dying in a fire for? :)
Now, the good news is that you can make a device that works just as well as this one without having to touch the wire going to the TV. The only reason you have the TV connected through the current-sensing chip is to get the current that the TV's drawing very close to the Hall effect sensor. This will let you make milliamp-level measurements very accurately. But you don't need that accuracy, so taping a Hall effect sensor to the TV's cord will be just as good, and will be intrinsically safe. (I think a few loops of wire will work too, but I just tried this and it didn't work. YMMV. I didn't have any magnet wire, so I used a long piece of wire stolen from a radio antenna.)
(This is assuming that my photoresistor-near-the-TV's-power-LED idea doesn't work, of course.)
Finally, the Arduino is likely overkill for this application. Something like an op-amp set up as a comparator and connected to a free serial port pin would work just as well, and cost you 1 cent instead of 20 bucks :)
Anyway, I'm looking forward to version two; this is a great project and your proof of concept is excellent. But you can make the device simpler, safer, and cheaper; so why not spend an afternoon doing that. The increase in sleep from not having nightmares about the thing catching on fire should definitely make up for the time invested in doing so :)
I really appreciate your input. This is extremely helpful.
I also picked up some epoxy this afternoon to do exactly what you said.
I realize the Arduino is overkill, but I'm complete newbie and it seemed like the quickest solution. Whenever my next revision is ready, can I send you an email?
Yes, please send me email. I find this project very interesting and you've done a great job documenting it. I'm going to order some Hall effect sensors and see what results I get with them. I'll let you know what I find out.
Also, be careful with the epoxy. You need to get some specific kind (that is non-conductive), and I'm not sure what that is. There are all sorts of effects materials have on electronics; the epoxy could add resistance, capacitance, inductance, and any of those could adversely affect your circuit. Hopefully you can get specific advice from someone more qualified than I am.
If you do ever create your own, you might want to try siphoning some power from the mains to power your Arduino and while you're at it attach a XBee or Wifi unit to the Arduino for remote monitoring.
The Tweet-A-Watt was one of the first things I came across. In my situation, wireless seemed overkill considering my power plug is always within 10 feet of the PC.
Yea, good point. I was thinking of the case where you wanted to monitor something like your refrigerator. I suppose my TV has a computer next to it at all times too. Great project!
This looks great. One very important application for such a device is for viewer analytics. A lot of companies, e.g. Nielsen, would like to automatically gather data on what you are watching. Now, its relatively easy (well, if you have access to the cable box) to know what channel you are tuned to but they don't know if you actually watching the TV or not. One necessary (but not sufficient) condition for watching is, of course, for the TV to be on, which can be detected by a gadget like this.
You could also use a photodetector placed over the TV's power light, and I bet you could even input that to a PC with very minimal hardware, over a serial port or microphone jack.
Cost would be very low, even if you have to buy USB<->Serial adapters. And you can run many feet of serial over CAT5.
Also, you may want to check xrandr, that strikes me as the correct way to ask the X server what is connected.
The best answer is "try it and see". You already managed to build a device that uses the Hall effect to measure the amount of current your TV is pulling, so hooking up a photoresistor to an ohm meter and taping it to your TV while you turn the lights on and off should not be too difficult :)
Also, electrical tape is black and blocks light pretty well, so slather enough of that on there and you should be good :) I guess you won't know whether or not your TV is on, in that case, but you can always add another LED that mimics the status of the TV's LED.
(Also, a hacked VGA cable may help xrandr report the TV power status. By default, VGA cables supply +5V to the DDC chip in the TV, so it can detect its presence even when off. Since you don't want this to happen, perhaps clipping that pin off will prevent the DDC information from being queried until the TV is turned on.)
xrandr gives useful information on some cards. You can also try "nvidia-settings -q all" on nVidia boards (or try setting DynamicTwinView to false, see the nVidia docs).
As for the ambient lighting, I don't think it will once you use black electrical tape to attach the detector. TVs also usually aren't installed where subject to really bright light (e.g., direct sunlight) because then you can't see the screen.
As it is it looks like they are much too close to each other.
Just having them electrically separated is not enough, you have to account for arcing in all kinds of conditions as well as temporary over voltage (spikes) on the current carrying wires.