ESR meter with Arduino

@nurbit I currently use a 47uF, 35V non-polarized electrolytic capacitor, a polarized electrolytic would not be really good (there is the AC component), but a non-polarized ceramic capacitor with the proper C*V values might work, definitely you should give it a try, an interesting experiment would be obtaining a pseudo "non-polarized" cap from two electrolytic wired in series, experiment and see what results you can get. The ESR readings should not be taken as an exact measurement, as ERS really varies with frequency, temperature, capacitance, one will rather use this device to compare two capacitors with same characteristics to see which has a lower ESR, or test if the selected capacitor has a low ESR value, don't get me wrong, the device produces some good readings but I had no possibility to compare it to a reference, the sub ohm (miliohm) measurement precision for pure resistive load is pretty good once calibrated :)

@grant1842 I'm glad you can see some results there, keep trying and the device will work, it's not a very complicated schematic but is very rewarding once you get it going. (at least it was for me as I learned a lot building it). If there are questions and I have the answers I'll gladly help. Keep us posted with the progress.

My diodes have arrived in the post today :)

I was wondering about the 1% resistors though. Did you choose them because you had them laying around or is it vital they should be 1%? Will 5% resistors work but with less accurate results?

I'm going to put it together with parts I have in stock and then replace certain parts if I'm not getting the correct results.

I'll let you know how it goes :)

Sorry, I have another question regarding the transistors

I have some 2222A s but I'm struggling for the PNP transistor. I do have some A1015 s which seems to match the voltage but the collector current is only -150 instead of -800

Will this suffice or should I try to find something better matching?



If you have time and will follow the link at the start of the topic to dr. Le Hung's page from where I got the original schematic you can find some good information on how this ESR meter works.

Until then I will try to explain in a few words some basic things that will help you understand why some components are used. To calculate the ESR we use ohm's law for which the formula is V = I * R, for us the ESR is represented by the R from this equation, thus R = V / I, now we have to get these two values from somewhere so we can compute a result.

For this we setup a circuit which will connect the DUT to a [u]known current[/u] that in turn will produce a [u]voltage drop[/u] on the DUT which we can measure through the analog pin of the arduino, depending on the resistance (esr) we need to measure we might need different current values, the sketch implements just the 50 mA branch, a 5mA branch is available on the schematic and can be easily used switching to the proper pin for higher ESR measurement (in case of lower value capacitors, let's say 10uF and smaller) thus it can be implemented as an auto-range function.

How we obtain the constant current: For a 50 mA current we have: (I = V / R) = 5 / 100 = 0.05 A. Values are from: for Vcc = 5, this is supplied by the arduino's on board voltage regulator and R = 100 (obtained from R8 + the resistance of the transistor at saturation which should be very close to 0 ohm, thus 100 ohm). [u]So the reason to use low tolerance resistor in the current circuit is to ensure the value of the current is exactly as expected and calculated.[/u]

The 1 k ohm 1% resistor (R4) branch can give us a current of 5 mA (I = V / R) = 5 / 1000 = 0.005 A. I have to mention that the 5 mA current is not implemented in the sketch, so you can leave it out for now, this is necessary if you want to measure higher ESR or higher value resistors.

Some more things about the way we measure: we need to pulse the DUT with a very short pulse so that the capacitor we are measuring (especially if is a lower value) will not have time to charge and mess up the reading, plus charging and discharging fast is needed so that we measure the capacitor with a frequency as high as possible so capacitive reactance will be negligible (this is the reason I tried to speed up the analog read by changing the prescaller).

Conclusion: you can use 5% resistor (you can try to calibrate the device from the variables in the sketch), I guess the A1015 should be good too for a 50mA current, give it a try and see what are the results :)

Hi szmeu

Thanks for that explanation... it did help. I haven't yet studied the link you supplied but I will do after posting this :)

Your explanation has made things MUCH clearer as to why you've shoen the parts you have. I'll go and put the circuit together and get some new parts ordered so that I can replace my alternative parts when they arrive.

