Go Down

Topic: Detecting 240vAC - best way? (Read 1 time) previous topic - next topic


Hi All, I want a Nano to detect when there is 240vac on a wire and then send a wifi message to a Uno that will log it with the Oon/off time.


What can I use as a low cost sensor? I saw a clip-on thing on Amazon but it is 20-bucks, so what do I need to make the Nano send a notification to the Uno when it turns on and then again when it turns off?

I am using nRF24L01 as I already have two of them and a Nano+Uno and this video gives me all I need for the data. https://www.youtube.com/watch?v=wlhuO82IZjQ


The simplest solution is a 5V power supply.   You do need isolation.    The isolation can come from a transformer (like in a power supply), optical isolation, or you can us a relay with a 240VAC coil.

I saw a clip-on thing on Amazon but it is 20-bucks,
If there's no electrical connection, that's probably a current sensor rather than a voltage sensor.     ...In case you don't know the difference, voltage always exists at a (unswitched) power outlet.   Current flows when you plug something in that consumes power.


A mobile phone charger is ways available. They are nominally 5v but can be more. If more, it will damage your Arduino. Use an optoisolator to be safe.



Oct 25, 2015, 02:47 am Last Edit: Oct 25, 2015, 02:54 am by jcallen
You could use something like this and solder on wires and shrink wrap if you don't want to plug into a receptacle, but I would still definitely use an opto-isolater before connecting to your Nano.



In Australia we have had deaths from eBay specials like this. (Not this one specifically).

I would not be using el cheapo supply in my projects.

Mobile phone chargers (original equipment) are at least approved. They are also easy to get hold of.



An interesting alternative.

Use a mains rated capacitor in series to drop the voltage and a Zener diode across the NRF24L01 with its data pin held high.

That would be the entire transmitter.

Transmits RF during one half of each mains cycle.

Enclose the whole assembly in a heavy duty utility box so that it is totally isolated.

Also prevents using anything else on the same frequency (but that will be true of most such approaches).


Oct 25, 2015, 11:36 am Last Edit: Oct 25, 2015, 11:37 am by jcallen
I was not suggesting the op use this particular cheapy charger, it was the first picture that Googled up. I use one similar for my E-cigarette charger that was bought from an electronics store and UL approved, cost about $8.00 US. Also used one to tell my Arduino when my water pump was running. Soldered wires to prongs and connected to pressure switch, used old USB cable to connect 5 volt output to optocoupler on circuit board then to input pin to tell Arduino to turn off space heater so circuit breaker wouldn't trip when pump was running. Works great.


Oct 25, 2015, 12:31 pm Last Edit: Oct 25, 2015, 12:34 pm by Krupski
A mobile phone charger is ways available. They are nominally 5v but can be more. If more, it will damage your Arduino. Use an optoisolator to be safe.

If I were doing it, I would try to find a small TRANSFORMER power supply (wall wart) of around 9 volts, then run it through a 7805.

I don't trust switchers (to be safely isolated OR to output the proper voltage without spikes and noise). Especially that dangerous GARBAGE made in China and sold online for $3.00

Driving an Arduino input takes virtually no current, so the smallest transformer power supply is WAY big enough, I trust a transformer for isolation and the 7805 will keep my sense signal nice, clean and 5 volts.

If timing is important (that is, if the power goes on or off I need to know within a fraction of a second) I would add a bleeder dummy load to the power supply. Otherwise the low current draw and filter caps will keep the power appearing to be on well after it goes off.
Gentlemen may prefer Blondes, but Real Men prefer Redheads!


It's not a "production" method, but I collect Nokia switchers at Garage Sales.

The real old 3.7V charger - the heavy (transformer) "rounded cube"

is a bit of a gem!  It has a bridge rectifier but no capacitor - which is good, as transformer supplies in particular get hot (even unloaded) and the capacitor dries out and fails.  It can't in this one; you supply the capacitor in your device or if you just want status, well, no capacitor.

I used it to power a wireless doorbell which was powered by three "C" cells.  Battery powered doorbells are pretty useless.


That would be the entire transmitter.
Thanks, I will give that a try. The others who suggested a wall-wart have an interesting idea. I currently have a cheap analog electric clock but I have to go into the ceiling to check it and reset it.

Paul: I like this option as it saves a complete Nano for another project.

After posting I wondered about a wire wrapped around a few times on one of the AC wires. That would give me an isolated voltage for the A1 pin of the Nano.

But at the small risk of zapping a nRF24 by not knowing what I am doing :) I will give your idea a try first, as I can scrounge the parts from an old computer power supply.

There is zero risk to anyone as it is all in the ceiling crawl space. If some breaking in miscreant gets zapped up there they deserve it. LOL

How does a capacitor drop the voltage? Did you mean a resistor? Not questioning your knowledge, just trying to expand my own.

Which way and what voltage for the Zener?


The capacitor drops the voltage because it is kind of like a weak spring being pushed and pulled violently on one end. The other end only moves a little.

I would not recommend this approach because it is not isolated and there are too many ways to get it wrong and injure yourself or other people. The $1 bin at your local charity store will have lots of wall warts that are safer.
"The problem is in the code you didn't post."


While the capacitor supply is a good idea for an experienced electronics person, I would not suggest it be used by a beginner as it is dangerous for them to design and build without the right knowledge.


Go Up