Guides · 10 min read

Arduino Battery Capacity Tester: Measure 18650 mAh and Wh

Arduino battery capacity tester: discharge an 18650 with a MOSFET and power resistor, measure voltage and current, calculate mAh and Wh, 2.8 V cut-off, fakes.

An Arduino battery capacity tester shows you not what is printed on a cell, but how much energy it can really deliver. 18650 cells labelled 9900 mAh that don't even give 800 mAh, tired cells pulled from old laptop packs and no-name spares are everywhere. The only reliable way to tell them apart is to discharge the cell from full to empty through a known load and add up the current over time. An Arduino can do this with a MOSFET and a power resistor, with accuracy close to a commercial tester.

In this article you'll learn the logic of a capacity test, the job of every part in the circuit and which power resistor to choose for a given discharge current. You'll measure battery voltage and current with the Arduino, calculate mAh and Wh second by second and switch off the load automatically when the cell reaches 2.8 V. Then you'll build a stand-alone tester with an OLED display and a button, and see how to tell fake cells apart using internal resistance and weight.

18650 Li-ion battery
This tester is designed to measure the real capacity of single 18650 Li-ion cells.

How does a battery capacity test work?

Capacity is how long a battery can deliver a given current. A 2500 mAh cell can in theory supply 2500 mA for one hour or 500 mA for five hours. But because the voltage drops during discharge, the current isn't constant; that's why the tester measures the current again every second and adds up the small pieces. You don't need a separate current sensor: if you measure the voltage at both ends of the known load resistor, Ohm's law gives I = (V_top − V_bottom) / R. Every second adds mAh += I(mA) × Δt(h), and the energy share is Wh += V × I(A) × Δt(h). Wh is the better measure for comparing batteries with different voltages; you'll find the difference explained in the mAh and Wh article.

QuantityFormulaExample (4.7 Ω, cell at 3.70 V, MOSFET side 0.02 V)
CurrentI = (V_A0 − V_A1) / R(3.70 − 0.02) / 4.7 = 0.783 A
Capacity in one secondmAh = I × 1000 × (1 / 3600)783 × 0.000278 = 0.22 mAh
Energy in one secondWh = V × I × (1 / 3600)3.70 × 0.783 / 3600 = 0.0008 Wh
Power in the load resistorP = I² × R0.783² × 4.7 = 2.88 W
Internal resistanceR_int = (V_open − V_load) / I(4.15 − 4.05) / 0.86 = 116 mΩ

Parts list

  • Arduino Uno or Nano
  • Logic-level N-channel MOSFET: IRLZ44N, IRL540N or IRLB8721 (must turn fully on with 5 V on the gate)
  • Power resistor: 4.7 Ω 10 W aluminium-housed (or the value you choose from the table)
  • Resistors: 220 Ω (gate), 10 kΩ (gate pull-down), 2 × 1 kΩ (to protect the analog inputs)
  • 18650 battery holder, thick wires and an optional 2 A fuse
  • For the OLED version: 0.96 inch I2C OLED display, push button and buzzer
  • A TP4056 charger module and a multimeter to prepare the cell

Circuit and wiring

The discharge current flows in a single loop: from the cell's positive terminal through the load resistor, then through the MOSFET's drain and source back to the negative terminal. The Arduino isn't part of that loop; it only drives the MOSFET gate and measures the voltage at two points. A0 reads the cell's positive terminal and A1 reads the bottom of the load resistor (MOSFET drain); the difference between them is the voltage across the resistor. The 10 kΩ resistor on the gate stops the MOSFET from turning on by itself while the Arduino resets or code is being uploaded. You can see how a MOSFET works as a switch in the Arduino MOSFET article.

