The 3-digit capacitor number code is a standardized shorthand where the first two digits represent significant figures and the third digit is the multiplier (number of zeros) in picofarads (pF). For example, a code of 104 translates to 10 × 10⁴ pF, which equals 100,000 pF, or 100 nF (0.1 µF). While a basic capacitor number code calculator can give you the nominal target, real-world components drift. In this guide, we will build an embedded ESP32 tool that not only calculates the theoretical value from the printed code but also measures the actual capacitance via RC time constants to verify if your components are within tolerance.

The Theory: Decoding the 3-Digit Capacitor Code

Ceramic disc and multilayer ceramic capacitors (MLCCs) are often too small to print full microfarad or nanofarad values. Instead, manufacturers use the EIA (Electronic Industries Alliance) 3-digit marking system. The base unit is always picofarads (pF).

  • Digit 1 & 2: Significant figures.
  • Digit 3: Multiplier (10^x).
  • Letter (Optional): Tolerance code (e.g., J = ±5%, K = ±10%, M = ±20%, Z = +80%/-20%).

For a deeper dive into capacitor dielectrics and coding standards, refer to the Electronics Tutorials capacitor guide.

Common Capacitor Number Codes & Conversions
Printed CodeCalculation (pF)Picofarads (pF)Nanofarads (nF)Microfarads (µF)
10110 × 10¹100 pF0.1 nF0.0001 µF
10210 × 10²1,000 pF1 nF0.001 µF
10310 × 10³10,000 pF10 nF0.01 µF
10410 × 10⁴100,000 pF100 nF0.1 µF
10510 × 10⁵1,000,000 pF1,000 nF1.0 µF
22222 × 10²2,200 pF2.2 nF0.0022 µF
47347 × 10³47,000 pF47 nF0.047 µF

Project Build: ESP32 Capacitance Meter & Code Verifier

To verify if a bin of '104' capacitors is actually 100nF or if they have degraded, we will measure the actual capacitance. The ESP32 charges the capacitor through a known 10kΩ resistor and uses its internal ADC to measure the time it takes to reach 63.2% of the supply voltage (one RC time constant, τ = R × C). By rearranging the formula to C = τ / R, we extract the real-world capacitance.

Parts List & Spec Sheet

ComponentExact Variant / SpecEstimated 2026 Cost
MicrocontrollerESP32-WROOM-32 DevKit V1 (30-pin)$4.50
Display0.96" I2C OLED SSD1306 (128x64, 0x3C addr)$3.20
Charge Resistor10kΩ Metal Film (1% tolerance, 1/4W)$0.10
Test SubjectCeramic Capacitor (e.g., 104 / 100nF)$0.05
Miscellaneous830-point breadboard, 22 AWG jumper wires$6.00

Pin Mapping Table

We use GPIO 34 for the analog read. This is critical: GPIO 34 is an input-only pin on the ESP32 and lacks internal pull-up/pull-down resistors, preventing parasitic leakage that would skew high-impedance RC measurements. For more on ESP32 pin strapping and ADC nuances, check the Adafruit OLED and ESP32 wiring guides.

FunctionESP32 GPIOWiring Destination
I2C Data (SDA)GPIO 21OLED SDA
I2C Clock (SCL)GPIO 22OLED SCL
Charge ControlGPIO 2510kΩ Resistor (to Cap +)
Discharge ControlGPIO 26Cap + (via 220Ω safety resistor)
Analog Read (ADC)GPIO 34Cap + (Resistor/Cap junction)
GroundGNDCap -, OLED GND
Power3V3OLED VCC

The Firmware: RC Time Constant Measurement

The following C++ code targets the ESP32-WROOM-32 DevKit V1. It initializes the OLED, waits for a button press (simulated here via Serial input for simplicity), calculates the theoretical value of a user-inputted 3-digit code, and then performs the physical RC measurement to display the deviation.

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

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int CHARGE_PIN = 25;
const int DISCHARGE_PIN = 26;
const int ANALOG_PIN = 34;
const float R_VAL = 10000.0; // 10k ohms
const int ADC_THRESHOLD = 2588; // 63.2% of 4095 (12-bit ADC max)

