ESP32 ADS1015 No such file or directory

I am trying to connect ESP32 dev kit with ADS1115. I am following below links
https://microcontrollerslab.com/ads1115-external-adc-with-esp32/

When I compile code I am getting error "I2C_ADDRESS:2:30: error: Adafruit_ADS1015.h: No such file or directory" but I have installed it

Please post the full sketch and the full error messages (use the "Copy error messages" button), using code tags when you post them

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

Adafruit_ADS1115 ads(0x48);
float Voltage = 0.0;

void setup(void) 
{
Serial.begin(9600); 
ads.begin();
}

void loop(void) 
{
int16_t adc0;

adc0 = ads.readADC_SingleEnded(0);
Voltage = (adc0 * 0.1875)/1000;

Serial.print("AIN0: "); 
Serial.print(adc0);
Serial.print("\tVoltage: ");
Serial.println(Voltage, 7); 
Serial.println();

delay(1000);
}`

error message


I2C_ADDRESS:2:30: error: Adafruit_ADS1015.h: No such file or directory

compilation terminated.

exit status 1
Adafruit_ADS1015.h: No such file or directory


Did you copy the error message using the "Copy error message" button in the IDE ?

Where exactly is the Adafruit_ADS1015.h file located on your PC ?

C:\Users\System\Documents\Arduino
C:\Users\System\Documents\Arduino\I2C_ADDRESS
C:\Users\System\Documents\Arduino\libraries

I2C_ADDRESS:2:30: error: Adafruit_ADS1015.h: No such file or directory

compilation terminated.

exit status 1
Adafruit_ADS1015.h: No such file or directory

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


1 Like

Could it be as simple as

#include <Adafruit_ADS1015.h>

should be

#include <Adafruit_ADS1X15.h>

?

When I replace line #include <Adafruit_ADS1015.h> by #include <Adafruit_ADS1X15.h>

error message

Arduino: 1.8.11 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

I2C_ADDRESS:4:26: error: no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'

 Adafruit_ADS1115 ads(0x48);

                          ^

In file included from C:\Users\System\Documents\Arduino\I2C_ADDRESS\I2C_ADDRESS.ino:2:0:

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note: candidate: Adafruit_ADS1115::Adafruit_ADS1115()

   Adafruit_ADS1115();

   ^

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:186:3: note:   candidate expects 0 arguments, 1 provided

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(const Adafruit_ADS1115&)

 class Adafruit_ADS1115 : public Adafruit_ADS1X15 {

       ^

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note:   no known conversion for argument 1 from 'int' to 'const Adafruit_ADS1115&'

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note: candidate: constexpr Adafruit_ADS1115::Adafruit_ADS1115(Adafruit_ADS1115&&)

C:\Users\System\Documents\Arduino\libraries\Adafruit_ADS1X15/Adafruit_ADS1X15.h:184:7: note:   no known conversion for argument 1 from 'int' to 'Adafruit_ADS1115&&'

exit status 1
no matching function for call to 'Adafruit_ADS1115::Adafruit_ADS1115(int)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please post a link to where you downloaded this "I2C_ADDRESS" sketch from.

I have given that link in my first post
https://microcontrollerslab.com/ads1115-external-adc-with-esp32/

OK, great. I can see from the tutorial that they were using version 1.0.0 of the "Adafruit ADS1X15" library. There was a breaking change to the library since then, which is the cause of the error.

The easiest fix is to use the old version of the library. Even though the tutorial author wrote the sketch for 1.0.0 of the library, you should be able to use up to version 1.1.2, which was the last release before the bump to 2.0.0 (the major version bump is used to indicate a breaking change).
Please try this:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.
  2. Wait for the update to finish.
  3. In the "Filter your search" field, type "Adafruit ADS1X15".
  4. Press Enter.
  5. Scroll down through the list of libraries until you see the "Adafruit ADS1X15" library. Click on it.
  6. From the dropdown version menu, select "1.1.2".
  7. Click the Update button.
  8. Wait for the installation to finish.
  9. Click the Close button.

Now try compiling the sketch again.

1 Like

Try changing

Adafruit_ADS1115 ads(0x48);

to

Adafruit_ADS1115 ads;

Yeah, updating the sketch to work with the modern library is the ideal solution because there might have been valuable improvements or bug fixes made to the library since the 1.1.2 release.

But if you just want the quick fix then using the library version the sketch was written for should do the trick.

1 Like

I get following message after compiling the sketch

Sketch uses 214110 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 14144 bytes (4%) of dynamic memory, leaving 313536 bytes for local variables. Maximum is 327680 bytes.
````Preformatted text`

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

Adafruit_ADS1115 ads;
float Voltage = 0.0;

void setup(void)
{
Serial.begin(9600);
ads.begin();
}

void loop(void)
{
int16_t adc0;

adc0 = ads.readADC_SingleEnded(0);
Voltage = (adc0 * 0.1875)/1000;

Serial.print("AIN0: ");
Serial.print(adc0);
Serial.print("\tVoltage: ");
Serial.println(Voltage, 7);
Serial.println();

delay(1000);
}

That's the output from a successful compilation. Congratulations!

Now it's time to upload it to your Arduino board and try it out.

1 Like

Thanks Now sketch has been compiled and uploaded but output is not showing on serail terminal. A0 connected to POT

This line of the sketch configures the Arduino board to communicate over serial at 9600 baud:

But you have the Arduino IDE Serial Monitor configured for communication at 115200 baud. This will cause the communication from the Arduino to not be recognized by Serial Monitor. Select "9600" from the baud rate menu near the bottom right corner of the Serial Monitor window.

Thank you very much in0, Finally Problem has been solved

Or, better yet:

Serial.begin(115200); 
1 Like

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