ConnectionGoes toNote
Battery +Top of the load resistor and A0 through 1 kΩUse thick wire
Bottom of the load resistorMOSFET drain and A1 through 1 kΩOn the IRLZ44N the middle leg is the drain
MOSFET sourceBattery −Keep the current loop short
Arduino GNDDirectly to battery −Load current must not flow through the Arduino's GND
MOSFET gateD9 through 220 Ω, 10 kΩ to GNDLoad stays off when no code is running
Button (OLED version)D2 and GNDINPUT_PULLUP
Buzzer (OLED version)D8 and GNDBeeps when the test ends
OLED displaySDA → A4, SCL → A5, VCC → 5V, GND → GNDAddress 0x3C
A Li-ion cell delivers very high current into a short circuit and can overheat and catch fire. Run the test on a non-flammable surface, don't leave the device unattended for hours and check the plus and minus of the battery holder with a multimeter before building. If you insert the cell backwards, the MOSFET's internal diode conducts and the analog pins see a negative voltage; the 1 kΩ series resistors help protect the Arduino in that case, but it's best not to reverse it at all. Power the Arduino from USB first and then insert the cell; if the cell stays connected while the Arduino is off, it can back-feed the board through the analog inputs. A 2 A fuse in the load loop adds extra safety.

Resistor and heat table by discharge current

The load resistor sets the discharge current and the test time. A low resistance speeds up the test, but the resistor and MOSFET get hotter, and at high current the cell shows less capacity because of chemical losses. Manufacturers usually rate 18650 capacity at 0.2C, i.e. about 500 mA for a 2500 mAh cell. That's why 8.2 Ω suits comparing against the datasheet value, while 4.7 Ω is a good balance between time and accuracy. The values below were calculated with Ohm's law and P = V² / R; wire and MOSFET resistance lower the current slightly, but that doesn't affect the result because the code measures the real current. You can also work out the resistor for your own cell voltage with the Ohm's law calculator.

Load resistorCurrent at 4.2 V / 3.7 V / 3.0 VPower at 3.7 VRecommended resistorApprox. time for 2500 mAh
10 Ω0.42 / 0.37 / 0.30 A1.4 W5 W cement6.5–7 hours
8.2 Ω0.51 / 0.45 / 0.37 A1.7 W5 W cement5.5 hours
4.7 Ω0.89 / 0.79 / 0.64 A2.9 W10 W aluminium-housed3–3.5 hours
3.3 Ω1.27 / 1.12 / 0.91 A4.1 W10 W aluminium + heatsink or 20 W2–2.5 hours
2.2 Ω1.91 / 1.68 / 1.36 A6.2 W25 W aluminium + heatsink or fan1.5 hours
Choose a resistor rated at least twice the power it dissipates: for 4.7 Ω at 2.9 W, a 10 W resistor is the right choice. The rated power of aluminium-housed resistors applies when they are bolted to a heatsink; left in free air they get too hot to touch even at half that power. A MOSFET like the IRLZ44N has about 0.025 Ω with 5 V on the gate and produces only 0.02 W of heat at 0.8 A, so no heatsink is needed. Non-logic-level MOSFETs such as the IRFZ44N don't turn fully on at 5 V and heat up.

Why a 2.8 V cut-off voltage?

If a Li-ion cell is discharged below 2.5 V, its internal structure is permanently damaged, its capacity drops and recharging becomes risky. Datasheets usually give an end-of-discharge voltage between 2.5 and 2.75 V. Choosing 2.8 V in the tester leaves a safe margin and loses very little capacity, because the discharge curve is very steep below 3.0 V: only a few percent of the total capacity is left between 3.0 V and 2.8 V. So don't be surprised if your result is a little below the label; with a current around 0.3C and a 2.8 V cut-off, a good cell showing 90–95% of its rated capacity is normal. The cut-off is measured under load; once the load is removed, the cell recovers to 3.2–3.4 V within a few minutes, which is also normal. You'll find the link between voltage and state of charge in the 18650 battery guide.

Step by step: your first capacity test