void setup() {
  Serial.begin(115200);
  
  // Initialize OLED with error handling
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("ERR_I2C_TIMEOUT: OLED not found at 0x3C"));
    while(true) { delay(1000); } // Halt execution
  }
  
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.println(F("Cap Code Calculator"));
  display.println(F("Enter 3-digit code:"));
  display.display();

  pinMode(CHARGE_PIN, OUTPUT);
  pinMode(DISCHARGE_PIN, OUTPUT);
  pinMode(ANALOG_PIN, INPUT);
  
  digitalWrite(CHARGE_PIN, LOW);
  digitalWrite(DISCHARGE_PIN, LOW);
}

void loop() {
  if (Serial.available() > 0) {
    String codeStr = Serial.readStringUntil('\n');
    codeStr.trim();
    
    if (codeStr.length() == 3) {
      int sigFigs = codeStr.substring(0, 2).toInt();
      int multiplier = codeStr.substring(2, 3).toInt();
      
      // Calculate theoretical pF
      float theoretical_pF = sigFigs * pow(10, multiplier);
      float theoretical_nF = theoretical_pF / 1000.0;
      
      // Measure actual capacitance
      float actual_nF = measureCapacitance();
      
      // Display results
      display.clearDisplay();
      display.setCursor(0,0);
      display.print(F("Code: ")); display.println(codeStr);
      display.print(F("Nom: ")); display.print(theoretical_nF); display.println(F(" nF"));
      display.print(F("Act: ")); display.print(actual_nF); display.println(F(" nF"));
      
      float deviation = ((actual_nF - theoretical_nF) / theoretical_nF) * 100.0;
      display.print(F("Dev: ")); display.print(deviation); display.println(F(" %"));
      display.display();
      
      Serial.print(F("Nominal: ")); Serial.print(theoretical_nF); Serial.println(F(" nF"));
      Serial.print(F("Actual: ")); Serial.print(actual_nF); Serial.println(F(" nF"));
    } else {
      Serial.println(F("Error: Input must be exactly 3 digits."));
    }
  }
}

float measureCapacitance() {
  // Discharge phase
  pinMode(DISCHARGE_PIN, OUTPUT);
  digitalWrite(DISCHARGE_PIN, LOW);
  delay(100); // Allow full discharge
  pinMode(DISCHARGE_PIN, INPUT); // High-Z to prevent loading
  
  // Charge phase
  unsigned long startTime = micros();
  digitalWrite(CHARGE_PIN, HIGH);
  
  unsigned long elapsedTime = 0;
  unsigned long timeout = 5000000; // 5 second timeout
  
  while (analogRead(ANALOG_PIN) < ADC_THRESHOLD) {
    elapsedTime = micros() - startTime;
    if (elapsedTime > timeout) {
      digitalWrite(CHARGE_PIN, LOW);
      return -1.0; // Error: Capacitor too large or open circuit
    }
  }
  
  digitalWrite(CHARGE_PIN, LOW);
  
  // Calculate C = t / R (in Farads), then convert to nF
  float t_seconds = (float)elapsedTime / 1000000.0;
  float c_farads = t_seconds / R_VAL;
  float c_nF = c_farads * 1000000000.0;
  
  return c_nF;
}

Debugging: First Three Things to Check When It Fails

