Projects / Ohmmeter for loose resistors

Ohmmeter for loose resistors

A simple divider-based ohmmeter reads unmarked resistors and shows the value and nearest standard value.

Beginner2.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. UNO15.1 mASSD1306

    Install the libraries

    Adafruit SSD1306 and Adafruit GFX Library.

  2. UNO

    Measure the three references

    Note their real values with a multimeter.

  3. UNO

    Wire the references

    1k on D8, 10k on D9, 100k on D10, all to A0.

  4. UNO

    Add the test leads

    One lead to A0, the other to GND.

  5. UNO

    Upload the sketch

    With open leads it shows No resistor.

  6. UNO

    Clip a 4.7 kilohm resistor in

    About 4.7 k with the nearest E12 4.7 k.

  7. UNO

    Try 220 ohm and 470 kilohm

    Check the range switching.

  8. UNO

    Edit RANGE_OHM

    Put in your measured reference values for better accuracy.

In short

How do you build an ohmmeter for loose resistors?

A simple divider-based ohmmeter reads unmarked resistors and shows the value and nearest standard value. You need Arduino Uno R3, Resistor 10 kΩ, Resistor 1 kΩ, Resistor 100 kΩ, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 150 minutes.

Level
Beginner
Time
About 150 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
1 kilohm referenceUno D8 to A0Low range
10 kilohm referenceUno D9 to A0Middle range
100 kilohm referenceUno D10 to A0High range
Resistor under testBetween A0 and GNDUse two clips or a socket
OLED SDA and SCLUno A4 and A5Display, address 0x3C
OLED VCC and GNDUno 5V and GNDCheck your module voltage

Code

The three known resistors form, one at a time, a voltage divider with the unknown resistor: 5 V from an output pin goes through the known resistor to A0, and the unknown resistor runs from A0 to ground. The reading is raw = 1023 times Rx divided by (Rk plus Rx), so Rx equals Rk times raw divided by (1023 minus raw). That reading is most accurate when raw is near the middle of the scale, so the sketch tries all three ranges and picks the one closest to 512. The pins not in use are set to INPUT so they do not load the divider. An Uno output pin has about 25 ohms of resistance, which matters on the 1 kilohm range, so the sketch adds it. The result is shown with the nearest value from the E12 series, the standard values used on 10 percent resistors. Accuracy is limited by the tolerance of your three reference resistors, which is 5 percent for typical carbon film resistors, so measure your references with a multimeter and put the real values in the table. Do not use this to measure resistors that are in a live circuit.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const uint8_t RANGE_PIN[3] = {8, 9, 10};
const float RANGE_OHM[3] = {1000.0, 10000.0, 100000.0};
const float PIN_R = 25.0;            // output pin resistance, about 25 ohms on an Uno

const float E12[12] = {1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2};

int readRange(uint8_t i) {
  for (uint8_t k = 0; k < 3; k++) pinMode(RANGE_PIN[k], INPUT);   // all others off
  pinMode(RANGE_PIN[i], OUTPUT);
  digitalWrite(RANGE_PIN[i], HIGH);
  delay(5);
  long sum = 0;
  for (uint8_t n = 0; n < 16; n++) sum += analogRead(A0);
  pinMode(RANGE_PIN[i], INPUT);
  return sum / 16;
}

float nearestE12(float ohms) {
  float decade = pow(10, floor(log10(ohms)));
  float best = 0, bestErr = 1e9;
  for (uint8_t i = 0; i < 12; i++) {
    for (uint8_t d = 0; d < 2; d++) {          // also compare with the next decade's 1.0
      float v = (d == 0 ? E12[i] : 10.0) * decade;
      float err = fabs(log(ohms / v));
      if (err < bestErr) { bestErr = err; best = v; }
    }
  }
  return best;
}

void printOhms(float r) {
  if (r >= 1000000.0) { oled.print(r / 1000000.0, 2); oled.print(" M"); }
  else if (r >= 1000.0) { oled.print(r / 1000.0, 2); oled.print(" k"); }
  else { oled.print(r, 0); oled.print(" ohm"); }
}

void setup() {
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.setTextColor(SSD1306_WHITE);
}

void loop() {
  // Choose the range whose reading is closest to the middle of the scale.
  int bestRaw = 0, bestIdx = 0, bestDist = 9999;
  for (uint8_t i = 0; i < 3; i++) {
    int raw = readRange(i);
    int dist = abs(raw - 512);
    if (dist < bestDist) { bestDist = dist; bestRaw = raw; bestIdx = i; }
  }

  oled.clearDisplay();
  oled.setTextSize(1);
  oled.setCursor(0, 0);
  if (bestRaw > 1015) {
    oled.print("No resistor");
  } else {
    float rk = RANGE_OHM[bestIdx] + PIN_R;
    float rx = rk * bestRaw / (1023.0 - bestRaw);     // divider formula
    oled.print("Measured:"); oled.setCursor(0, 14); oled.setTextSize(2);
    printOhms(rx);
    oled.setTextSize(1); oled.setCursor(0, 40);
    oled.print("Nearest E12:"); oled.setCursor(0, 50);
    printOhms(nearestE12(rx));
  }
  oled.display();
  delay(300);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Open leadsNo resistor
4.7 kilohm resistorBetween 4.5 and 4.9 k
220 ohm resistorBetween 200 and 240 ohm
470 kilohm resistorBetween 440 and 500 k
Short the leadsA very low value, near the pin resistance

If it does not work

Always No resistor

Check the unknown resistor goes from A0 to GND.

Readings jump

Use firm clips, and keep fingers off the leads.

Low ohms read wrong

The pin resistance matters, check the 25 ohm figure.

High values read low

Skin touching the leads adds a parallel path.

Display blank

Try address 0x3D, and check the display voltage.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the ohmmeter for loose resistors?

Arduino Uno R3, Resistor 10 kΩ, Resistor 1 kΩ, Resistor 100 kΩ, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the ohmmeter for loose resistors take to build?

About 150 minutes for a beginner maker, in 8 steps.

How do I know the ohmmeter for loose resistors works?

Open leads: No resistor. 4.7 kilohm resistor: Between 4.5 and 4.9 k. 220 ohm resistor: Between 200 and 240 ohm.

Always No resistor: what should I check?

Check the unknown resistor goes from A0 to GND.

Readings jump: what should I check?

Use firm clips, and keep fingers off the leads.

Low ohms read wrong: what should I check?

The pin resistance matters, check the 25 ohm figure.

High values read low: what should I check?

Skin touching the leads adds a parallel path.