Very simple library for reading temperature from NTC thermistors

Dependents:   lightweight-weather-station

Embed: (wiki syntax)

« Back to documentation index

Thermistor Class Reference

Thermistor Class Reference

Measuring temperature with thermistor. More...

#include <thermistor.h>

Public Member Functions

 Thermistor (PinName thermistorpin, int nominalres, int beta, int seriesresistor)
float temperature ()
float resistance ()

Detailed Description

Measuring temperature with thermistor.

Example of use:

 #include "mbed.h"
 #include "thermistor.h"

 Serial pc(USBTX, USBRX); // serial communication

 int main() {
     Thermistor my_thermistor(A5, 10000, 3950, 4700); // instantiate the sensor object (on pin A5, nominal resistance is 10kOhms, beta coefficient is 3950 and value of the sacond resistor is 4,7kOhms
     while(1) {
         pc.printf("Temperature: %5.1f celsius degrees\r", my_thermistor.temperature());
         pc.printf("Resistance: %5.1f ohms\r", my_thermistor.resistance());
         wait_ms(1000);
     }
 }

Definition at line 20 of file thermistor.h.


Constructor & Destructor Documentation

Thermistor ( PinName  thermistorpin,
int  nominalres,
int  beta,
int  seriesresistor 
)
Parameters:
thermistorpinmbed analog pin to which the thermistor is connected to
nominalresresistance of thermistor at 25 celsius degrees
betabeta coefficient of thermistor
seriesresistorvalue of the resistor connecter with thermistor

Definition at line 4 of file thermistor.cpp.


Member Function Documentation

float resistance (  )
Returns:
resistance of thermistor

Definition at line 31 of file thermistor.cpp.

float temperature (  )
Returns:
temperature in celsius degrees

Definition at line 26 of file thermistor.cpp.