-
Notifications
You must be signed in to change notification settings - Fork 12
/
SerialReading.ino
45 lines (35 loc) · 1.12 KB
/
SerialReading.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Average Thermocouple
Reads a temperature from a thermocouple based
on the MAX6675 driver and displays it in the default Serial.
https://github.com/YuriiSalimov/MAX6675_Thermocouple
Created by Yurii Salimov, May, 2019.
Released into the public domain.
*/
#include <Thermocouple.h>
#include <MAX6675_Thermocouple.h>
#define SCK_PIN 3
#define CS_PIN 4
#define SO_PIN 5
Thermocouple* thermocouple;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN);
}
// the loop function runs over and over again forever
void loop() {
// Reads temperature
const double celsius = thermocouple->readCelsius();
const double kelvin = thermocouple->readKelvin();
const double fahrenheit = thermocouple->readFahrenheit();
// Output of information
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.print(" C, ");
Serial.print(kelvin);
Serial.print(" K, ");
Serial.print(fahrenheit);
Serial.println(" F");
delay(500); // optionally, only to delay the output of information in the example.
}