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.
| Printed Code | Calculation (pF) | Picofarads (pF) | Nanofarads (nF) | Microfarads (µF) |
|---|---|---|---|---|
| 101 | 10 × 10¹ | 100 pF | 0.1 nF | 0.0001 µF |
| 102 | 10 × 10² | 1,000 pF | 1 nF | 0.001 µF |
| 103 | 10 × 10³ | 10,000 pF | 10 nF | 0.01 µF |
| 104 | 10 × 10⁴ | 100,000 pF | 100 nF | 0.1 µF |
| 105 | 10 × 10⁵ | 1,000,000 pF | 1,000 nF | 1.0 µF |
| 222 | 22 × 10² | 2,200 pF | 2.2 nF | 0.0022 µF |
| 473 | 47 × 10³ | 47,000 pF | 47 nF | 0.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
| Component | Exact Variant / Spec | Estimated 2026 Cost |
|---|---|---|
| Microcontroller | ESP32-WROOM-32 DevKit V1 (30-pin) | $4.50 |
| Display | 0.96" I2C OLED SSD1306 (128x64, 0x3C addr) | $3.20 |
| Charge Resistor | 10kΩ Metal Film (1% tolerance, 1/4W) | $0.10 |
| Test Subject | Ceramic Capacitor (e.g., 104 / 100nF) | $0.05 |
| Miscellaneous | 830-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.
| Function | ESP32 GPIO | Wiring Destination |
|---|---|---|
| I2C Data (SDA) | GPIO 21 | OLED SDA |
| I2C Clock (SCL) | GPIO 22 | OLED SCL |
| Charge Control | GPIO 25 | 10kΩ Resistor (to Cap +) |
| Discharge Control | GPIO 26 | Cap + (via 220Ω safety resistor) |
| Analog Read (ADC) | GPIO 34 | Cap + (Resistor/Cap junction) |
| Ground | GND | Cap -, OLED GND |
| Power | 3V3 | OLED 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:
- Check I2C Pull-ups and Address (For the OLED Error): The
ERR_I2C_TIMEOUTstring triggers when theWirelibrary 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 to0x3Dinstead of0x3C. If it's 0x3D, update theSCREEN_ADDRESSmacro in the code. - 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.
- 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.
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.






