Adafruit MAX31856 - Unexpected behaviour in Serial Output

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
hughestu
 
Posts: 3
Joined: Thu Dec 16, 2021 5:04 pm

Adafruit MAX31856 - Unexpected behaviour in Serial Output

Post by hughestu »

I am using a Mega2560 and my goal is to obtain temperature measurements with a T-Type thermocouple using the MAX31856 breakout board. I have the pins setup for an SPI connection using the pinouts described here (scroll down to the second table). Here are the connections on my end:
PinsAdaQ.JPG
PinsAdaQ.JPG (95.48 KiB) Viewed 233 times
That is:
50 - Yellow - SDO/MISO
51 - Green - SDI/MOSI
52 - Orange - SCK
53 - Blue - CS/SS

I downloaded the Adafruit MAX31856 library along with the Adafruit BusIO dependency using the package manager on Arduino IDE. Following that, I used the example "max31856_manual" from the MAX31856 library. Here is a shortened version of the example which I am currently using:

Code: Select all

// This example demonstrates doing a one-shot measurement "manually".
// Separate calls are made to trigger the conversion and then check
// for conversion complete. While this typically only takes a couple
// 100 milliseconds, that times is made available by separating these
// two steps.

#include <Adafruit_MAX31856.h>

// use hardware SPI, just pass in the CS pin
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(53);

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

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

  maxthermo.setThermocoupleType(MAX31856_TCTYPE_T);
  Serial.println("T Type"); 
  
  maxthermo.setConversionMode(MAX31856_ONESHOT_NOWAIT);
}

void loop() {
  // trigger a conversion, returns immediately
  maxthermo.triggerOneShot();
  delay(500);

  // check for conversion complete and read temperature
  if (maxthermo.conversionComplete()) {
    Serial.println(maxthermo.readThermocoupleTemperature());
  } else {
    Serial.println("Conversion not complete!");
  }
}
However, upon running the code, I received the following outputs in the serial monitor:
SerialMonitorAdaQ.JPG
SerialMonitorAdaQ.JPG (43.56 KiB) Viewed 233 times
I did a simple test by touching the sensor to see that it responded ... which it did (from 21.39 to 32.07). Ok, so it seems to be working somewhat, however here's the problem: the outputs before the last output line were there before I opened the serial monitor and every output after is converted to some other format. So my procedure was to (a) let the sensor run for a bit after "Done Uploading", (b) touch it to raise the temperature, then (c) open the serial monitor. Following that, it started printing characters such as backward question-marks and boxes. Does anyone know why this happens or how to fix this problem?

If it helps I'm using Arduino IDE v1.8.18 on Windows 10

User avatar
rpiloverbd
 
Posts: 198
Joined: Mon Nov 29, 2021 8:13 am

Re: Adafruit MAX31856 - Unexpected behaviour in Serial Outpu

Post by rpiloverbd »

Hello, kindly change the baud rate. In your code, your baud rate is 115200. In your screenshot of the serial monitor, I can see it is 9600. Please change it to 115200.

User avatar
hughestu
 
Posts: 3
Joined: Thu Dec 16, 2021 5:04 pm

Re: Adafruit MAX31856 - Unexpected behaviour in Serial Outpu

Post by hughestu »

Oh ok, that makes sense...I hoped it would be something simple like that. Thanks a mill!

User avatar
rpiloverbd
 
Posts: 198
Joined: Mon Nov 29, 2021 8:13 am

Re: Adafruit MAX31856 - Unexpected behaviour in Serial Outpu

Post by rpiloverbd »

You're welcome. Please make the change and see if your get your desired result.

User avatar
hughestu
 
Posts: 3
Joined: Thu Dec 16, 2021 5:04 pm

Re: Adafruit MAX31856 - Unexpected behaviour in Serial Outpu

Post by hughestu »

I have it working now, thanks. The problem was the baud rate as you mentioned.

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

Return to “Arduino”