thermometerMaxThermo allows you easily interact with various thermocouple-to-digital converters, thermometer and thermostats, so you can read or log temperature data (and for some devices, set the target temperature as well).  The library currently supports Max31855 and Max6675 devices, through SPI on Arduino/AVR microcontrollers, and the DS7505 digital thermometer/thermostat (through I2C) .

Using MaxThermo will add about 3k to your program’s footprint in simple cases, up to 4-5k if using fancy features (mostly logging related).

Related Pages


Simple Usage

The full MaxThermo API description is available but if all you’re interested in is getting temperature readings, the library is little more than:

// include the lib
#include <MaxThermo.h>

// chip_select_pin -- pin that goes to chip select/enable
#define chip_select_pin        5

// chip_clock_pin -- pin that goes to chip SPI clock
#define chip_clock_pin          10

// chip_serial_in_pin -- pin connected to device serial output
#define chip_serial_in_pin      9

// create the device
MaxThermo::Max31855 myTDC(chip_select_pin, chip_clock_pin, chip_serial_in_pin);
// in case you have an older Max6755, it's simply
// MaxThermo::Max6755 myTDC(chip_select_pin, chip_clock_pin, chip_serial_in_pin);

// at some point (normally in setup() for Arduino's
myTDC.begin(); // set everything up, connect through SPI, etc.

// later... get a fresh reading from device
if (myTDC.update() == MaxThermo::Status::OK)
   // do something with myTDC.thermoTemp()
} else {
   // we have some kind of error, check myTDC.status() or 
   // use one of the convenience methods like circuitOpen()

and that’s pretty much it!  See the TempMonitor example for more details on simple use cases.  All supported devices will handle thermocouple related temperature functions, which you may access after calling update():

myTDC.thermoTempIsNegative(); // will return true if the temp is sub-zero (celcius)
myTDC.thermoTempAsInt(); // the integer temperature -- more efficient if 
                         // you don't need the fractional temp
myTDC.thermoTemp(); // as above, returns the real temperature value.

// shortcuts are available without the "thermo" qualifier


Additional Functionality

For devices that support it, like the Max31855, you may access additional data using the internal* family using the same naming convention as above for the thermocouple:


Logging Features

The library has a few features that allow you to collect and analyze groups of samples.  In essence, you create an array to hold the data, and inform the device that you wish to log update()s to the list.  The call to update() will inform you when the log (array) is full, and you can then access each of the samples or use convenience methods to perform some basic analysis.  The TempLogger example has more info, but it basically boils down to:

// create the device as demonstrated above...

// how many samples?  In the example program, the mega328's limited RAM manages
// to handle up to about 250 samples:
#define num_samples_to_log        180

// actually create the storage space, using the appropriate SampleLog type 
MaxThermo::Max31855::SampleLog the_samples[num_samples_to_log];

// when it's time to start logging:
myTDC.startLoggingTo(the_samples, num_samples_to_log);

// from this point on, each call to update() will log the result in the_samples.  You need to 
// keep an eye on the return values from update() to know when the log is full:

if (myTDC.update() == MaxThermo::Status::LogFull)
    // ok, we're done logging--tell the lib we know we're done:

    // do whatever you wanted to do with the_samples (see the example)
    // here you can access individual samples in the log with getSample() 
    // and get some global info with logSummary()
} else if (myTDC.isOK())
    if (myTDC.isLogging())
        // we're still filling the sample log
        // ...
    } else {
        // logging is done, do whatever you need with the te
} else {
    // some kind of issue with the thermocouple...

Have a look at the examples and the full API description. There are also some device specific details you may want to check out.

More MaxThermo information: [subpages]



Leave a Reply