Code: Select all
#include <Adafruit_MAX31856.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(3);
double temp=0;
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);
}
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
maxthermo.setThermocoupleType(MAX31856_TCTYPE_S);
maxthermo.setConversionMode(MAX31856_ONESHOT_NOWAIT);
}
void loop() {
maxthermo.triggerOneShot();
delay(200);
if (maxthermo.conversionComplete()) {
temp=maxthermo.readThermocoupleTemperature();
} else {
Serial.println("Conversion not complete!");
}
display.println(temp);
}
Code: Select all
display.println(temp);