Converting a 1.50V analog signal to a digital value using a 12-bit analog to digital converter for Raspberry Pi (such as the Microchip MCP3208) with a 3.3V reference yields a raw digital count of 1861. This direct conversion assumes a stable 3.3V reference voltage (VREF), a single-ended input configuration, and a 12-bit resolution (4096 discrete steps). Because the Raspberry Pi lacks native analog input pins, relying on an external ADC over SPI or I2C is mandatory for reading sensors, and understanding the exact math bridging the analog voltage to the digital integer is critical for accurate calibration.

The Conversion Formula:
Digital Count = (V_in / V_ref) × (2^n - 1)
Substituted Values: (1.50 / 3.3) × (2^12 - 1) = 0.4545 × 4095 = 1861.36 (rounded down to 1861).

Hardware Comparison: Selecting Your Pi ADC

Before calculating values, you must lock in your hardware assumptions. The resolution (n) and reference voltage (V_ref) dictate your step size (Least Significant Bit, or LSB). Below is a data-dense comparison of the most common ADC ICs used in Raspberry Pi embedded projects.

ADC ICResolutionInterfaceVREF RangeMax Sample RateTypical Price
Microchip MCP300810-bit (1024 steps)SPI2.7V - 5.5V200 ksps$2.50
Microchip MCP320812-bit (4096 steps)SPI2.7V - 5.5V100 ksps$4.10
TI ADS111516-bit (65536 steps)I2C0.3V - 5.5V (Internal)860 sps$3.60
NXP PCF85918-bit (256 steps)I2C2.5V - 6.0V100 sps$1.80

Sources: Microchip MCP3208 Datasheet, Texas Instruments ADS1115 Datasheet.

Neighboring Value Conversion Table (±20% Range)

Sensors rarely output a perfect static voltage. If your nominal target is 1.50V, real-world fluctuations will push the reading ±20% (1.20V to 1.80V). Here is how those analog voltages map to digital counts across the three most popular Pi ADC resolutions, assuming a fixed 3.3V VREF.

Analog Voltage (V_in)10-Bit Count (MCP3008)12-Bit Count (MCP3208)16-Bit Count (ADS1115)
1.20V (-20%)372148923834
1.35V (-10%)418167626813
1.50V (Nominal)465186129792
1.65V (+10%)511204732771
1.80V (+20%)558223335750

How VREF, Mains AC, and Phase Shift the Math

The assumption that fixes the baseline answer above is a stable, noise-free 3.3V reference. However, the math shifts dramatically depending on your power architecture and what you are measuring.

Shifting VREF: 3.3V vs 5.0V

If you power an MCP3208 with a 5V VREF to maximize dynamic range for a 0-5V sensor, the Pi’s 3.3V GPIO logic will be destroyed by the 5V SPI MISO line unless you use a logic level shifter. If you do shift the logic and use 5V VREF, the formula changes: (1.50 / 5.0) × 4095 = 1228. Never assume VREF matches the Pi's logic voltage unless explicitly wired to the Pi's 3.3V rail.

Measuring 120V vs 230V vs 3-Phase AC

When using an analog to digital converter for Raspberry Pi to monitor AC mains via a voltage transformer module (like the ZMPT101B), the analog signal is stepped down and biased to a 1.65V DC offset so the Pi can read the negative AC half-cycles.

  • 120V vs 230V: For a 120V nominal system, the peak-to-peak swing is smaller, utilizing fewer ADC steps than a 230V system scaled to the same module. You must adjust the multiplication factor in software based on the transformer's specific turns ratio.
  • 3-Phase Systems: In 3-phase monitoring, you must sample three separate ADC channels simultaneously. If your ADC (like the MCP3008) multiplexes sequentially rather than sampling simultaneously, phase-angle skew will corrupt your power calculations, introducing a timing error of several microseconds between Channel 0 and Channel 2.

When the Conversion is Meaningless

There are specific scenarios where converting an ADC count back to a real-world unit provides false confidence:

  1. Power Factor (PF) is Unknown: If you are using the ADC to measure AC voltage and current to calculate real power (Watts), but the phase shift (Power Factor) is unknown or unmeasured, converting the RMS voltage and current counts into real power is meaningless. You can only calculate apparent power (VA).
  2. Unregulated VREF: If your VREF is derived directly from the Pi’s 3.3V rail without a dedicated voltage reference IC (like the LM4040), switching noise from the Pi's CPU and WiFi module will inject 20-40mV of ripple into the rail. On a 12-bit ADC, this renders the lowest 3 to 4 bits entirely meaningless, effectively reducing your 12-bit ADC to an 8-bit ADC.
  3. Floating Inputs: An unconnected ADC pin will float, picking up environmental EMI and returning random counts between 0 and 4095. Always use a 10kΩ pulldown resistor on unused channels.

FAQ: Raspberry Pi ADC Edge Cases

Why is my ADS1115 returning negative digital counts?

The ADS1115 is a 16-bit signed ADC. If you configure it for differential measurement (e.g., AIN0 to AIN1) and the voltage on AIN1 is higher than AIN0, the chip outputs a negative two's complement integer. Switch your configuration register to single-ended mode (measuring AINx to GND) if you only need positive 0-3.3V readings.

Do I need to worry about the Pi's I2C clock stretching with the ADS1115?

Yes. The Raspberry Pi's hardware I2C pins (GPIO 2 and 3) sometimes struggle with clock stretching, which the ADS1115 uses during conversion. If you experience I/O errors or locked buses, move the ADC to software I2C pins or switch to an SPI-based ADC like the MCP3208, which is generally more robust on the Pi's hardware SPI bus.

How do I handle the 0.7V diode drop in my sensor circuit?

If you are passing your analog signal through a standard silicon protection diode (like a 1N4148) before it hits the ADC input, you must subtract ~0.65V from your V_in before applying the conversion formula, or simply calibrate the offset out in your Python/C++ code using a known reference voltage.

For more on configuring the Pi's hardware buses, refer to the official Raspberry Pi Hardware Documentation.