Open Energy Monitor promotes a simple way of measuring AC voltage using an AC adapter (9V transformer). Here is an example on a breadboard with an Arduino:
If you use their schematic and the microcontroller is NOT powered but the AC adapter IS, the microcontroller would surely end up with an AC current being fed into the Analog input. Schematic shown here:
I don't see this hurting the arduino even if you hooked it up unpowered.. Powered the A0 pin would see about 2.499 volts unpowered it's about 89mV. so it should not hurt the chip
This is powered View attachment 69166
And even with the uno unpowwered the 89mV would all be on the ground based on the simulations.
This is unpowered View attachment 69167
The voltage divider Open Energy Monitor are recommending uses 10k ohm and 100k ohm resisters; from what I see you've drawn 1k ohm and 100k ohm. They quote an output voltage swing of plus/minus 1.15V:
"If the arduino is running at 5V the resultant waveform of the circuit has a positive peak of 2.5V + 1.15V = 3.7V and negative peak of 1.3V satisfying the arduino analog input voltage requirements and leaving plenty of room so that there is no risk of over or under voltage."
The second voltage divider lifts the sine wave and centres it at 2.5V, which is fine if the arduino is powered. My concern is that if somebody unplugs the arduino and leaves the AC adapter plugged in, all of a sudden the analog input is surely swinging at AC 60Hz between -1.15V and +1.15V. Is that an issue? Can arduino or PIC microcontrollers handle some AC into an unpowered chip? Or is there something I'm not understanding?
The two diodes on the port pins will feed the power to the ground and VDD but it's so low that's there no way it could run the chip. And from what i see the most that that could happen is there would be .5 volts feeding the rail at 108 micro-amps which is well inside of spec.
No worries, I'll roll with it and see how it goes. Thanks for your help Burt. It will be interesting to see what supply voltage I'm getting and how it varies over time...