-
Notifications
You must be signed in to change notification settings - Fork 7
begin()
The MAX31855 library can be instantiated using either hardware SPI or software SPI. The begin() function will initialize hardware SPI when called with just one parameter, the CS pin that is used to select the device. If software SPI is desired, then begin() must be called with 3 parameters for the CS, the MISO and SCK pin numbers.
The SPI protocol generally requires 4 lines to be used:
- MISO (Master In Slave Out) - The Slave line for sending data to the master.
- MOSI (Master Out Slave In) - The Master line for sending data to the peripherals, unused by the MAX31855.
- SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master.
- CS/SS (Chip Select or Slave Select)
When using hardware SPI the MISO and SCK lines are defined by the Arduino SPI Library and are dependent upon which Arduino is being used. Only the CS pin needs to be defined in the program and it should be a digital pin.
When using software SPI all 3 lines need to be defined, the CS and SCK lines are output only while the MISO line is input.
The optional "reversed" boolean parameter can be set to "true" when the thermocouple connections have been reversed. This would normally result in the probe measurements being reversed, showing progressively lower values as the temperature goes up. The preferred solution is to correct the orientation of the thermocouple connections but this switch will also work to let the temperatures values be shown correctly.
#include <MAX31855.h> // MAX31855 Thermocouple Library
...
const uint8_t CS_PIN = 2;
MAX31855_Class thermocouple;
...
thermocouple.begin(CS_PIN);