TP4056 charger module
Fully charge the cell with the TP4056 before the test and let it rest for half an hour.
  1. Fully charge the cell with the TP4056 module; when the charging LED goes out and the full LED lights up, the cell is at 4.2 V. Then let it rest for 30 minutes.
  2. Touch the multimeter probes together and read their own resistance, then measure the load resistor and enter the difference in the R_LOAD constant.
  3. Measure the Arduino's 5V pin with the multimeter; if the Vcc printed in the Serial Monitor differs, correct BANDGAP_MV to 1100 × measured / printed.
  4. Plug the Arduino into USB first and upload the code, then insert the cell the right way round and reset the Arduino.
  5. Open the Serial Monitor at 115200 baud; first the open-circuit voltage and internal resistance are printed, then a CSV line every 10 seconds.
  6. When the test ends, paste the lines into a spreadsheet and plot voltage against time; that curve tells you far more about the cell's health than a single number.
C++ (Arduino IDE)
1// Arduino 18650 pil kapasite test cihazı: MOSFET + güç direnci, mAh, Wh, iç direnç, 2,8 V kesme
2// Arduino 18650 battery capacity tester: MOSFET + power resistor, mAh, Wh, internal resistance, 2.8 V cut-off
3const int PIN_BAT = A0;                // pil + (1 kΩ seri direnç üzerinden) / battery + (through 1 kΩ series resistor)
4const int PIN_DRAIN = A1;              // yük direnci alt ucu = MOSFET drain / bottom of load resistor = MOSFET drain
5const int PIN_GATE = 9;                // MOSFET gate (220 Ω seri, 10 kΩ GND'ye) / MOSFET gate (220 Ω series, 10 kΩ to GND)
6
7const float R_LOAD = 4.7;              // multimetreyle ölçtüğün yük direnci (Ω) / load resistor measured with a multimeter (Ω)
8const float V_CUTOFF = 2.80;           // kesme gerilimi (V) / cut-off voltage (V)
9const long BANDGAP_MV = 1100;          // iç 1,1 V referans, kalibre et / internal 1.1 V reference, calibrate it
10
11float mAh = 0, Wh = 0;
12unsigned long lastMs = 0, startMs = 0, lastLog = 0;
13bool running = false;
14
15long readVccMv() {                     // 5V hattını iç referansla ölç / measure the 5V rail with the internal reference
16  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);   // AVcc referans, 1,1 V kanal / AVcc ref, 1.1 V channel
17  delay(2);
18  ADCSRA |= _BV(ADSC);
19  while (bit_is_set(ADCSRA, ADSC)) {}
20  uint16_t r = ADC;
21  return (BANDGAP_MV * 1023L) / r;
22}
23
24float readVolts(int pin, float vcc) {
25  analogRead(pin);                     // kanal değişimi sonrası ilk okumayı at / discard first read after channel switch
26  long s = 0;
27  for (int i = 0; i < 32; i++) s += analogRead(pin);
28  return (s / 32.0) * vcc / 1023.0;
29}
30
31void setup() {
32  Serial.begin(115200);
33  pinMode(PIN_GATE, OUTPUT);
34  digitalWrite(PIN_GATE, LOW);         // yük kapalı / load off
35  delay(500);
36
37  float vcc = readVccMv() / 1000.0;
38  float vOpen = readVolts(PIN_BAT, vcc);           // yüksüz gerilim / open-circuit voltage
39  Serial.print(F("Vcc: ")); Serial.print(vcc, 3);
40  Serial.print(F(" V  Pil yuksuz / open circuit: ")); Serial.print(vOpen, 3); Serial.println(F(" V"));
41
42  if (vOpen < V_CUTOFF + 0.1 || vOpen > 4.30) {
43    Serial.println(F("Pil yok, bos ya da gerilim hatali / no battery, empty or invalid voltage"));
44    return;
45  }
46
47  digitalWrite(PIN_GATE, HIGH);        // deşarjı başlat / start discharging
48  delay(2000);
49  float vLoad = readVolts(PIN_BAT, vcc);
50  float iLoad = (vLoad - readVolts(PIN_DRAIN, vcc)) / R_LOAD;
51  float rInt = (vOpen - vLoad) / iLoad;            // iç direnç + kontaklar / internal resistance + contacts
52  Serial.print(F("Ic direnc / internal resistance: ")); Serial.print(rInt * 1000.0, 0); Serial.println(F(" mOhm"));
53  Serial.println(F("sure_s,V,mA,mAh,Wh"));
54
55  running = true;
56  startMs = lastMs = lastLog = millis();
57}
58
59void loop() {
60  if (!running) return;
61  if (millis() - lastMs < 1000) return;            // saniyede bir ölç / measure once per second
62
63  unsigned long now = millis();
64  float dtH = (now - lastMs) / 3600000.0;          // geçen süre, saat / elapsed time in hours
65  lastMs = now;
66
67  float vcc = readVccMv() / 1000.0;
68  float vBat = readVolts(PIN_BAT, vcc);
69  float vDrain = readVolts(PIN_DRAIN, vcc);
70  float iA = (vBat - vDrain) / R_LOAD;             // direnç üzerindeki gerilim / resistor voltage = I x R
71  if (iA < 0) iA = 0;
72
73  mAh += iA * 1000.0 * dtH;                        // akım x süre / current x time
74  Wh += vBat * iA * dtH;                           // güç x süre / power x time
75
76  if (now - lastLog >= 10000 || vBat <= V_CUTOFF) {
77    lastLog = now;
78    Serial.print((now - startMs) / 1000); Serial.print(',');
79    Serial.print(vBat, 3); Serial.print(',');
80    Serial.print(iA * 1000.0, 0); Serial.print(',');
81    Serial.print(mAh, 0); Serial.print(',');
82    Serial.println(Wh, 2);
83  }
84
85  if (vBat <= V_CUTOFF) {
86    digitalWrite(PIN_GATE, LOW);                   // kesme: yükü kapat / cut-off: switch the load off
87    running = false;
88    Serial.print(F("BITTI / DONE  Kapasite / capacity: ")); Serial.print(mAh, 0);
89    Serial.print(F(" mAh  Enerji / energy: ")); Serial.print(Wh, 2); Serial.println(F(" Wh"));
90  }
91}

