How to determine current in line ?

Hi,

This may sound like a strange question but I would like to detect if there is a current going through a line and have the arduino process that information. My scenario is that I want the arduino to be able to tell what lines are drawing a current. I can't seem to find a cost-effective way to do this. Any thoughts ?

Mark

The lines of what exactly?

Well we need to know the voltage of the lines and the min and max current range that they might draw and of course how many lines we are talking about. Also a typical circuit drawing showing how a line is being used.

It could be as simple as installing a low value resistor in the line and tapping it to one of the Arduino analog input pins.
Spill the beans and see if we can help :wink:

Lefty

I'm rather new to all of this so bare with me.
I'm in the planning stages of some simple home automation. I was thinking of going with X10 but I realized that their light-switches do not offer any feedback to say whether the light is on or off so I am thinking that I want to use the arduino to control my lights. I am thinking of having them hooked up to a relay but I still need feedback to tell if the light is on or off. Any thoughts on how I can do this ? My original thought was to have something in the line to the light to measure if any current is being drawn from the light.

Thanks in advance for your help,
Mark

To be honest, I have used a ton of X10 stuff, and I can rewire household electrical systems, but I don't think I'd mess with engineering anything custom in that regard. Upwards of 20 Amps at high voltage is nothing to sneeze at. There's too much at stake if you end up smoking a poorly-specified transistor when you are in another room, asleep or away from home.

You have a very god point there.
I would use X10 but it's so limiting to what you can do with it.
Any other suggestions ?

There's too much at stake if you end up smoking a poorly-specified transistor when you are in another room, asleep or away from home.

What's to say that an X10 wouldn't blow up and burn your house down?

I agree, one should exercise common sense and caution in whatever you do...walking across the road, buttering some toast...because we all know that there can be undesirable outcomes. I'm not disagreeing with you Halley but I would like to point out that "knowing is half the battle" so it doesn't mean you shouldn't try, it just means you need to take the proper precautions to limit the likelihood of certain undesirable outcomes like your house catching on fire as you sleep. It's that kind of "defeatist" attitude that slows the advancement of technology and/or the human race in general.

Mark is likely to use better quality components than they use in the X10's and I'm sure with the advice of the Arduino community among other resources like his own grey matter, he has nothing to worry about.

I say, get stuck into it. Make sure you do your research and that your house insurance is current and valid :wink:

Hi Scootabug,

Thanks for the advice. I agree that even if every precaution is taken, shit still happens. It's just how the world works I guess.

I haven't even begun this project and I won't think about starting until I learn as much as I can first. Like I said, I'm new to this (just got my arduino in the mail). I'm a computer programmer by profession so I think logically. Like I said before, I think the X10 would be enough for my use case but with the exception that the light switches do not provide any feedback to tell whether they are on or off.

Are there any other suggestions as to where I can start doing my research ? I need to learn about relays and how to safely control them using my arduino. I also need to learn about how to detect whether my lights are on or off. The only way I can think to do this is to detect if there is current flowing to them. I will be controlling my arduino via RF so I also need to learn about that too. I don't plan to plunge into this without knowing as much as I can so any help is greatly appreciated.

Thanks and Happy New Year !

Mark

Well relays are not that difficult to use. Just need to connect Arduino to MOSFET, and MOSFET in turn switches on the relay. You cannot connect the relay directly to the Arduino

Google around for more information about relays and MOSFETs.
P.S. For a mosfet I'd suggest the IRF530 - its common and cheap

Well relays are not that difficult to use. Just need to connect Arduino to MOSFET, and MOSFET in turn switches on the relay. You cannot connect the relay directly to the Arduino

Google around for more information about relays and MOSFETs.
P.S. For a mosfet I'd suggest the IRF530 - its common and cheap

While one CAN use a MOSFET for this purpose I'm not sure I'd recommend that for a newbie. The reason being that MOSFETs break if you look at them funny after skuffing your feet on the carpet. A bipolar transistor is a lot less prone to failure from accidents. The only real downside of a NPN or PNP transistor is that it takes a little bit of current to keep it going. This should be no problem at all in a power switching circuit.

I suppose this isn't an issue if you've got some to spare and/or you have an anti-static wrist strap.

Can you tell me why I can't connect a relay directly to the Arduino ?
Like I said, I'm a newb.

Mark

Hi Again,

I did some reading and now understand why the transistor is needed to switch the relay.