Thanks again for the explanation and your time.

Is the updated sketch posted here still updated to the posted schematic? Except for the ESR pin which is A0, the pulse pin does not seem to match the schematic based from the sketch.

Will this ESR work in circuit? What is the output voltage P-P? Thanks!

@alyas You are right, for the sketch to work with the schematic you should edit the define lines (I updated the sketch also):

//define the input and output pin we will use
#define ESR_PIN A0
#define PULSE_SMALL 8 //this is not used in the sketch, implement it as needed (for 5mA current needed for smaller cap value measurement)
#define PULSE_PIN 9
#define BUTTON_PIN 0

and for the lcd use pin 5, 6, 10, 11, 12, 13 as in schematic.

@bseishen Yes, this should work in circuit, voltage P-P should be 300mV (max permited by antiparalel Schottky diodes.)

Thank you for sharing your ESR with Arduino, nicely done.

You said "The DUT should be connected to CN1 between GND (pin3,pin4) and pulse and AIN0 (pin1,pin2) using a setup with four wires." I am assuming that you would attach/solder probes to use for testing, but to which wires? (you have four).



To be honest I did use only two wires to the DUT and worked well (one wire from gnd and only one wire from AIN0 and pulse, this means that on CN1 you tie together pin1 and pin2 thus resulting the point of connection for the probe), for more accuracy a four terminal sensing should give better results, you can read more here


Thank you for sharing your excellent circuit and code. I made a PCB from your circuit image and used 2n2222 & 2N2907 transistors and 1% resistors. I didn’t have a non-polar cap, so I soldered the anodes of two 100uF caps together. As a test, I tried adding parallel diodes to the caps, but found they made no difference in my readings. On a pair of used 2200uF 10V caps I got 0.0 Ohms on one that looks good, and 5.600 Ohms on one with a slight top bulge, so it finds bad caps.

The problem I am having is that I am unable to calibrate it. Using a one Ohm resistor I had to set “double current = 0.007460;” to get the meter to read 1.012, but then a 1/3 Ohm resistor reads .090. Could the transistors or DIY capacitor cause this? I'm a beginner, so your post was highly educational and I got a new test tool as well! Thanks again.