At start-up the code measures the cell's open-circuit voltage with the load off, and doesn't start the test unless it is between 2.9 and 4.3 V. It then turns the MOSFET on, waits two seconds and calculates the internal resistance from the loaded voltage and current. This value also includes the resistance of the holder and wires, so it comes out a little higher than the true internal resistance; but it's a very good indicator for comparing cells tested on the same rig. Every second the loop measures both voltages as an average of 32 readings, calculates the current and adds to mAh and Wh using the real elapsed time from millis. When the cell voltage drops to 2.8 V, the MOSFET turns off and the result is printed.

The biggest enemy of accuracy is the Arduino's supply voltage. analogRead results are scaled to the 5V rail, and USB voltage can drift between 4.7 and 5.1 V over a test lasting hours. The readVccMv function solves this: it measures the ATmega328P's internal reference of about 1.1 V against the 5V rail and works backwards to the real supply voltage. Because this reference can vary by ±10% from chip to chip, the one-time calibration in step 3 matters; after that, the readings stay correct even when the supply drifts. One step of the 10-bit ADC is about 4.9 mV, which means a current resolution of about 1 mA with 4.7 Ω. You'll find analog voltage measurement covered in more detail in the Arduino voltmeter article.

Stand-alone tester with an OLED display

For a device that works without a computer, a 0.96 inch OLED display, a button and a buzzer are all you need. When switched on, it shows HAZIR / READY and the cell's open-circuit voltage. Press the button and, if a valid cell is inserted, the test starts; the display shows mAh in large digits with voltage, current, Wh and elapsed time below. When the cell reaches 2.8 V, the load switches off, the buzzer beeps three times and the result stays on screen. You can power the Arduino from a USB adapter or a separate 5 V source. For the display, see the OLED display guide; the code uses the Adafruit SSD1306 and Adafruit GFX libraries.

