# Guide to Ratiometric Sensor Applications

A ratiometric measurement is a technique that relies on a ratiometric sensor’s ability to maintain a fixed ratio between the input voltage and the output voltage independent of changes in the input voltage. For example, if the sensor’s excitation voltage is set to 5.0 VDC and the output is 2.5 VDC, we can expect a 1.0 VDC output when the excitation voltage is 2.0 VDC. In both cases, the 50% output of the sensor is maintained. Examples of ratiometric sensors include the Vishay linear motion sensor, Allegro analog Hall sensor, and thermistors such as this Murata.

A ratiometric measurement provides a low-cost method to interface a microcontroller to a sensor. The key to an effective ratiometric measurement is to use a common excitation voltage for both the sensor and the microcontroller’s Analog to Digital Converter (ADC). As this excitation voltage naturally drifts, it impacts both sensor and ADC. However, this is mitigated by the ratiometric properties of each device. As an example, consider an excitation voltage drift from 4.9 VDC to 4.2 VDC, the ratio for both the sensor and ADC is equal. Consequently, the binary result of the ADC remains unchanged.

In this article we demonstrate the ratiometric measurement method using the Arduino Nano Every as shown in Figure 1. The ratiometric method is demonstrated by measuring a potentiometer’s angular rotation while a second potentiometer used to adjust the excitation voltage.

Figure 1: Picture of the Arduino Nano Every and potentiometers used in the ratiometric experiment. The 5 kΩ potentiometer on the left is used to adjust the excitation voltage while the potentiometer on the right is the device under test.

Tech Tip: The ratiometric method is not suitable for direct or absolute measurement as it lacks the requisite precision voltage reference. For example, the ratiometric method will not directly measure voltage as “true value” voltage measurements require a quality internal or external voltage reference. Additional information can be found in the Arduino language reference under analogReference( ). This DigiKey forum post explores how to implement an external voltage reference.

## Terminology associated with ratiometric measurement

Before we explore the Arduino circuit, it is useful to include explicit definitions of the various terms associated with the ratiometric measurement. Note that “voltage reference” has different meanings depending on the context.

• Excitation voltage: This voltage serves as the reference to the microcontroller’s ADC as well as the supply voltage for the sensor.

• Voltage reference (physical): A physical voltage reference may be an external device or circuitry embedded into the microcontroller’s die. By default, the Arduino is configured to use the voltage rail as the voltage reference. The purpose of the ratiometric measurement is to ease the performance requirements or eliminate the relatively expensive physical voltage reference.

• Voltage reference (ADC input): At their core, most ADCs operate using voltage comparison. For normal operating modes, the voltage reference is a critical input to the ADC as it determines the true value of the voltage measurement. For example, suppose we operated a 10-bit microcontroller’s ADC with an external 1.024 precision voltage reference. Each count of the ADC equates to 1 mV. For example, a 0.5 VDC signal would register as an ADC output of 500. Now, if the voltage reference drifted to 1.014 VDC, the same 0.5 VDC input signal would register as an erroneous ADC output of 495.

• Ratiometric: Ratiometric is a term that encompasses both the sensor and measurement device such as the microcontroller. Both sensor and ADC share a common excitation voltage. In an ideal situation both devices scale equally with changes to the excitation voltage thereby relaxing the need for a quality external voltage reference.

## Arduino demonstration

The schematic for an Arduino based demonstration circuit is shown in Figure 2. The excitation voltage is set by variable resistor R1. Variable resistor R2 serves as our ratiometric sensor. For this system to work properly, the Arduino’s ADC has been configured for an external sensor using the analogReference(EXTERNAL) command. With this code change, we can see that the excitation voltage is shared between the Arduino’s ADC and the input (top) of the R2 position sensor.

Figure 2: Arduino based test circuit for the ratiometric experiment. The resistor values are not critical as values between 1 kΩ and 10 kΩ are acceptable.

### Ratiometric test

To test the circuit, we will set R2 to a known position. We will then adjust the excitation voltage via R1. In an ideal setting, varying the excitation voltage (R1) will have no effect on the measurement of R2.

The following Arduino code was used for the test. Note that the shaft position of R2 is expressed as a percentage of the full 10-bit ADC count.

``````void setup( ){
analogReference(EXTERNAL);
Serial.begin(9600);
}
void loop( ){
float position = (rawVal / 1024) * 100;
Serial.println(position);
delay(500);
}
``````

### Results

The results are unremarkable. Adjusting R1 from 4.5 to 2.0 had no effect on the ADC result unless the excitation voltage fell to very low levels. In fact, continuous adjustment of R1 had no effect on the measured angle of the R2 potentiometer. This is good news, as the experiment suggest that ratiometric measurement is immune to changes in excitation voltage.