My second problem that I want to address is that I don't know how to detect whether my light is on or off. What I plan to do is to wire up a 3-way light switch. One end will be to the relay which is connected to the arduino and the other will just be the regular mechanical switch. I need the arduino to tell if the light is on or off, any ideas ?

Mark

Yikes... That'll complicate things... Well, you'll have to wire your relay like a three way switch. That is, it'll sort of have a power wire on both sides (open and closed, one with the red wire, one with black). Then you'd need to actually directly sense whether current is flowing (if it is then obviously the light is on). You could use an inductor wrapped around the wires. If current is flowing in them it'll flow in the inductor as well. This isolates you from having to directly sample 120AC.

Hmmm, I'm not sure I understand how to wire up the relay as a 3-way switch. Also, how would I get the data back to the arduino from the inductor ?

Mark

Adding to what I said,

The inductor would need a LOT of turns in order to achieve any sort of voltage all by itself. It's likely that it's output would need to be amplified to be reliable. One way to test is this:

Take an old lamp and split apart the two wires of it's cord (at least for a little ways). Now wrap something like 100 - 200 turns of 28 gauge electromagnet wire around one of the wires (don't strip those lamp wires! I don't want to explain anything to your parents and/or widow) Strip off the insulation from both ends of your new inductor, turn the lamp on and use a multimeter to test how many volts you get from your inductor. It almost certainly won't be a whole bunch.

It goes without saying that you should be really, really careful when wrapping wire around 120AC lines.

How you get data back from the inductor to the arduino is to put one end of the inductor into the ground lead and one into an analog pin. But, like I said, you'll likely actually have to amplify the signal. Otherwise it might not even be strong enough to make it's reading larger than the normal 2-4 value fluctuation. If it's strong enough to register even 20 or 30 (which is something like a 1/10 of a volt) then you are set. You just check to see if the pin is reading 20 more than it usually does. If it is then you've got power running in the wires.

Oh, I forgot to answer about the relay (apparently I like posting a lot...)

You need a relay that has a set of connections which are connected when the relay is open and a set which is connected when the relay is closed. This isn't uncommon in industrial control relays.

Three way switches have a red and black wire that they use instead of just black. You hook the reds up to either open or closed connections on the relay and the blacks to the other.

That's an awesome idea (using the inductor).
Now this brings up the question of safety. How can I make my inductor more safe. I'm aware of the possible 'complications' if the inductor, for whatever reason, were to make contact with the live 110 wire... YIKES ! How can I make this more safe ?

Also about amplifying the signal, how can I go about doing that, using another transistor ?

And about the 3-way relay wiring, I still don't get it but bare with me. I'll sit on it for a day or two and I'll figure it out, ha ha.

Mark

That's an awesome idea (using the inductor).
Now this brings up the question of safety. How can I make my inductor more safe. I'm aware of the possible 'complications' if the inductor, for whatever reason, were to make contact with the live 110 wire... YIKES ! How can I make this more safe ?

Well, there isn't any real danger so long as you don't break the insulation around the wires you are testing. It's not a great idea to put the inductor really close to the end of the wire where it has to be bared. Put it at least a few inches away and there really isn't a whole lot of danger. Standard wiring is rated up to 600V. I don't remember the dielectric breakdown voltage but it would practically take a lightning strike to do that. So, in a lightning strike you are likely to see your arduino blow up. If you want to prevent that you'll need optoisolators and then you'll definitely need an amplifier.

Also about amplifying the signal, how can I go about doing that, using another transistor ?

I don't think that an inductor would properly turn a normal transistor on. It's likely to be too weak. You'll need an amplifier IC. You can get them really cheap.

Also, I forgot, an inductor will produce AC voltage. You'd have to run it through a diode before it would be safe to run it to a pin on the arduino. Of course, most diodes have a drop of at least .3v so if the inductor can't produce more than that you'll never see it.

And about the 3-way relay wiring, I still don't get it but bare with me. I'll sit on it for a day or two and I'll figure it out, ha ha.

Mark

http://www.misterfixit.com/3wayswch.htm

Go there. The picture is really about the clearest that the concept can be explained.

Great, thanks for all this info !
I understand the 3-way switch. I was trying to over complicate things for myself.

What I think I will have trouble with is getting this inductor to work properly. Like you said, the signal might be too weak. I have to do my reading on amplifying the signal and getting the arduino to read it.

Mark