but when adapter output is disconnected and only midpoint terminal of the transformer is connected the Arduino input pin reads some mV. mid point reads perfect 2.5V. What am I doing wrong?
That's the normal behavior for the circuit you posted. Your adc can read voltages from 0 to 5v but the ac signal (if the voltage divider is spot on) is -2.5v to 2.5v. So you mix a dc 2.5v with the ac signal and subtract the offset voltage the arduino measures to reference your measurement circuits ac 'ground' reference. So 0-127 will be negative and 128-255 will be positive. Openenergymonitor project has some great tutorials and sample code that may keep you from killing yourself literally or figuratively figuring this stuff out.
The buffer opamp isn't needed in your circuit as you are not using much current from the reference voltage. Just Capacitor c1 would give the 2.5v divider a clean voltage. A 3pin 2.5v Ldo chip would give a more accurate reference but is overkill for a toss off arduino circuit.
But I think the real answer to your question is that you should use ac voltage setting on your meter to test the circuit. if you use a meter in DC mode with the mains plugged the voltage will be 0 as the average of a sine wave and 2.5v with no mains signal as that is your 'ground' voltage not 0v.
When you disconnect the adapter there is no current flowing in secondary coil, as there are two 12k resistors which make voltage divider by ratio of 1:2 so in the mid point of it there will be 2.5 v which is applied to the non inverting terminal of op amp which is set to unity gain so the output of op-amp will b 2.5v and as the is no current flowing in the resistor R1 the voltage drop will be 0v so the 2.5v is seen on the Arduino Input pin.
The 'non-midpoint' ground of the secondary transformer should have the same potential as the ground of the Arduino just like analogsystemsrf has done. Otherwise, who knows what kind of voltages you could see at the ADC of the Arduino?
Also, since this is AC, and the 'positive/top' side of the transformer would go negative with respect to the secondary ground, so you need a rectifier so the ADC pin does not go below ground. A series cap like analogsystemsrf would eliminate DC bias.
Edit: Another method (without rectifying) is to add a DC bias of 2.5V so that the signal goes above and below 2.5V (but not abober 5V or below 0V) you could then read both the positive and negative signal while maintaining a safe 0-5V for the ADC. Look up adding a DC bias on Google for many references, but it's basically a voltage divider with the midpoint connected to the signal you want to bias.
if u r measuring Ac Voltage corresponding to AC Main i will suggest u please used diode bridge and filter capacitor at secondary side. 1. u will get DC voltage corresponding to AC mains 2. In your circuit opamp o/p getting loaded because of transformer secondary winding when your AC Mains not available. that's why your reference is changing.
Where did you get the circuit? I'd like to see the original. It will not work at all as drawn.
If all you want is 5v you just need your transformer connected to a bridge rectifier. The low output of the bridge rectifier will be your ground. Then you connect a 7805 regulator and a cap before and after and walla! You have a nice 5v 1A power supply.
protected by Community♦ Mar 24 at 4:24
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?