Go Down

Topic: sensing mains power (Read 2 times) previous topic - next topic

yesyes

Hi,
I'm looking for the easiest (i.e. smallest) way of sensing whether mains power is on or off with an Arduino input pin.

My first thought was to use a circuit that drives a LED from 240V mains power and substitute the LED with an opto-coupler (a 4N25 for example).
There are some circuit diagrams on this page: http://www.marcspages.co.uk/tech/6103.htm

My worry with that is that the LED would "blink" at the mains 50Hz. This is not a problem with a visual-only LED indicator but will give false readings when read at intervals with the Arduino. I could add another capacitor parallel to the LED as shown in the diagram for the blinking LED on the website above. But I was wondering if there are any simpler and smaller ways of doing this?

The idea is to replace a ceiling lamp with an Arduino controlled LED lamp and to use the existing cabling and wall switch. There is a 3 core cable going to the ceiling lamp, so I could have permanent mains plus switched mains from the wall switch.
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

Grumpy_Mike

Add the capacitor not across the LED but across the arduino input pin. In other words on the transistor side of the opto isolator.

Krodal

How will your Arduino be powered, can you use that somehow ?

The 470nF capacitor seems large to me. If the optocoupler is good with 10mA, use 150nF.
A capacitor over led/optocoupler is no problem. But it is saver on the low-voltage side.
However without the extra capacitor, the led/optocoupler is at 100/120Hz, and that is not hard to detect with the Arduino. Say with about 500Hz sampling rate in a timer interrupt.

Grumpy_Mike

Quote
A capacitor over led/optocoupler is no problem.

Except for the voltage rating it has to be.

yesyes

The arduino will be powered from the permanent mains (it has to be always on) via a small 5V PSU (one of those USB chargers). The arduino will control the lamp / LED and will be hidden in the ceiling rose or similar. It will be sent commands via a RF module. The idea is that the light switch on the wall can also be used to switch the lamp on and off so that "she" does not notice the difference but I can still control the lamp remotely.. ;-)
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

yesyes

I quickly made a schematic diagram of what I had in mind. Does this look OK?
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

yesyes

Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

im_nikolaos

you can use an AC 230V (or 110V) microrelay to send a DC signal to your arduino. Simple!

Grumpy_Mike

Quote
Does this look OK?

Looks fine, appart from the fact I would also have a resistor in line with the LED. The only thing limiting the current is te 470R and the 0.15uF cap, I am not sure if that will pass too much current.

jackrae

Capacitor should have class X dielectric implying ti is suitable for use as a mains "dropper"

yesyes


Quote
Does this look OK?

Looks fine, appart from the fact I would also have a resistor in line with the LED. The only thing limiting the current is te 470R and the 0.15uF cap, I am not sure if that will pass too much current.


How would you calculate the value for that resistor?
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

yesyes


you can use an AC 230V (or 110V) microrelay to send a DC signal to your arduino. Simple!


Not a bad idea. But I can't find one that is smaller than the LED circuit....
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

yesyes


Quote
A capacitor over led/optocoupler is no problem.

Except for the voltage rating it has to be.


The "flashing LED" circuit on the web page I linked to uses a 47uF 10V capacitor. Do you think the capacitor should be rated as high as the "mains dropper" capacitor?
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

Grumpy_Mike

No 10V is fine because the Zener and the LED means it dosn't get more than 10V across it.

Docedison

There are 2 better Idea's I can come up with one (the simplest is a relay connected to the mains, 230V relays are common and cheap, the second and better one is an LDR and a neon light. About 10 years ago I designed a radio remote controller for a center pivot irrigation controller and I Tried several times to use Led's for 220 Vac sensing. After literally blowing SEVERAL OF THEM off of The board I tried to use wall warts to save the board design, I bit the bullet and shrink tubed a NE2 to an LDR snd Never had a problem again and the LDR NE2 combination was about $0.10 cheaper after the part price had been burdened by the assembly time my girls spent putting them together. If adequately being shielded from light totally I could measure a low on a pin 2 or 3 times in succession, I knew that the power was on at the point being monitored, didn't need filters, caps or special software just a completely light shielded LDR and 2 or 3 low measurements were more than enough... that and a .1 uF cap for the occasional transient. I didn't write the code for that job but it was written to my specifications and the "engineer" doing the code had no problems measuring the pin. Just a thought...

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Go Up