Library for ADS1115 by Adafruit

Hello!

I am attempting to attach two external ADC's (the ADS1115 by Adafruit) to my Arduino Mega 2560 and I am trying to
program the arduino to read in data from the ADC's. However when I follow the steps on ( Arduino Code | Adafruit 4-Channel ADC Breakouts | Adafruit Learning System ) to begin programming the device through the arduino software, it tells me Adafruit_ADS1115 does not have a name type (which I know normally it would be an int or char or double etc.). Isn't this supposed to be a variable defined in the .h library I believe I downloaded correctly?
Any ideas?

Thanks!

Hello bjudson

Please post your code, using code tags. And can you copy and paste the exact error messages you are getting?

Regards

Ray

bjudson:
it tells me Adafruit_ADS1115 does not have a name type (which I know normally it would be an int or char or double etc.)

No, it tells you that Adafruit_ADS1115 does not name a type.

That's usually because you've failed to install the library / restart the Arduino software

MarkT,

By downloading the library, where would this be? I believe I downloaded a zip file from the Adafruit walkthrough, but it still is not working correctly.

Hackscribble:
Hello bjudson

Please post your code, using code tags. And can you copy and paste the exact error messages you are getting?

Regards

Ray

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1015 ads1015;  	// Construct an ads1015 at the default address: 0x48
Adafruit_ADS1115 ads1115(0x49);	// construct an ads1115 at address 0x49

void setup(void)
{
  ads1015.begin();  // Initialize ads1015
  ads1115.begin();  // Initialize ads1115
}

and the error message comes up as:

ExtADC:9: error: 'Adafruit_ADS1015' does not name a type
ExtADC:10: error: 'Adafruit_ADS1115' does not name a type
ExtADC.ino: In function 'void setup()':
ExtADC:14: error: 'ads1015' was not declared in this scope
ExtADC:15: error: 'ads1115' was not declared in this scope

As MarkT said, looks like the library is not properly installed. Try the following ...

Download the library zip file and extract it to a folder (e.g. on your desktop). The default folder name will probably be Adafruit_ADS1X15-master.

Rename the folder to Adafruit_ADS1X15.

In Arduino IDE, select Sketch - Import Library - Add Library. Select the Adafruit_ADS1X15 folder and click OK.

To check if the install has worked, select File - Examples - Adafruit_ADS1X15. You should see three sample sketches. Try loading and compiling one of these.

Hackscribble:
As MarkT said, looks like the library is not properly installed. Try the following ...

Download the library zip file and extract it to a folder (e.g. on your desktop). The default folder name will probably be Adafruit_ADS1X15-master.

Rename the folder to Adafruit_ADS1X15.

In Arduino IDE, select Sketch - Import Library - Add Library. Select the Adafruit_ADS1X15 folder and click OK.

To check if the install has worked, select File - Examples - Adafruit_ADS1X15. You should see three sample sketches. Try loading and compiling one of these.

That was the problem! Thank you!

Good day:

I too am having trouble with the ADS1X15 software. I downloaded the Adafruit_ADS1X15-master file, changed the folder name to Adafruit_ADS1X15, and placed it in ~/Documents/Arduino/libraries along with other libraries I use. I restarted Arduino.app and imported the library. I am trying to use an Adafruit ADS1115 ADC board with an Arduino Uno R3. My code looks like this:

======== start source ==========
#include <Adafruit_ADS1015.h>
#include <Wire.h>
Adafruit_ADS1115 ads1115(0x48); // construct an ads1115 at address 0x48

uint16_t readADC_SingleEnded(uint8_t channel);

int led = 13;
int nchars=0;

void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);

Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
ads1115.begin();
}
.....
===== end code example =====================

And when I try to verify the compile fails and the result is:

====== start compile error output =================
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:88: multiple definition of Adafruit_ADS1015::Adafruit_ADS1015(unsigned char)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:93: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:88: multiple definition of Adafruit_ADS1015::Adafruit_ADS1015(unsigned char)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:93: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1115': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:101: multiple definition of Adafruit_ADS1115::Adafruit_ADS1115(unsigned char)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:106: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1115': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:101: multiple definition of Adafruit_ADS1115::Adafruit_ADS1115(unsigned char)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:106: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::setGain(adsGain_t)': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:125: multiple definition of Adafruit_ADS1015::setGain(adsGain_t)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:130: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::getGain()': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:133: multiple definition of Adafruit_ADS1015::getGain()'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:138: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::startComparator_SingleEnded(unsigned char, int)': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:302: multiple definition of Adafruit_ADS1015::startComparator_SingleEnded(unsigned char, int)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:307: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::getLastConversionResults()': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:348: multiple definition of Adafruit_ADS1015::getLastConversionResults()'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:353: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::readADC_Differential_2_3()': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:250: multiple definition of Adafruit_ADS1015::readADC_Differential_2_3()'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:255: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::readADC_Differential_0_1()': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:199: multiple definition of Adafruit_ADS1015::readADC_Differential_0_1()'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:204: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::readADC_SingleEnded(unsigned char)': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:143: multiple definition of Adafruit_ADS1015::readADC_SingleEnded(unsigned char)'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:148: first defined here
Adafruit_ADS1X15/Adafruit_ADS1015.cpp.o: In function Adafruit_ADS1015::begin()': /Users/rmr/Documents/Arduino/libraries/Adafruit_ADS1X15/Adafruit_ADS1015.cpp:115: multiple definition of Adafruit_ADS1015::begin()'
Adafruit_ADS1015.cpp.o:Adafruit_ADS1015.cpp:120: first defined here
======= end ===================

Sorry for the volume of output. This is a Mac OS X.

I hope someone can help me. I really want to use this chip in my current project.

Michael Reynolds, PhD Oceanography
Seattle WA USA

Hi Michael

I restarted Arduino.app and imported the library.

Can you say exactly what you did to "import the library" at this step in the process?

And can you check that you only have one instance of the following statement in your full program code.

#include <Adafruit_ADS1015.h>

Thanks

Ray

Sounds like you have two copies of the library now...

Hi All,

My code now compiles without error. I upload the software to my Uno with breadboard and the loop runs fine but the output is always zero. (Code is below).
Is there any way to trouble shoot the program or chip? Vdd=5v. A0=0.2v, A1=A2+a3=0v, ADR=GND,ALRT=open.

------example output---------
Waiting...
A0: -1
A1: -1
A2: -1
A3: -1

Waiting...
A0: -1
A1: -1
A2: -1
A3: -1
----- end -----------

---- code ------------
#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads; // construct an ads1115 at address 0x48

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int nchars=0;

// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);

Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = .15mV)");
ads.begin();

ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V
}

// the loop routine runs over and over again forever:
void loop() {

int16_t adc0, adc1, adc2, adc3;

adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("A0: "); Serial.println(adc0);
Serial.print("A1: "); Serial.println(adc1);
Serial.print("A2: "); Serial.println(adc2);
Serial.print("A3: "); Serial.println(adc3);
Serial.println(" ");

digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(5000);
// Serial in/out
if ( (nchars = Serial.available()) > 0) {
Serial.print("blink, nchars = ");
Serial.println(nchars);
Serial.flush();
}
else {
Serial.println("Waiting...");
}
}
--------- end -----------------