B4R Question Adafruit_ADS1015 automatically deleted from sketch folder

Hans- Joachim Krahe

Active Member
Licensed User
Longtime User
hi, I try to #include <Adafruit_ADS1015.h> //"Adafruit_ADS1015.h" . Does anyone know, what's wrong? ?

--------------------------------------
Erel:
1. You have posted this thread in B4R Libraries forum. Only actual libraries should be posted there.
----done

2. Never add files to the internal libraries folder unless the instructions specifically say so.
----never will do again

3. The internal libraries folder is not searched for anything during compilation.
---- understood

You can install the library with Arduino IDE and change the include command to use <Adafruit_ADS1015.h> instead of "Adafruit_ADS1015.h" or include the files inside the folder of one of the already referenced libraries. This way it will be copied to the project folder during compilation.
/Erel


-----------------------------------
I installed Adafruit ADS1X15 in Arduino IDE

I changed the include command to use <Adafruit_ADS1015.h> instead of "Adafruit_ADS1015.h"

I cleaned the project.

I copied Adafruit_ADS1015.h and Adafruit_ADS1015.cpp to the Rwire folder in additional library, which is used too in sketch

result:


Adafruit_ADS1015.h and Adafruit_ADS1015.cpp NOT copied to sketch folder.

? ... what todo or tobe?

by the way, after installing Adafruit ADS 1X15 to IDE, it is not shown in Arduino libraries - is there another folder too?
 

janderkan

Well-Known Member
Licensed User
Longtime User
I think that you need to understand how B4R works.
I hope more people will help me to explain.

In B4R you can only use B4R libraries.
A B4R library can build on an Arduino library.
The creator of a B4R library must explain how to install the C files or include them in the library.
In this example someone has wrapped an Arduino library to be used in B4R.

If you use Arduino to install a library, it will not be available in B4R.
But if it is installed by Arduino you can use inline C to use it.
In this example you install Narcoleptic in Arduino and use inline C.

Jan
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here is what I did:
1. Installed the mentioned library with Arduino IDE.
2. I've opened Arduino libraries folder to see what was actually installed:


The file name is different than what you wrote.

3. I've added a reference to this header file with:
B4X:
#if C
#include <Adafruit_ADS1X15.h>
#End If

It compiles.
 
Upvote 0

Hans- Joachim Krahe

Active Member
Licensed User
Longtime User
... hm, I had changed the Arduino libraryfolder adress. Set it back to Documents/Arduino and it works. But was missing Adafruit_i2c then. I installed Adafruit IObus then and got errors:

"E:\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp: In member function 'void Adafruit_SPIDevice::transfer(uint8_t*, size_t)':
E:\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp:133:31: error: no matching function for call to 'SPIClass::transfer(uint8_t*&, size_t&)'
_spi->transfer(buffer, len);
^
E:\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp:133:31: note: candidate is:
In file included from E:\Documents\Arduino\libraries\Adafruit_BusIO/Adafruit_SPIDevice.h:1:0,
from E:\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp:1:
C:\Users\Krahe64\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\SPI/SPI.h:65:11: note: uint8_t SPIClass::transfer(uint8_t)
uint8_t transfer(uint8_t data);
^
C:\Users\Krahe64\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\SPI/SPI.h:65:11: note: candidate expects 1 argument, 2 provided
exit status 1"

is there another library that works?
 
Upvote 0

Hans- Joachim Krahe

Active Member
Licensed User
Longtime User
arduino example from github makes same error. Seems to be incompatibility between latest libs adafruit_ADS1X15 and adafruit_busIO..? ?



C++:
#include <Adafruit_ADS1X15.h>

//Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use this for the 12-bit version */

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Hello!");
 
  Serial.println("Getting single-ended readings from AIN0..3");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
 
  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV
 
  ads.begin();
}

void loop(void)
{
  int16_t adc0, adc1, adc2, adc3;
  float volts0, volts1, volts2, volts3;

  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);

  volts0 = ads.computeVolts(adc0);
  volts1 = ads.computeVolts(adc1);
  volts2 = ads.computeVolts(adc2);
  volts3 = ads.computeVolts(adc3);

  Serial.println("-----------------------------------------------------------");
  Serial.print("AIN0: "); Serial.print(adc0); Serial.print("  "); Serial.print(volts0); Serial.println("V");
  Serial.print("AIN1: "); Serial.print(adc1); Serial.print("  "); Serial.print(volts1); Serial.println("V");
  Serial.print("AIN2: "); Serial.print(adc2); Serial.print("  "); Serial.print(volts2); Serial.println("V");
  Serial.print("AIN3: "); Serial.print(adc3); Serial.print("  "); Serial.print(volts3); Serial.println("V");

  delay(1000);
}
?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…