Help with compile error

Fluxanode

Well-known member
this program compiled and ran just fine and now it won't and is giving these errors:
D:\ChuckW\Arduino\Projects\Ads1118\Ads1118.ino:19:19: error: no matching function for call to 'ADS1118::ADS1118(int)'
19 | ADS1118 ads1118(CS);
| ^
In file included from D:\ChuckW\Arduino\Projects\Ads1118\Ads1118.ino:1:
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: candidate: 'ADS1118::ADS1118()'
38 | class ADS1118 {
| ^~~~~~~
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: candidate expects 0 arguments, 1 provided
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: candidate: 'constexpr ADS1118::ADS1118(const ADS1118&)'
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: no known conversion for argument 1 from 'int' to 'const ADS1118&'
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: candidate: 'constexpr ADS1118::ADS1118(ADS1118&&)'
d:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library/ADS1118.h:38:7: note: no known conversion for argument 1 from 'int' to 'ADS1118&&'

Using library ADS1118 library at version 1.0.3 in folder: D:\ChuckW\Arduino\Projects\New BB files\libraries\ADS1118_library
Using library SPI at version 1.0 in folder: C:\Users\ChuckW\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.60.3\libraries\SPI
exit status 1

Compilation error: no matching function for call to 'ADS1118::ADS1118(int)'
and i can't figure out what changed???
Teensy 4.1 on windows 10 with Arduino 2.3.4, I have confirmed the library is installed but apparently something is missing

Any help appreciated really appreciated.



C:
/**
*  Basic Example for Arduino Library for Texas Instruments ADS1118 - 16-Bit Analog-to-Digital Converter with
*  Internal Reference and Temperature Sensor
*
*  @author Alvaro Salazar <alvaro@denkitronik.com>
*  http://www.denkitronik.com
*
*/

#include "ADS1118.h"
#include <SPI.h>

//Definition of the Arduino pin to be used as the chip select pin (SPI CS pin). Example: pin 5
#define CS 10

//Creating an ADS1118 object (object's name is ads1118)
ADS1118 ads1118(CS);


void setup(){
    Serial.begin(9600);
    ads1118.begin(); //Initialize the ADS1118. Default setting: PULLUP RESISTOR, ADC MODE, RATE 8SPS, SINGLE SHOT, ±0.256V, DIFFERENTIAL AIN0-AIN1

    /* Changing the sampling rate. RATE_8SPS, RATE_16SPS, RATE_32SPS, RATE_64SPS, RATE_128SPS, RATE_250SPS, RATE_475SPS, RATE_860SPS*/
    ads1118.setSamplingRate(ads1118.RATE_8SPS);

    /* Changing the input selected. Differential inputs: DIFF_0_1, DIFF_0_3, DIFF_1_3, DIFF_2_3. Single ended input: AIN_0, AIN_1, AIN_2, AIN_3*/
    ads1118.setInputSelected(ads1118.AIN_0);

    /* Changing the full scale range.
     *  FSR_6144 (±6.144V)*, FSR_4096(±4.096V)*, FSR_2048(±2.048V), FSR_1024(±1.024V), FSR_0512(±0.512V), FSR_0256(±0.256V).
     *  (*) No more than VDD + 0.3 V must be applied to this device.
     */
    ads1118.setFullScaleRange(ads1118.FSR_2048);
}

void loop(){
  delay(50);
   // Serial.println(String(ads1118.getTemperature(),1)+" C"); //Getting temperature of the internal sensor
    Serial.println(String(ads1118.getTemperature() * 9.0 / 5.0 + 32.0, 1) + " F"); // Getting temperature in Fahrenheit

    Serial.println(String(ads1118.getMilliVolts(),2)+"mV"); //Getting millivolts measured in the input selected
    delay(1000); //You can use a delay to save power. The ADS1118 will be in power down state during all the delay time. (Optional)
}
 
Your root sketch folder seems to be:

D:\ChuckW\Arduino\Projects\

but your libraries are one level below that:

D:\ChuckW\Arduino\Projects\New BB files\libraries\

Maybe Arduino searches until it finds a libraries folder, but I've always had my libraries folder in my sketches folder. In your case, that would be:

D:\ChuckW\Arduino\Projects\libraries\
 
Compilation error: no matching function for call to 'ADS1118::ADS1118(int)'
and i can't figure out what changed???

Did this ADS1118 library ever work? Looks like this library lacks support for specifying the CS pin when used with anything other than AVR and ESP32... which is really sad since it ought to be possible on all boards. Looking deeper in the code, it seems the author made it non-functional for all other boards. Very disappointing design. :(

To make this work, you'll probably need to edit the library code in many places. Fortunately the edits should be pretty simple. Everywhere you find "defined(ESP32)" change it to "defined(ESP32) || defined(TEENSYDUINO)".
 
Back
Top