Measuring temperature with a thermistor 10k

Hi,

I have a thermistor 10k
using 3.3v

i’m testing the sample code of thermistor-library but when I click verify to build bin file I receive this errors:
I don’t understand this errors and can’t find a solution.

////////////
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from thermistor-library/thermistor-library.h:2,
from example.cpp:1:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
example.cpp: In function 'void loop()':
example.cpp:25:37: error: no matching function for call to 'Thermistor::getTempC()'

^
example.cpp:25:37: note: candidate is:
In file included from example.cpp:1:0:
thermistor-library/thermistor-library.h:18:9: note: float Thermistor::getTempC(bool)
float getTempC(bool smooth);
^
thermistor-library/thermistor-library.h:18:9: note: candidate expects 1 argument, 0 provided
make: *** [example.o] Error 1

Error: Could not compile. Please review your code.
///////////

full code:

    #include "thermistor-library/thermistor-library.h"
    
    // Analog pin the thermistor is connected to
    int thermPin = A1;
    
    // Voltage divider resistor value
    int thermRes = 10000;
    
    // Configure the Thermistor class
    Thermistor Thermistor(thermPin, thermRes);
    
    
    void setup() {
    	// Start Serial output
    	Serial.begin(9600);
    
    	// Initialize the Thermistor class
    	Thermistor.begin();
    }
    
    
    void loop() {
   
    	// Print temperature in degrees Celsius
    	Serial.print("Celsius: ");
    	Serial.println(Thermistor.getTempC());
    
    	// Wait 1 second
    	delay(1000);
    }

@wgbartley contributed this so he might have some idea :wink:

The error message is quite explicit

You have to provide a bool as parameter for getTemp(), you don't provide any parameter.


Sure, the sample should run out the box, but some minimum understanding of the matter might be required still.

I wrote that earlier but seems like in the .cpp file there’s a default argument but of course, adding the argument when calling should resolve the issue :wink:

The default parameter needs to be set in the header file in order to be known in the including program.

In a closed source library you would only have the header file and you (the user) wouldn’t know anything about the default parameter either.

PR sent: https://github.com/wgbartley/spark-thermistor-library/pull/1

2 Likes

PR merged!

Thanks @kennethlimcp!!!

2 Likes

Awesome! @rbbahia, once the new version is reimported to Web IDE, it should work without a default arguement :wink:

Hi,

I tried now bute get this error:

n file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from thermistor-library/thermistor-library.h:2,
from example.cpp:1:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
example.cpp: In function 'void loop()':
example.cpp:25:37: error: no matching function for call to 'Thermistor::getTempC()'

^
example.cpp:25:37: note: candidate is:
In file included from example.cpp:1:0:
thermistor-library/thermistor-library.h:18:9: note: float Thermistor::getTempC(bool)
float getTempC(bool smooth);
^
thermistor-library/thermistor-library.h:18:9: note: candidate expects 1 argument, 0 provided
make: *** [example.o] Error 1

Either you do what @kennethlimcp said, or what I said earlier (before the new version)

It's exactly the same error as the one I've explained above already!