CONTROLLINO + MAX31856 temp sensor

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
gndAdafruit
 
Posts: 17
Joined: Wed Dec 29, 2021 4:00 pm

CONTROLLINO + MAX31856 temp sensor

Post by gndAdafruit »

Hi Everyone.
I am a novice using Arduino IDE and I have purchased a microcontroller/plc (CONTROLLINO) and temp sensor (adafruit MAX31856) to experiment w/sensing temperatures w/a thermocouple type K. Could I get some help with understanding what I am doing incorrect with the example code for the max31856? I only get readings of 0.0's. I am currently using software SPI andI have them connected as below:
CONTROLLINO (left) -- Adafruit_MAX31856 (right)
3v3 -- VIN
GND -- GND
SCK -- SCK
MISO -- SDO
MOSI -- SDI
/SS -- CS

This is the example code I am working with and the data sheets:
CONTROLLINO
https://www.controllino.com/wp-content/ ... Pinout.pdf
Adafruit MAX31856
https://cdn-learn.adafruit.com/download ... lifier.pdf

Code: Select all

#include <Adafruit_MAX31856.h>
#include <Controllino.h>
#include <SPI.h>

//const int SS = 19;   // chip select              -- CS port pins
//const int MOSI = 21; // serial digital input     -- SDI port pins
//const int MISO = 22;  // serial digital output   -- SDO port pins
//const int SCK = 20;  // system clock             -- SCK port pins

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(CONTROLLINO_PIN_HEADER_SS, CONTROLLINO_PIN_HEADER_MOSI, CONTROLLINO_PIN_HEADER_MISO, CONTROLLINO_PIN_HEADER_SCK);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(CONTROLLINO_PIN_HEADER_SS);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(100);
  Serial.println("MAX31856 thermocouple test");

  if (!maxthermo.begin()) {
    Serial.println("Could not initialize thermocouple.");
    while (1) delay(10);
  }

  maxthermo.begin();
  maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);

  Serial.print("Thermocouple type: ");
  switch (maxthermo.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
    case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
    case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
    case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
    case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
    case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
    case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
    case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
    case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
    case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
    default: Serial.println("Unknown"); break;
  }
}

void loop() {
//  Serial.print("CS Pin: ");
//  Serial.println(CONTROLLINO_PIN_HEADER_SS);
//  Serial.print("SDO Pin: ");
//  Serial.println(CONTROLLINO_PIN_HEADER_MISO);
//  Serial.print("SDI Pin: ");
//  Serial.println(CONTROLLINO_PIN_HEADER_MOSI);
//  Serial.print("SCK Pin: ");
//  Serial.println(CONTROLLINO_PIN_HEADER_SCK);
  Serial.print("Cold Junction Temp: ");
  Serial.println(maxthermo.readCJTemperature());
  Serial.print("Thermocouple Temp: ");
  Serial.println(maxthermo.readThermocoupleTemperature());
  delay(1000);
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”