ESR meter with Arduino

@ronx
I think I made some mistakes in my sketch and assumed wrong how the original circuit worked when reverse engineered Lee Hung's schematic. I assumed it was a constant current circuit, which as I see it now it is not. The formula used in the sketch thus will not give correct results, funny thing is when I tried it by measuring different value resistors, readings were pretty sound. I currently don't have the possibility to test the following but if you have time please replace the formula and post back if this works better.

As I see it now in the circuit we have a voltage divider (see Wikipedia article on this Voltage divider - Wikipedia) (from there we get the formula for calculating Z2 = (Vout*Z1)/(Vin-Vout))

replace this line

esrVal = (miliVolt)/current - esrCal;//calculate ESR in miliOhm

with this

esrVal = (miliVolt*100)/(4.9-miliVolt);//calibration should be done by changing the value of 100 (This is the 1% reference resistor) and/or changing the 4.9 value which is the Vin and it is given by the the voltage regulator on the arduino board

When I have a litle spare time I'll test it.

Greeatings