Pages: [1] 2   Go Down
Author Topic: sensing mains power  (Read 1514 times)
0 Members and 1 Guest are viewing this topic.
Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Chris

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

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A capacitor over led/optocoupler is no problem.
Except for the voltage rating it has to be.
Logged

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.. ;-)
Logged

Chris

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

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* mains_switch - Schematic.pdf (10.56 KB - downloaded 32 times.)
Logged

Chris

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

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, and these caps should be ok?
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=160816947443&fromMakeTrack=true&ssPageName=VIP:watchlink:top:en
Logged

Chris

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SW Scotland
Offline Offline
Edison Member
*
Karma: 13
Posts: 1326
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Chris

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

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Chris

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

Berkshire, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 120
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Chris

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

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2812
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

--> 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

Pages: [1] 2   Go Up
Jump to: