Adafruit ads1015

Hello all,

I am using an Adafruit ads1015 AD converter to read a 12-bit inclinometer. When the inclinometer is sitting level, it outputs a voltage of 2.5V (confirmed with an oscilloscope) and assuming I did my interpolation correctly, the AD converter should convert this to a value of 2048. When I open up the com port and print the reading of the sensor, I am getting a value of 830, which translates to around 1V. I can see that the values change according to how I tilt the inclinometer as they should, but the resting value is incorrect and I can never reach the max (4095) or the min (0) values. If I instead use the Arduino’s 10-bit AD converter, I see the correct values from the com port (10-bit, from 0 to 1023) and it will in turn give me the correct voltage output as well as the correct angle that the inclinometer is sitting at.

Pictures are attached, but my wiring is kind of messy, so here are the connections I’ve made:

VDD on the converter to 5V on the Arduino
GND on the converter to a common ground rail on the breadboard
SCL on the converter to SCL on the Arduino
SDA on the converter to SDA on the Arduino
ADDR on the conerter to the common ground on the breadboard (for the default 0x48 addressing)
Inclinometer to A3 of the converter
Common ground rail on breadboard to GND on Arduino.

My code is as follows:

#include <Adafruit_ADS1015.h>
#include <Wire.h>
float sensorReading;
#define adcSensorPin 3
#define ardSensorPin A0
float sensorVoltage;
float sensorDegrees;
#define powerPin 10
#define groundPin 5

//Defines map function to return floats
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

//Initializes AD converter
Adafruit_ADS1015 ads1015;

void setup() {

void loop() {
  //sensorReading = analogRead(ardSensorPin);
  sensorReading = ads1015.readADC_SingleEnded(adcSensorPin);
  sensorVoltage = mapfloat(sensorReading, 409.5, 3685.5, 0.5, 4.5);
  //sensorDegrees = mapfloat(sensorReading, 409.5, 3685.5, -180, 180);
  //sensorVoltage = mapfloat(sensorReading, 102.4, 922.6, 0.5, 4.5);
  //sensorDegrees = mapfloat(sensorReading, 102.4, 922.6, -180, 180);
  //Serial.print("Angle is ");
  //Serial.println(" degrees");
  //Serial.print("Voltage is ");
  //Serial.println(" volts");

Please ignore the commented portions, this code will be used for running a couple relays once I get the AD converter figured out.

Thanks for your help!

do you have a link to the datasheet of teh ads1015?

did you connect the grounds?

~833 seems to be the value you get in default differential mode with default 2/3 PGA gain and 2.5volt single ended input.
Did you try “ADS1025” in the search box on top of this page?


Here is a link to the ads1015 data sheet. The inclinometer is grounded through the power supply, the inclinometer output is grounded through the power supply, and the AD converter is grounded through the arduino (which is powered via usb from my computer). I measured the voltage across the power supply ground and the arduino ground to make sure they were at the same potential, and they were.


I have been doing a lot of searching online and the most common issue I've found is folks only getting a value of 4095 returned, where my problem is an unexpected value returned (but still responding to changing the orientation of the inclinometer) possibly stemming from my having set something up incorrectly or simply not understanding fully how this device works.

I should note that the output range of the inclinometer is +0.5V to +4.5V.

Did you see this pdf. Default is 3mV/bit. 2.5volt = 2500mV. 2500/3 = ~833

From the pdf, page 17: GAIN_FOUR (for an input range of +/-1.024V) "If we had an analog sensor with an output voltage ~1V (a TMP36, for example), we could set the gain on the ADC to GAIN_FOUR, which would give us a +/-1.024V range. This would push the 1V input signal over the entire 12-bit or 16-bit range of the ADC"

This seems nonsense to me. You can't feed negative voltages into the A/D. My pea-brain tells me only half the A/D (11 bits) can be used single-ended. Maybe someone else can explain this. Leo..