@ronx I think [u]I made some mistakes in my sketch and assumed wrong how the original circuit worked[/u] 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 (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.


Thanks for the reply szmeu. I did find the problem, and it was me... I checked my circuit and for R8 (on the PCB) and found 1 Ohm rather than a 100. I must have put my 1 Ohms and 100 Ohms in the same bag last time I cleaned up ;-) After the fix I calibrated using the original code until I got 1001 on a 1 Ohm resistor. The 1/3 Ohm reads 363, and a 10 Ohm reads 4450 (it's all I have to test with). Am I correct in assuming this pretty accurate and the 10 Ohm is just too big? I tried the voltage divider modification, but it gives negative numbers (-112 and -143). Thanks again for the great code, and sorry for the confusion. I think this is an extremely useful tool and have built both an arduino shield and a self-contained ardweeny powered meter housed in an old external hard drive case.

Regards, Ron


I’m glad you found the “bug” in your circuit and managed to get better readings, I will answer to your questions now:

  • your assumption are right, with the 100 ohm branch max reading is around 6 ohm (R = U/I) = 0.300/0.05 = 6 ohm (0.300 is max voltage allowed by schottky diode 1N5822), if you need more range there is R4 branch with the 1k ohm 1% resistor (on D8), (you can implement this in the code and can have upper range that will give you the range of the 100 ohm resistor X 10, I think the same way a lower range could be implemented with a proper transistor that can source 500mA of current through resistor of 10 ohm 1%).
  • you mentioned in your first post that did not use the diodes, I just want to explain now the role of the two groups of diodes, the first group of antiparalel 1N5822 diodes is to allow in circuit measurements, this diodes assure that we will get max 0.3 V on the probes and will not damage components on the board, the second group of diodes 1N4004 are there to protect the input of the Atmega from charged capacitors, good practice is to discharge caps before measurements.
  • 65536 comes from 2^16(using oversampling in code we can have a mapped value between 0 and 65535), if we would take a simple measurement on a AIN pin we would get a 10 bit result which is 1024, but as we are enhancing our reading we get a 16 bit result that needs the proper scaling, thus dividing it by 65535, see

I wonder where I am wrong with the voltage divider formula, I currently don’t have the hardware assembled and no possibility to test it, if you have spare time and in mood please try the following (would be nice to get better results from this simple hardware):
I think the problem comes from mixing Volts with mVolts in the formula I gave you, probably the reason for negative numbers too, display on your LCD the value of miliVolt and see the representation for a known resistor, say 1 ohm, this should be around 0.05 V or 50 mV:

if milivolt (not good)
esrVal = (miliVolt*100)/(4.9-miliVolt) = (50 * 100) / (4.9 - 50) = 5000 / -45.1 = -110

if volt
esrVal = (miliVolt*100)/(4.9-miliVolt) = (0.05 * 100) / (4.9 - 0.05) = 5 / 4.85 = 1.03 ohm

I have to say it’s great to have someone to help testing and give feedback, otherwise it gets boring and can lose interest.

Thanks and glad if I could help :slight_smile:

That's it! With "esrVal = (miliVolt * 100)/(4.9-(miliVolt/100)); " I get 339 on the 1/3 Ohm resistor, 987 on the 1 Ohm and 6582 on the 10 Ohm. My 10V-2200uF good-cap, bad-cap pair now read 21 and 3774 respectively. Perfect! I didn't mention the diodes in my first post as they are the same as you used. I just wanted to verify your PCB works, as do homemade non-polar caps and 2N2222 / 2N2907 transistors.

This is such a useful tool; and so cheap and easy to build. I really hope others build this, make their own modifications, and post their results. If the arduino has enough processing power it would be great to have an audible tone to check caps without looking at the LCD. When I have more time I hope to learn how your code works and make the circuit in Eagle Cad so I can experiment. Thanks again for posting this great project and all your help.


I'd like to build this project but I don't seem to get the thing about the four wire connection to the DUT:

Why use four wires to connect a capacitor that has only two wires? Why not connect pin1 and pin2 of CN1 directly? I've seen other esr meters that use very short wires to connect to the DUT, is this something about wire capacities or something of this kind?

Also, in the original schematic by Le Hung there is an additional BS170 mosfet in the circuit, could anybody clear up what that is about?

I know how a esr-meter works in principle, but this really puzzles me.



Hi there, 1. You can use 2 wires no problem, no need for the 4 wire setup to understand why initially proposed that setup read back as I explained in a previous post. 2. The schematic that uses BS170 is a newer one, version 4.0, the esr meter presented here is based on an older schematic version 3.0 from lee hung. I see the new version has a bunch of modifications compared to ver 3.0. I guess the adition of see it BS170 would be to discharge the cap. If you build the esr meter with Arduino read the post on this thread as you will find answers and some important modifications to the code.

Restecp ;)

I've built the circuit on a breadboard and it works fine. But for production use I'm aiming at eliminating the whole arduino and building a board with a stand alone atmega 328.

The problem is, I can't really decide on how to build the power supply:

I understand that a clean supply voltage is crucial, so just hooking up a 4*AA-battery-pack is out of the question.

But do I have to power the circuit with 5V or will 3.3V also work (with some adjustments to the code, of course)? And if so, can I use a switching regulator instead of a linear one? The Arduino as well as other ESR-meter-projects (including Le Hung's) use linear regulators, so maybe using a switching regulator might not be a good idea, because of the ripple it might introduce. Then again, maybe this issue could be addressed with a few caps..

Any input on this is appreciated!



Can anybody repost zip file from first post in this topic?

Here it is (131 KB)