I am using Emonlib to measure AC voltage using atmega32.
First of all I tried my circuit on Arduino uno board as follows:
1- Preparing a pcb including: - transformer(220/15)
voltage divider for 15vac(2 resistors:100k&10k)
voltage divider for 5vdc to maintain 205 dc offset(2 resistors:470k both)
2- this pcb has 220 vac input in addition to 5vdc and ground from the uno board, and the output to be measured is connected to an analog input in the arduino uno.
3- an lcd 16*2 is connected to the board.
when loading the emonlib example (measure voltage and current) to measure voltage, and after calibration, all goes fine, the results are very accurate and stable (Shone on LCD display), the results are very close to 220v.
BUT when loading the same sketch to atmega32 (offcource after modifying the arduino ide to deal with it), and when connecting the hardware, the results where very unstable and not accrate, they fluctuate near 100 v.
I thought it was a resolution problem but the result of a normal adc was 1024 for a 5 vdc supply.
I am sure it is not a power supply problem since i am powering the atmega from the uno board, and i am using necessary capacitors.