When working with high-impedance analog circuits on the ESP32, hardware faults often manifest as software hangs or wild data. If your serial monitor outputs the exact error string ERR_I2C_TIMEOUT: OLED not found at 0x3C, or if your capacitance readings are wildly inaccurate, follow this ranked decision path:

  1. Check I2C Pull-ups and Address (For the OLED Error): The ERR_I2C_TIMEOUT string triggers when the Wire library fails to handshake. First, verify your OLED module has physical pull-up resistors (usually 4.7kΩ) on the SDA/SCL lines; cheap clone boards sometimes omit them. Second, run an I2C scanner sketch. Some SSD1306 variants default to 0x3D instead of 0x3C. If it's 0x3D, update the SCREEN_ADDRESS macro in the code.
  2. Verify ADC Pin Selection and Leakage: If the code compiles but the measured capacitance reads 2x or 3x higher than the calculator result, you are likely using an ADC2 pin (like GPIO 12, 13, or 14) or a pin with internal pull-ups enabled. ADC2 conflicts with the ESP32's WiFi radio and introduces noise. Ensure you are strictly using GPIO 34, 35, 36, or 39 (ADC1 channels), which are input-only and lack internal pull-ups.
  3. Inspect the Discharge Path: If the first reading is correct but subsequent readings climb infinitely, the capacitor isn't discharging between cycles. Check the wiring on GPIO 26. Ensure you are using a ~220Ω current-limiting resistor between GPIO 26 and the capacitor's positive leg to prevent exceeding the ESP32's 40mA absolute maximum GPIO sink limit when dumping a large 1µF+ capacitor.
Callout Tip: The ESP32's internal 12-bit ADC is notoriously non-linear below 0.15V and above 3.1V. By targeting the 63.2% charge threshold (~2.08V on a 3.3V rail), we land squarely in the ADC's most linear and accurate region, minimizing calculation errors without needing external op-amp conditioning.

Extending and Simplifying the Build

To Simplify: If you don't have an SSD1306 OLED on hand, you can strip out all Adafruit_SSD1306 and Wire.h dependencies. Rely entirely on the Serial Monitor. Replace the display.print() calls with Serial.print(), and use physical pushbuttons wired to GPIOs with internal pull-ups to cycle through preset codes (103, 104, 105) instead of typing them into the serial console.

To Extend: Upgrade the physical interface by adding a rotary encoder (e.g., KY-040) to dial in the 3-digit code without a keyboard. For higher accuracy on sub-100pF capacitors, swap the 10kΩ charge resistor for a 100kΩ or 1MΩ 1% metal film resistor, and adjust the R_VAL constant in the code. This increases the RC time constant, giving the micros() timer more resolution to count the charging curve of tiny ceramic caps.

Capacitor Code Calculator FAQ

How do I calculate the value of a 3-digit capacitor code?

Take the first two digits as your base number, and multiply it by 10 raised to the power of the third digit. The result is in picofarads (pF). For example, code 473 means 47 × 10³ pF = 47,000 pF. To convert to nanofarads (nF), divide by 1,000 (47 nF). To convert to microfarads (µF), divide by 1,000,000 (0.047 µF).

What does the letter after the capacitor number code mean?

The letter indicates the manufacturing tolerance, which is the allowable deviation from the nominal calculated value. Common letters include J (±5%), K (±10%), M (±20%), and Z (which uniquely means +80% / -20%, often found on older ceramic disc caps used for decoupling where minimum capacitance is the only strict requirement).

Why does my measured capacitance differ from the calculator result?

Ceramic capacitors, especially those with Y5V or Z5U dielectrics, exhibit severe capacitance loss when DC bias voltage is applied or when operating outside room temperature. A '104' (100nF) X7R capacitor might measure 95nF at 0V, but drop to 40nF when 3.3V is applied across it. Furthermore, cheap components frequently ship outside their stated tolerance bands. Always measure critical timing capacitors in-circuit if possible.

Can I use this capacitor number code calculator for electrolytic capacitors?

No. The 3-digit EIA code system is almost exclusively used for ceramic, film, and tantalum capacitors. Aluminum electrolytic capacitors have enough physical surface area to print the actual microfarad (µF) value and voltage rating directly on the sleeve (e.g., "100µF 25V"). Additionally, the ESR (Equivalent Series Resistance) of large electrolytics can skew simple RC time-constant measurements on basic microcontrollers.