Engduino  3.1.0
A fun device for learning coding
Files | Classes | Enumerations | Functions | Variables
Driver for Engduino Thermistor

Files

file  EngduinoThermistor.cpp
 
file  EngduinoThermistor.h
 

Classes

class  EngduinoThermistorClass
 

Enumerations

enum  temperatureUnits { CELSIUS, KELVIN, FAHRENHEIT }
 

Functions

 EngduinoThermistorClass::EngduinoThermistorClass ()
 Constructor. More...
 
void EngduinoThermistorClass::begin ()
 begin function - must be called before using other functions More...
 
void EngduinoThermistorClass::end ()
 end function - switch off the LEDs More...
 
float EngduinoThermistorClass::temperature (temperatureUnits units=CELSIUS)
 Get the temperature. More...
 
float EngduinoThermistorClass::temperature (temperatureUnits units, float B, float T0, float R0, float R_Balance)
 Get the temperature. More...
 
uint16_t EngduinoThermistorClass::temperatureRaw ()
 Get the raw potential divider reading. More...
 

Variables

EngduinoThermistorClass EngduinoThermistor = EngduinoThermistorClass()
 
EngduinoThermistorClass EngduinoThermistor
 

Detailed Description

This is the driver code for reading temperature. This can equally well be done in a sketch file, but it is also here for completeness

The Engduino has a Murata NCP18WF104J03RB thermistor attached to analogue input A5. This thermistor has a resistance of 100K at 25C.

Function Documentation

void EngduinoThermistorClass::begin ( )

begin function - must be called before using other functions

Nothing to be done.

void EngduinoThermistorClass::end ( )

end function - switch off the LEDs

Nothing to be done.

EngduinoThermistorClass::EngduinoThermistorClass ( )

Constructor.

C++ constructor for this class. Empty.

float EngduinoThermistorClass::temperature ( temperatureUnits  units = CELSIUS)

Get the temperature.

Parameters
unitsA choice between CELSIUS (default), KELVIN, or FAHRENHEIT
Returns
The temperature on the given scale.

This function makes a call to the function that actually works out what a particular resistance means.

For the Murata NCP18WF104J03RB, the thermistor has a resistance of 100K at 25C and a B value of 4250 and a 100K balance resistor.

float EngduinoThermistorClass::temperature ( temperatureUnits  units,
float  B,
float  T0,
float  R0,
float  R_Balance 
)

Get the temperature.

Parameters
unitsA choice between CELSIUS (default), KELVIN, or FAHRENHEIT
BParameter in the B equation - see data sheet
T0Temperature in Kelvin at which resistance is R0 - see data sheet
R0Resistance at temperature T0 - see data sheet
R_BalanceValue of the balance resistor in the potential divider (100K on Engduino v1.0)
Returns
The temperature on the given scale.

This function measures the voltage and, as a consequence, calculates the resistance of the thermistor. From this, we can figure out the actual temperature

NTC thermistors can be characterised with the B (or beta) parameter equation,

1/T = 1/T0 + 1/B*ln(R/R0)

Where the temperatures are in Kelvin and R0 is the resistance at temperature T0 (25 °C = 298.15 K).

So far as the resistance is concerned, we have a potential divider with a balance resistor of value R_Balance. Assuming that the resistance of the NTC is R and the voltage across it is V, then Ohms law gives: V/Vcc = R/(R + R_Balance)

Given that V/Vcc is just (analog in)/1024 for a 10 bit ADC, we can work out that: R = (R_Balance * analogIn) / (1024 - analogIn)

uint16_t EngduinoThermistorClass::temperatureRaw ( )

Get the raw potential divider reading.

Returns
Raw potential divider reading.

Raw voltage reading from NTC potential divider circuit