# analog level conversion in ADC circuit

I'm trying to feed a 3.3V ADC from a gas sensor that operates at 5V. I know I can use a voltage divider, but am a bit confused how it would apply here. It appears that this circuit operates as a voltage divider already, with the sensor acting as a variable resistor (B1 and B2 are internally connected, as is A1 and A2). If that's the case, can I still add another voltage divider after this, as follows: With GAS_V then going to the ADC, or am I missing how this would work?

• Your title contains "logic level" (on or off) but your sensor is analog. You probably mean "analog level conversion". – Transistor Jun 24 '16 at 6:05
• @transistor - good point. – kolosy Jun 25 '16 at 16:27

You don't give voltage at pin GAS_V ,this is your output pin, you read value from it. So there is no need to use voltage divider at this node.The way you are using voltage divider it will give you a fixed 3.3V at that pin which may damage your sensor.

According to your datasheet your supply voltage must be 5V (so if you are thinking about using 3.3V here, change you sensor that operate in 3.3V)and your output voltage will very from 2.5V to 4V.I'm guessing you want to bring this output range within 3.3V.

If you want that , use GAS_V pin as the supply pin for your voltage divider and take the divided voltage as input for ADC. consider GAS_V as 4V (maximum value) and calculate values of resistances that give you 3.3V .

A fair warning , your divided voltage may not 100% correct all the time with good precision as we are not considering input resistance and max input current of the device you are using to read ADC value. If it's input value is too high comparing your voltage divider resistances, it will work fine. If not then you can design it considering input resistance of the device. Fist see the datasheet of the device to find input resistance and current of the ADC pin and consider this resistance is connected in parallel with bottom resistance.

From what I can tell from Fig. 2 in the gas sensor's data sheet, U1 pins B1 and B2 (in your schematic diagram) should be shorted together and connected to the top leg of resistor RL, as shown in the gas sensor's datasheet. And the bottom leg of resistor RL connects to your circuit's ground.

I'm trying to use a 3.3V logic level on a gas sensor that operates at 5V.

I might be telling you something you already know, but your gas sensor outputs an analog voltage $V_{RL}$ whose value can be any voltage within the range

$$0\: V \leqslant V_{RL} \leqslant 4.5\: V$$

The gas sensor does not output a digital logic signal. Connecting an analog voltage to a digital logic input pin won't do what you want/need. Instead, you must perform an analog-to-digital conversion (ADC)—i.e., you must convert the gas sensor's analog output voltage into an n-bit binary integer number that your software can use. (Given the title of your question, I suspect you already realize this.)

Many microcontrollers have one or more built-in ADC circuits. If your microcontroller has a built-in ADC circuit refer to the microcontroller's datasheet to determine the maximum input voltage at the ADC input pin. For the sake of this discussion, let's say the datasheet says the ADC's maximum input voltage is 1 VDC. Your job, then, is to create a circuit that reduces the gas sensor's maximum output voltage of 4.5 VDC down to 1 VDC. The easiest way to do this is with a resistor voltage divider circuit—i.e., replace resistor RL with two resistors R1 and R2 connected in series to form a voltage divider circuit. Your job is to select values for R1 and R2 that produce an output voltage of 1 VDC when the gas sensor's output voltage is 4.5 VDC.

HINT 1: Use Vin = 4.5 VDC on SparkFun's "Voltage Divider" tutorial page.

HINT 2: The sum resistance value R1 + R2 should be approximately equal to RL's original value of 4.7 kΩ (see Fig. 5 in the gas sensor's datasheet)—i.e.,

$$R_{L}=4.7\: k\Omega \approx R1 + R2$$

HINT 3: This website provides tables that show the "standard resistor values" for resistors with value tolerances of ±1%, ±2%, ±5%, and ±10%. After you calculate theoretical values for resistors R1 and R2 you need to select "real" resistor values—i.e., resistor values that actually exist, that you can actually buy. For example, if the theoretical value of R1 is 1234.5678 ohms, you might select/buy a ±5% resistor whose value is 1.2 kΩ, or you might select/buy a ±1% resistor whose value is 1.24 kΩ. Ensure your chosen values for R1 and R2 do not produce an output voltage VOUT that exceeds your ADC's maximum input voltage when the gas sensor's output voltage is 4.5 VDC.