How to scale ADC Input

Using ADC on the Photon
ADC Input range 0-3.3V 12-bit 4096 steps

Using Pressure Sensor
0-2500 psi. output is 0.5 to 4.5 VDC

Using a Resistor Voltage Divider to stay under the 3.3 VDC input limit with 1.8K and 3.3K (should limit output to 3.24VDC Max)

Not sure how to do the math to scale this properly. Any guidance appreciated. Thanks

Hi @phoneman

Starting from the sensor, 0.5V to 4.5V will be lowered by the resistor voltage divider by 3300/(3300+1800) or 3300/5100 or 33/51 so

0.5 V * 33/51 = 0.3235 V for 0 psi
4.5 V * 33/51 = 2.9118 V for 2500 psi

Now into the Photon we find

For 0 psi: 0.3235 V / 3.3 V * 4096 steps = 401.56 so the ADC should read about 402.
For 2500 psi: 2.9118 V / 3.3 V * 4096 steps = 3614.11 so ADC level 3614 or so.

So now you can figure that 0-2500 psi maps to 402 to 3614 ADC levels or 0.77833 psi per ADC step. You can read the ADC, subtract 402 and multiply by 0.77833 to get the reading in psi.

In reality, your 3.3V supply will not be exactly 3.3V and there will be noise in the readings.


Thanks so much for your prompt and detailed reply.

Digesting and trying the conversion now.

if you wanted more theory behind the great bko’s explanation, you may find some in the section Method #1 – Voltage Divider on this page here:


1 Like