C++ (Arduino IDE)
1// OLED ekranlı bağımsız 18650 kapasite test cihazı: buton ile başlat, bitince buzzer
2// Stand-alone 18650 capacity tester with OLED: start with a button, buzzer when done
3#include <Wire.h>
4#include <Adafruit_GFX.h>
5#include <Adafruit_SSD1306.h>
6
7Adafruit_SSD1306 oled(128, 64, &Wire, -1);
8
9const int PIN_BAT = A0, PIN_DRAIN = A1;
10const int PIN_GATE = 9, PIN_BTN = 2, PIN_BUZZ = 8;
11const float R_LOAD = 4.7, V_CUTOFF = 2.80;
12const long BANDGAP_MV = 1100;
13
14enum State { IDLE, TESTING, DONE };
15State state = IDLE;
16float mAh = 0, Wh = 0, vBat = 0, iA = 0;
17unsigned long lastMs = 0, startMs = 0, endMs = 0;
18
19long readVccMv() {
20  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
21  delay(2);
22  ADCSRA |= _BV(ADSC);
23  while (bit_is_set(ADCSRA, ADSC)) {}
24  return (BANDGAP_MV * 1023L) / ADC;
25}
26
27float readVolts(int pin, float vcc) {
28  analogRead(pin);
29  long s = 0;
30  for (int i = 0; i < 32; i++) s += analogRead(pin);
31  return (s / 32.0) * vcc / 1023.0;
32}
33
34void measure() {
35  float vcc = readVccMv() / 1000.0;
36  vBat = readVolts(PIN_BAT, vcc);
37  iA = (vBat - readVolts(PIN_DRAIN, vcc)) / R_LOAD;
38  if (iA < 0 || state != TESTING) iA = 0;   // yük kapalıyken akım yok / no current when the load is off
39}
40
41void draw() {
42  unsigned long sec = ((state == DONE ? endMs : millis()) - startMs) / 1000;
43  oled.clearDisplay();
44  oled.setTextSize(1);
45  oled.setCursor(0, 0);
46  oled.print(state == IDLE ? F("HAZIR / READY") : state == TESTING ? F("TEST SURUYOR / RUN") : F("BITTI / DONE"));
47  oled.setTextSize(2);
48  oled.setCursor(0, 14);
49  oled.print(mAh, 0); oled.print(F(" mAh"));
50  oled.setTextSize(1);
51  oled.setCursor(0, 36);
52  oled.print(vBat, 2); oled.print(F(" V   ")); oled.print(iA * 1000.0, 0); oled.print(F(" mA"));
53  oled.setCursor(0, 48);
54  oled.print(Wh, 2); oled.print(F(" Wh   "));
55  oled.print(sec / 3600); oled.print(':');
56  if ((sec / 60) % 60 < 10) oled.print('0');
57  oled.print((sec / 60) % 60);
58  oled.display();
59}
60
61void setup() {
62  pinMode(PIN_GATE, OUTPUT);
63  digitalWrite(PIN_GATE, LOW);
64  pinMode(PIN_BTN, INPUT_PULLUP);
65  pinMode(PIN_BUZZ, OUTPUT);
66  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);      // çoğu 0,96 inç OLED 0x3C / most 0.96 inch OLEDs use 0x3C
67  oled.setTextColor(SSD1306_WHITE);
68}
69
70void loop() {
71  if (state == IDLE && digitalRead(PIN_BTN) == LOW) {
72    measure();
73    if (vBat > V_CUTOFF + 0.1 && vBat < 4.30) {  // geçerli pil varsa başla / start only with a valid cell
74      mAh = Wh = 0;
75      digitalWrite(PIN_GATE, HIGH);
76      state = TESTING;
77      startMs = lastMs = millis();
78    }
79    delay(300);
80  }
81
82  if (millis() - lastMs >= 1000) {
83    unsigned long now = millis();
84    float dtH = (now - lastMs) / 3600000.0;
85    lastMs = now;
86    measure();
87    if (state == TESTING) {
88      mAh += iA * 1000.0 * dtH;
89      Wh += vBat * iA * dtH;
90      if (vBat <= V_CUTOFF) {
91        digitalWrite(PIN_GATE, LOW);
92        state = DONE;
93        endMs = now;
94        for (int i = 0; i < 3; i++) { tone(PIN_BUZZ, 2000, 200); delay(400); }
95      }
96    }
97    if (state != TESTING) startMs = (state == IDLE) ? now : startMs;
98    draw();
99  }
100}

