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?
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.
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.
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.
weedpharma:
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.
Weedpharma
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.
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.
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
@Paul:
How does a capacitor drop the voltage? Did you mean a resistor? Not questioning your knowledge, just trying to expand my own.
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.
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.