#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "max6675.h"
// OLED display width and height, for a 128x64 display.
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
// Initialize Adafruit SSD1306 display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Thermocouples' pins
int termoSCK1 = 9;
int termoSO1 = 10;
int termoCS1 = 11;
int termoCS2 = 6;
int termoSO2 = 5;
int termoSCK2 = 3;
int termoCS3 = 7;
int termoSO3 = 6;
int termoSCK3 = 5;
// Create MAX6675 objects for each thermocouple
MAX6675 thermocouple1(termoSCK1, termoCS1, termoSO1);
MAX6675 thermocouple2(termoSCK2, termoCS2, termoSO2);
// MAX6675 thermocouple3(termoSCK3, termoCS3, termoSO3);
void setup() {
Serial.begin(9600);
// OLED display initialization
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Check the OLED's I2C address
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
delay(1000); // Pause for 1 second
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.println(F("MAX6675"));
display.display();
delay(1000);
}
void loop() {
// Read temperatures from thermocouples
float tempC1 = thermocouple1.readCelsius();
float tempC2 = thermocouple2.readCelsius();
// float tempC3 = thermocouple3.readCelsius();
// Prepare display
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setCursor(0,0);
// Display temperatures
display.print(F("Temperature "));
display.print((char)247);
display.print(F("Celcius"));
display.setTextSize(1);
display.print(F(" A: "));
display.print(tempC1);
display.print(F(" B: "));
display.print(tempC2);
display.print(F(" C: "));
// display.print(tempC3);
display.display(); // Actually display all of the above
delay(100);
}