The code runs as a state machine with three states: ready, testing and done. Measurement and display update once per second, so the OLED's I2C traffic doesn't disturb the readings. To test a new cell, just reset the Arduino. If you want to extend the circuit to two or four channels, each channel needs its own load resistor, MOSFET and two analog inputs; since the OLED uses A4 and A5, the Uno allows two channels with the display and three without it.

Spotting fake 18650 cells

You can often suspect a fake cell without even testing it. The best 18650 cells today reach about 3500–3600 mAh; an 18650 labelled 5000, 8800 or 9900 mAh is physically impossible. The second clue is weight: a good 18650 usually weighs 44–50 grams, while fakes weigh 20–35 grams. Some fakes contain a small cell padded with sand or plastic, so weight alone isn't enough. The final verdict comes from the capacity test and internal resistance. You'll find other details, such as protected vs unprotected cells, in the 18650 battery guide.

CheckGood 18650Fake or worn-out cell
Label capacity2000–3600 mAhUnrealistic values like 5000–9900 mAh
Weight44–50 g20–35 g, or padded out with filler
Measured capacity (0.3C, 2.8 V)85–95% of the label300–1500 mAh
Internal resistance on this rigAbout 50–150 mΩ (holder and wires included)250 mΩ or more
Temperature during dischargeLukewarmGets noticeably hot
Resting after chargeAbove 4.1 V after a weekClear drop within a few days

Making the measurement more accurate

  • For higher resolution on current and voltage, use an INA219 current sensor; with 12 bits and its own shunt it reaches milliamp-level accuracy.
  • If you want a 16-bit ADC, an ADS1115 module makes the voltage measurement completely independent of the Arduino's supply.
  • For true constant current, build an electronic load from an op-amp, a MOSFET and a small shunt; the current stays constant throughout the discharge regardless of voltage.
  • Instead of measuring only through the holder, run separate sense wires to the cell terminals (four-wire measurement) to take the holder and contacts out of the measurement.
  • On long tests, save the data to an SD card or write the last mAh value to EEPROM so nothing is lost.
  • Note the room temperature; below 10 °C Li-ion cells show noticeably less capacity.

Common problems and fixes

SymptomLikely causeFix
Current always reads 0MOSFET not turning on or gate wired wrongUse a logic-level MOSFET, check D9 and the 220 Ω connection
MOSFET gets very hotNon-logic-level MOSFET only half on at 5 VChoose a MOSFET such as IRLZ44N, IRL540N or IRLB8721
Capacity far below the labelCell not fully charged, current too high or cell really weakCharge fully with the TP4056, test again with 4.7 Ω or 8.2 Ω
Measured voltage differs from the multimeter5V supply calculation or bandgap calibration wrongCorrect BANDGAP_MV based on the measured 5V
Test ends immediatelyVoltage sags under load because of wire and holder resistanceUse thick wires, connect A0 directly to the cell terminal
Arduino resets during the testLoad current flows through the Arduino's GND wireConnect the Arduino GND straight to battery −, keep the load loop separate
Calculated internal resistance very highSpringy holder or oxidised contactsClean the contacts, use a four-wire measurement

Built from just a few parts, this tester shows how long your cells will really last and lets you weed out fake or worn-out cells before they end up in your project; with the same measuring logic you can also track energy in solar and battery systems. If you want to try voltage measurement, displays and buttons step by step with a circuit diagram and ready code, take a look at the measurement projects in the BlueGrays app.

Frequently asked questions

How do you measure battery capacity?

The battery is fully charged and then discharged through a known load down to the cut-off voltage. During the discharge, the current is measured at regular intervals, multiplied by the time and added up; the result is the capacity in mAh. An Arduino can do this with a MOSFET, a power resistor and two analog inputs.

