Vernier Software and Technology
Vernier Software & Technology
Arduino and Vernier Sensors

Calibrating Sensors with Linear Calibrations

Fortunately, the vast majority of standard Vernier analog (BTA) sensors have linear calibrations. For these sensors, you need to convert from a raw voltage (described in the previous section) to the sensor value using the following equation:

sensorValue = slope * voltage + slope

You can get the slope and intercept for Vernier sensors with a linear calibration from the sensor’s User Manual. You can download user manuals from any sensor’s web page or from the Vernier Support section of the website.

In the sensor’s User Manual, you will find a section called Specifications that lists the Stored Calibrations (slopes and intercepts) for that sensor. For example, the User Manual for the Vernier Dual-Range Force Sensor ±10N range lists:

Stored calibration

  • slope: -4.9 N/volt
  • intercept: 12.25 N

To convert Arduino voltages to forces in newtons, you would need to add variables for the slope and intercept, as well as the calibration equation. The sample sketch, VernierTutorialLinearCalibration, will read the raw count from a Vernier Dual-Range Force Sensor once every half second, convert it to a voltage, and then convert it to a sensor value. This sketch assumes the sensor is plugged into the Analog 2 port on the Vernier Arduino Interface Shield or connected to an Analog Protoboard Adapter wired to Arduino pin A2 as explained in the Connecting Vernier Sensors to the Arduino Using a Breadboard section.

/* VernierTutorialLinearCalibration (v2017)
 * This sketch reads the raw count from a Vernier Analog (BTA) 
 * sensor once every half second, and uses its algebraic slope 
 * and intercept to convert it to standard units.
 * Plug the sensor into the Analog 2 port on the Vernier Arduino 
 * Interface Shield or into an Analog Protoboard Adapter wired 
 * to Arduino pin A2.

float rawCount; //create global variable for reading from A/D converter (0-1023)
float voltage; //create global variable for voltage (0-5V)
float sensorValue; //create global variable for sensor value
float slope = -4.9; //create global variable for slope for a Dual-Range Force Sensor +/-10N range
float intercept = 12.25; //create global variable for intercept for a Dual-Range Force Sensor +/-10N range
char units = "N"; //create global variable for units for a Dual-Range Force Sensor
void setup() {
  Serial.begin(9600); //setup communication to display

void loop() {
  rawCount=analogRead(A2); //read one data value (0-1023)
  voltage=rawCount/1023*5; //convert raw count to voltage (0-5V)
  sensorValue=slope*voltage+intercept; //convert to sensor value with linear calibration equation
  Serial.print(sensorValue); //print sensor value 
  Serial.println(units); //print units and skip to next line
  delay(500); //wait half second



Vernier Engineering Contest

Vernier recognizes instructors for creative uses of Vernier sensors to introduce engineering concepts and/or practices. Vernier Engineering Award »

Go to top