# Voltage error ADS

**URL:** <https://forum.arduino.cc/t/voltage-error-ads/1108785>\
**Category:** Sensors\
**Created:** [March 30, 2023, 10:46am UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785 "2023-03-30T10:46:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lolastic](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/lolastic/32/939578_2.png) [@lolastic](https://forum.arduino.cc/u/lolastic)\
**Post date:** [March 30, 2023, 10:46am UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/1 "2023-03-30T10:46:35Z")

</div>

Hello so I have a code for my ADS1115  
`#include \<Wire.h\>  
#include \<Adafruit\_ADS1X15.h\>

Adafruit\_ADS1115 ads; // create ADS1115 object

void setup() {  
Serial.begin(9600); // initialize serial communication  
Wire.begin(); // initialize I2C communication  
ads.begin(); // initialize ADS1115  
}

void loop() {  
int16\_t differential1 = ads.readADC\_Differential\_0\_1(); // read differential voltage  
float voltage1 = differential1 \* 0.0078125; // convert to voltage (assuming default gain of 1)  
Serial.print("Differential voltage weerstand: ");  
Serial.print(voltage1, 3);  
Serial.println("mV");

int16\_t differential2 = ads.readADC\_Differential\_2\_3(); // read differential voltage  
float voltage2 = differential2 \* 0.0078125; // convert to voltage (assuming default gain of 1)  
Serial.print("Differential voltage stof: ");  
Serial.print(voltage2, 3);  
Serial.println("mV");  
delay(1000); // wait for 1 second  
}`  
My question is what is the measured voltage error (absolute error)?

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [March 30, 2023, 12:09pm UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/2 "2023-03-30T12:09:45Z")

</div>

> [@lolastic](#):
>
> assuming default gain of 1

I don't see where you set that in the code, in which case gain defaults at 2/3.

Make sure **both** analogue inputs stay within the boundaries of VCC/GND of the ADS.  
Leo..

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [March 30, 2023, 12:24pm UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/3 "2023-03-30T12:24:45Z")

</div>

If you don't do any offset or gain calibrations and ignoring any errors do to drift, the worst case error will be around 0.156% of the full scale value (FSR).

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [March 30, 2023, 1:41pm UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/4 "2023-03-30T13:41:58Z")

</div>

Hi, @lolastic  
Welcome to the forum.

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966):
>
> See also [FAQ - Arduino Forum](https://forum.arduino.cc/faq) for general rules on forum behaviour and etiquette. Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…

It will tell you how to post your code.

Have you tried the differential code example that comes with the library?

What model Arduino controller are you using?

What have you got connected to the 1115?

Can we please have a circuit diagram?  
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Have you tried the example differential code that comes with the library?

Have you got YOUR code to compile and upload?  
If so have you done some measurements to establish the error?

Thanks.. Tom.. 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![robertnc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/robertnc/32/1013044_2.png) [@robertnc](https://forum.arduino.cc/u/robertnc)\
**Post date:** [April 1, 2023, 10:28am UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/5 "2023-04-01T10:28:18Z")

</div>

So the way an ADS1115 works is it offers a 15 bit resolution based on the Full Scale Range, which is determined by the gain setting.

Your code says "assume default gain of 1". But you are not setting the gain so in fact that will default to gain of 2/3 which corresponds to a FSR of 6.144 volts.

Voltage(mV) = ADC reading \* (FSR/2^15)  
= ADC Reading \*(6144mV/2^15)

You are using 0.0078125mV resolution. That is in fact based on setting the gain to 16 which results in a FSR of 256mV so

Voltage(mV) = ADC Reading \* (FSR/2^15)  
= ADC Reading \* (256mV/2^15)  
= ADC Reading \* 0.0078125mV/bit

That's not right at all because your default gain will set the FSR to 6144mV. So your code is not right, not only are the calculations incorrect but the comments are incorrect.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 28, 2023, 10:28am UTC](https://forum.arduino.cc/t/voltage-error-ads/1108785/6 "2023-09-28T10:28:37Z")

</div>

Closed on September 28, 2023, 10:28am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