Tech Tip: A variable resistor was used as the excitation voltage for this experiment. In practice, it is more convenient to use the Arduino default voltage rail as the excitation voltage. Normally this is undesirable as the rail voltage will fluctuation with the USB voltage of your PC the voltage regulator, or the condition of the battery. The rail voltage will also change based on the type and number of loads attached to the microcontroller. The beauty of ratiometric measurements is that these natural voltage changes do not significantly affect the measurement.

Tech Tip: Use care to match the ratiometric sensor to the microcontroller’ voltage rail. Recall that microcontrollers are available with both 5.0 and 3.3 VDC voltage rails. Many of the legacy sensors are not compatible with the 3.3 VDC microcontrollers.

## Parting thoughts

The ratiometric sensor / microcontroller pair provides a low-cost method that provides a true value for the measured system. This may be a good solution for your project as opposed to the modern and more complex I^2C or SPI devices.

Be sure to test your knowledge by completing the questions and critical thinking questions located at the end of this note. Also, please your leave questions and comments in the space below. We would love to hear from you especially if you have a project that features the ratiometric sensor.

Best Wishes,

APDahlen

Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (partially interwoven with military experience). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET-accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians. Dahlen has returned to his Northern Minnesota home and thoroughly enjoys researching and writing educational articles about electronics and automation.

### Highlighted Experience

Dahlen is an active contributor to the DigiKey TechForum. At the time of this writing, he has created over 145 unique posts and provided an additional 477 forum posts. Dahlen shares his insights on a wide variety of topics including microcontrollers, FPGA programming in Verilog, and a large body of work on industrial controls.

For additional Arduino education content visit this Arduino Index page.

Connect with Aaron Dahlen on LinkedIn.

## Questions

The following questions will help reinforce the content of the article.

1. Define ratiometric as applied to a sensor.

2. Define radiometric when we expand the term and apply it to a microcontrollers ADC.

3. The term ratiometric is often reserved for sensors. Why is this a shortsighted view? Hint: ADC voltage reference.

4. Why is ratiometric a poor choice when measuring voltage.

5. Suppose the microcontroller was configured to use a precision 4.096 VDC external voltage reference and then measure a ratiometric position sensor powered by the Arduino 5 VDC rail. Describe the results as for variation in the Arduino rail voltage and fluctuations in the 4.096 VDC reference.

6. With respect to the previous question, describe how things change if the sensor and ADC were both powered via a properly buffered 4.096 voltage reference.

7. What is meant by the expression “things common to both sides fall out of the calculation” when applied to the ratiometric method. Be specific as to what falls out?

8. The Arduino Nano Every is a 5 VDC device.
A) What is the maximum voltage that may safely be applied to an analog input pin.
B) What is the maximum safe voltage for a 3.3. VDC microcontroller?
C) Can a 5 VDC ratiometric sensor’s output be fed to a 3.3 VDC analog input pin?
D) How can a voltage divider be used to connect a 5 VDC sensor to a 3.3 VDC microcontroller?

9. Research the operation of the Wheatstone bridge. Is the bridge a ratiometric system? What qualities does it share with the ratiometric sensor?

10. Present the schematic for a thermistor to microcontroller interface. Identify the wire connection necessary to a ratiometric response. Hint: Include additional components as required.

## Critical thinking questions

These critical thinking question expand the article’s content to develop a big picture understanding the material and its relationship to adjacent topics. They are often open ended, require research, and are best answered in essay form.

1. The ratiometric technique does a commendable job of mitigating changes in excitation voltage. Do these advantages extend to things like temperature based changes, non-linear response of components, and natural aging?

2. Sketch the schematic of op amp-based buffer for the excitation voltage. For full credit show the voltage reference, sensor, and microcontroller. Hint: Did you account for the op amps voltage overhead?

3. With regards to the previous question, present the DigiKey part numbers for a system featuring a solid state ratiometric sensor of your choice. Assume 5 VDC parts. Hint: Pay special attention to the voltage requirements for each component.

4. Repeat the previous two questions with a new sensor and a 3.3 VDC microcontroller. Hint: Use multiple rail voltages and an external I2C ADC if necessary.

5. An alternative to the previous hardware solution is to perform a ratiometric calculation with a microcontroller ADC can measure both the excitation voltage and the sensor output. With this method, voltage dividers are used to reduce the 5 VDC signals down to 3.3 VDC. Present schematic and code and then comment on the necessity of precision resistors and a high-quality voltage reference.