How low can you discharge an 18650 battery?

Most manufacturers give an end-of-discharge voltage between 2.5 and 2.75 V for 18650 Li-ion cells. Using a 2.8 V cut-off in a tester protects the cell and leaves only a few percent of the capacity unmeasured. Below 2.5 V the cell can be permanently damaged.

How can you tell if an 18650 battery is fake?

Unrealistic labels above 5000 mAh and a weight under 35 grams are the first warning signs. For certainty, fully charge the cell and run a capacity test; fakes usually reach only 300–1500 mAh. High internal resistance and heating during discharge strengthen the suspicion.

What resistor should I use for a battery capacity test?

For a single 18650 cell, a 4.7 Ω 10 W resistor gives a balanced test of about 3 hours at roughly 0.8 A. To compare against the label, an 8.2 Ω 5 W resistor is better because its current is close to 0.2C. The resistor's rating should be at least twice the power it dissipates.

What is the difference between mAh and Wh?

mAh shows the amount of charge a battery delivers, while Wh shows the total energy. You get Wh by multiplying mAh by the average voltage and dividing by 1000; a 2500 mAh 18650 at an average of 3.6 V delivers about 9 Wh. When comparing batteries with different voltages, Wh is the more accurate measure.

How accurate is an Arduino battery capacity tester?

When the load resistor is measured with a multimeter and the supply voltage is corrected with the internal reference, the result is usually within a few percent. The biggest error sources are resistor tolerance, drifting USB voltage and the resolution of the 10-bit ADC. Using an INA219 or ADS1115 improves accuracy further.

See all projects
LED Control with a Push Button (Push)
AR-9Beginner

LED Control with a Push Button (Push)

Just like a doorbell: the light stays on as long as you press, and goes off when you let go.

4.8(118)
283
Using a Buzzer
AR-13Beginner

Using a Buzzer

Ever wondered how a doorbell or an alarm makes its sound? The Arduino makes a small buzzer beep at short intervals: beep, pause, beep, pause.

4.7(93)
180
Digital Voltmeter with LCD Display
AR-56Intermediate
Premium

Digital Voltmeter with LCD Display

Find out how much voltage a battery or power adapter gives with a meter you built yourself.

4.5(27)
36
Using LCD Screen with I2C
AR-32Beginner
Premium

Using LCD Screen with I2C

Give your Arduino its own screen and make it write its first message. The two-line LCD screen hooks up with just a few wires; a greeting appears on the top line, then a second message on the bottom…

4.8(53)
71
ESP32 HTTPClient + Weather API (with SSD1306 OLED Display)
ES-32Advanced
Premium

ESP32 HTTPClient + Weather API (with SSD1306 OLED Display)

In this project the ESP32 makes a REST API call over the internet to a weather API (wttr.in) using HTTPClient.h. Unlike the I2C LCD version, it uses an SSD1306 OLED (128×64) display, with large text and vector icons for a richer look. Seven weather icons (sunny, rainy, snowy and more) are drawn on the fly, with no bitmap files.

4.3(10)
22
Temperature Measurement with NTC and 2x16 Lcd Display
AR-44Beginner
Premium

Temperature Measurement with NTC and 2x16 Lcd Display

Measure the temperature around you with a sensor that looks like a tiny bead. This part, called an NTC, lets electricity through more easily as it warms up; the Arduino reads that change, turns it…

4.5(33)
44
ESP32 I2C LCD Display (16x2)
ES-17Intermediate
Premium

ESP32 I2C LCD Display (16x2)

In this project we connect a 16x2 character LCD to the ESP32 over I2C and display text. With I2C, just 2 data pins (SDA and SCL) control the screen, instead of the 6+ pins a classic parallel connection wastes. The code prints a fixed message on the first line and a counter that goes up every second on the second. At startup an I2C scanner also prints the display's address to the Serial Monitor (usually 0x27 or 0x3F).

4.9(23)
40
ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
ES-33Advanced
Premium

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)

The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.

4.3(10)
17