Arduino reading AC voltage

Hi All,

I am currently working on a project at the minute to make an arduino read the ac voltage.

The setup I have is as follows:-
Mains input into a 0-6v isolation transformer and then a potential divider to half the voltage.

I am wanting to offset the analogue input channel to 2.5v so I can read both the positive and negative sides of the wave.

What is the maximum voltage input to the analogue input?
I know its 0-5v but is this peak to peak 0-5 or rms ?

Thanks

it is 0-5V DC

What is the maximum voltage input to the analogue input?
I know its 0-5v

The maximum voltage on any pin except /RESET is Vcc+0.5V

so can I not read ac voltage into the analogue pins?

To read AC you would need to either bias it so that the peak voltages stayed inside the 0..5V range, or rectify it.

You need to put a full wave rectifier on it and a large value capacitor. Make sure it's not over 5 Volts DC. Then you can take readings. Calibrate with a VOM on the AC at the same time you take the readings.

You can read AC because Ive managed to read. Lets say your transformer outputs a sin wave between -6/+6 Arduino cannot read negative values. But you can use Opamp to adjust the offset of the wave to 2.5 V. And you can adjust the gain in order to make the signal move between 0 and 5 volts. Then you can program a rutine which samples the wave and calculates RMS.

I know its 0-5v but is this peak to peak 0-5 or rms ?

Peak. A 5VAC RMS voltage has positive & negative peaks of about 7V. That's 14V peak-to-peak, (or 16.8V peak-to-peak from 6VRMS) and you are only "allowed" 5V peak-to-peak with the 2.5V bias. Make sure to check/calibrate with a multimeter. 6V transformers tend to run a little high with a light load and the Arduino's ADC isn't as accurate as a meter.

I like steinie44's idea... The capacitor will charge-up to the peak so you can simply read the DC. Of course, you still need a voltage divider. As long as the source is known to be a sine wave the relationship between RMS & peak is known and constant. (The voltage-drop across the diodes creates a non-linearity, but line voltage is constant enough that this isn't a problem.)

You need a resistor in parallel with the capacitor so that the input doesn't "float". 100uF and 10k gives you a 1 second time constant... It depends on how "stable" you want the readings to be and how fast you want the readings to react. You can use a much-much shorter time-constant, or leave out the capacitor completely if you want to "pick out" the peaks in software.

Atmel's application note AVR465 explains all your questions. Google for it.

Hi, if you want to sample the waveform then mart256 is the way to go.

If it is just the level that you are after then, rectify, filter to DC and scale to 0 to 5Vdc level.
The voltage at the analog input will be Vpeak, now IF the waveform is SINE then Vrms=Vpeak/SQUAROOTof(2).

If you want to measure measure positive and negative excursions separately.
Then 1/2wave rect to get positive voltage.
And 1/2wave rect to get negative voltage and then invert the signal to get 0 to 5Vdc range.
Then feed to two analog inputs.

Tom.... :slight_smile:

DVDdoug:
Peak. A 5VAC RMS voltage has positive & negative peaks of about 7V. That's 14V peak-to-peak, (or 16.8V peak-to-peak from 6VRMS) and you are only "allowed" 5V peak-to-peak with the 2.5V bias. Make sure to check/calibrate with a multimeter. 6V transformers tend to run a little high with a light load and the Arduino's ADC isn't as accurate as a meter.

I like steinie44's idea... The capacitor will charge-up to the peak so you can simply read the DC. Of course, you still need a voltage divider. As long as the source is known to be a sine wave the relationship between RMS & peak is known and constant. (The voltage-drop across the diodes creates a non-linearity, but line voltage is constant enough that this isn't a problem.)

You need a resistor in parallel with the capacitor so that the input doesn't "float". 100uF and 10k gives you a 1 second time constant... It depends on how "stable" you want the readings to be and how fast you want the readings to react. You can use a much-much shorter time-constant, or leave out the capacitor completely if you want to "pick out" the peaks in software.

Hi ,

mind to give me the circuit of ac voltage act as an input to arduino

currently im doing a project about synchronizing grid with ac source and arduino act as controller..

since i need to get the grid voltage as an input, hence i need to step down the value so that the arduino board can read the value. However since the value still in ac voltage although it was been stepped down to below 5v, im still confuse on how can i connecting it to the arduino board as an input as it still have negative cycle on it.

zulcar9:
Hi ,

mind to give me the circuit of ac voltage act as an input to arduino

currently im doing a project about synchronizing grid with ac source and arduino act as controller..

since i need to get the grid voltage as an input, hence i need to step down the value so that the arduino board can read the value. However since the value still in ac voltage although it was been stepped down to below 5v, im still confuse on how can i connecting it to the arduino board as an input as it still have negative cycle on it.

You need to be aware the transformer AC is not in phase with the input AC signal.

Paul.

zulcar9:
since i need to get the grid voltage as an input, hence i need to step down the value so that the arduino board can read the value. However since the value still in ac voltage although it was been stepped down to below 5v, im still confuse on how can i connecting it to the arduino board as an input as it still have negative cycle on it.

No negatives allowed on the ADC pin. Period.

  1. you have to bring down your voltage a lot more: the PEAK voltage must go down to <2.5V (so RMS <1.8V). That's the peak for the highest voltage you ever expect to see.

  2. you supply this voltage to an OpAmp (single supply, rail-to-rail type), positive input, and apply a 2.5V fixed voltage to the negative input as offset. That will give you a 0-5V wave output which then can be read by the Arduino's ADC.

To complete the circuit iirc you add a load resistor across your transformer output, and connect the other end to the ground of your circuit.