Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« on: July 18, 2012, 06:40:30 am » |
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.htmMy 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
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 275
Posts: 25482
Solder is electric glue
|
 |
« Reply #1 on: July 18, 2012, 07:20:14 am » |
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
Edison Member
Karma: 9
Posts: 1001
|
 |
« Reply #2 on: July 18, 2012, 08:20:17 am » |
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)
Offline
Brattain Member
Karma: 275
Posts: 25482
Solder is electric glue
|
 |
« Reply #3 on: July 18, 2012, 09:32:44 am » |
A capacitor over led/optocoupler is no problem. Except for the voltage rating it has to be.
|
|
|
|
|
Logged
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #4 on: July 18, 2012, 09:33:04 am » |
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
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #5 on: July 18, 2012, 10:54:12 am » |
I quickly made a schematic diagram of what I had in mind. Does this look OK?
|
|
|
|
|
Logged
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #6 on: July 18, 2012, 10:56:04 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 10
|
 |
« Reply #7 on: July 18, 2012, 01:38:05 pm » |
you can use an AC 230V (or 110V) microrelay to send a DC signal to your arduino. Simple!
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 275
Posts: 25482
Solder is electric glue
|
 |
« Reply #8 on: July 18, 2012, 02:32:24 pm » |
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
Edison Member
Karma: 6
Posts: 1053
Arduino rocks
|
 |
« Reply #9 on: July 18, 2012, 04:45:31 pm » |
Capacitor should have class X dielectric implying ti is suitable for use as a mains "dropper"
|
|
|
|
|
Logged
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #10 on: July 19, 2012, 08:15:12 am » |
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
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #11 on: July 19, 2012, 08:16:17 am » |
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
|
|
|
|
|
Berkshire, UK
Offline
Full Member
Karma: 0
Posts: 110
Arduino rocks
|
 |
« Reply #12 on: July 19, 2012, 08:20:26 am » |
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
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 275
Posts: 25482
Solder is electric glue
|
 |
« Reply #13 on: July 19, 2012, 07:47:40 pm » |
No 10V is fine because the Zener and the LED means it dosn't get more than 10V across it.
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2307
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #14 on: July 19, 2012, 10:44:21 pm » |
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
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
|