11001000, the exact decimal conversion is 200.
Converting base-2 binary sequences into base-10 decimal numbers is the foundational math behind every digital system, from basic logic gates to microcontrollers measuring AC mains. While the pure math is straightforward, applying this conversion to real-world electrical engineering—specifically when translating binary Analog-to-Digital Converter (ADC) readings into decimal AC voltages or power values—requires strict attention to reference voltages, phase angles, and regional grid standards.
The Core Math: How Do You Convert Binary to Decimal?
The base-2 positional system assigns a weight to each bit based on powers of 2, starting from $2^0$ on the far right (the Least Significant Bit) and increasing as you move left. According to All About Circuits, the formula for an 8-bit binary number is:
$D = (b_7 \times 2^7) + (b_6 \times 2^6) + (b_5 \times 2^5) + (b_4 \times 2^4) + (b_3 \times 2^3) + (b_2 \times 2^2) + (b_1 \times 2^1) + (b_0 \times 2^0)$
Substituting the bits for our query value 11001000:
$D = (1 \times 128) + (1 \times 64) + (0 \times 32) + (0 \times 16) + (1 \times 8) + (0 \times 4) + (0 \times 2) + (0 \times 1)$
$D = 128 + 64 + 0 + 0 + 8 + 0 + 0 + 0 = \mathbf{200}$
Neighboring Values (±20% Range)
When debugging digital logic or setting threshold registers, it helps to see the binary equivalents for values surrounding your target. Here is the ±20% range (160 to 240) around our target of 200:
| Decimal | 8-Bit Binary |
|---|---|
| 160 | 10100000 |
| 180 | 10110100 |
| 200 | 11001000 |
| 220 | 11011100 |
| 240 | 11110000 |
Scaling 8-Bit Binary to 12-Bit ADC Voltages
In practical embedded systems like the ESP32-WROOM-32, you rarely work with just 8 bits. The internal ADC is 12-bit (0–4095). If you map an 8-bit binary value to a 12-bit ADC scale against a 3.3V logic reference, the decimal and voltage outputs shift as follows:
| 8-Bit Binary | Decimal (Base-10) | 12-Bit ADC Equivalent | ESP32 Voltage (3.3V Ref) |
|---|---|---|---|
00000000 | 0 | 0 | 0.000V |
01000000 | 64 | 1024 | 0.825V |
10000000 | 128 | 2048 | 1.650V |
11000000 | 192 | 3072 | 2.475V |
11111111 | 255 | 4095 | 3.300V |
From Binary to Decimal AC Voltage: 120V vs 230V vs 3-Phase
When you move from pure math to measuring AC mains with a microcontroller and a sensor module (like a ZMPT101B voltage transformer), converting binary ADC readings to a decimal AC voltage requires scaling. The assumption that fixes the answer is your voltage reference (Vref) and your step-down transformer ratio.
Because AC voltage is a sine wave, the ADC reads the peak voltage, not the RMS (Root Mean Square) value displayed on your multimeter. How the binary ceiling shifts depends entirely on the regional grid standard you are measuring:
| Mains Standard | Nominal RMS | Peak Voltage | Binary ADC Ceiling (12-bit) | Decimal Scaling Factor |
|---|---|---|---|---|
| US Split-Phase | 120V | ~170V | 2104 | 0.057 |
| EU Single-Phase | 230V | ~325V | 4030 | 0.057 |
| 3-Phase (L-L) | 400V | ~565V | 4095 (Clipped) | Requires 5V Ref |
The 3-Phase Trap: If you use a voltage divider calibrated for 230V single-phase and attempt to measure a 400V 3-phase line-to-line signal, the 565V peak will exceed your ADC's maximum input. The binary output will hard-clip at 111111111111 (4095), rendering your decimal conversion entirely inaccurate. You must recalculate your step-down resistors to accommodate the higher peak.
When Binary-to-Decimal Power Conversion is Meaningless
Converting binary voltage and current samples into decimal Volt-Amps (VA) is straightforward. However, converting those binary readings into decimal Real Power (Watts) is entirely meaningless if the Power Factor (PF) and phase angle are unknown.
According to the U.S. Department of Energy, reactive loads like induction motors, transformers, and uncorrected fluorescent ballasts cause the current waveform to lag behind the voltage waveform. If your microcontroller simply multiplies the decimal RMS voltage by the decimal RMS current, you are calculating Apparent Power.
To get true decimal Watts, your firmware must sample both waveforms simultaneously, calculate the time delay (phase shift) between the zero-crossings, and apply the cosine of that angle ($\cos \theta$). Without measuring that phase shift, any decimal Wattage value your code prints to the serial monitor is a mathematical fiction.
FAQ: Binary Conversion Edge Cases
Can I convert negative decimal numbers to binary?
Standard base-2 math only handles positive integers. To represent negative decimal numbers in digital logic, systems use Two's Complement. To convert a negative decimal (e.g., -56) to 8-bit binary: find the binary for positive 56 (00111000), invert all bits (11000111), and add 1 (11001000). Note that in Two's Complement, 11001000 represents -56, not 200. Context and data type definitions (signed vs. unsigned) fix the answer.
Why does my ESP32 ADC read 4095 when the multimeter says 2.8V?
The ESP32's internal ADC is notoriously non-linear near the top and bottom of its range. As documented in the Texas Instruments SLAA013 application note on data converters, SAR (Successive Approximation Register) ADCs suffer from offset and gain errors. On the ESP32, any voltage above ~2.5V to 2.6V will often saturate and return a hard binary ceiling of 4095. To fix this, use an external I2C ADC like the ADS1115, or scale your voltage divider down so your maximum expected voltage hits around 2.0V (decimal ~2480).
Does endianness affect binary-to-decimal conversion?
Endianness (Big-Endian vs. Little-Endian) dictates how multi-byte binary data is stored in memory, but it does not change the mathematical conversion of a single isolated byte. However, if you are reading a 16-bit binary register over I2C and the bytes arrive Little-Endian, you must swap the high and low bytes in your firmware before applying the decimal conversion formula, or your decimal output will be wildly incorrect.






