From c499c458f2cc2452e3710b6d989e856dcaf1209e Mon Sep 17 00:00:00 2001 From: bitscuit Date: Wed, 28 Jun 2023 15:07:19 +0200 Subject: [PATCH] thermocouple --- src/thermovouple.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/thermovouple.cpp diff --git a/src/thermovouple.cpp b/src/thermovouple.cpp new file mode 100644 index 0000000..ec23ee3 --- /dev/null +++ b/src/thermovouple.cpp @@ -0,0 +1,43 @@ +#include + +#define PIN_LED 13 +#define PIN_TEMP1 14 + +#define AD8495_REF 1.365f +#define AD8495_RES 0.005f + +void setup() { + /* Debug LED */ + pinMode(PIN_LED, OUTPUT); + digitalWrite(PIN_LED, 0); + + /* Analog input */ + pinMode(PIN_TEMP1, INPUT); + analogReadRes(12); + + /* Begin serial interface */ + Serial.begin(115200); +} + +void loop() { + /* Blink */ + digitalWrite(PIN_LED, 0); + delay(500); + digitalWrite(PIN_LED, 1); + delay(500); + + /* Read temperature */ + uint16_t raw = analogRead(PIN_TEMP1); + + /* Convert to degrees */ + float Vout = raw * 3.3f / 4096; + float Tmj = (Vout - AD8495_REF) / AD8495_RES; + + /* Send over serial */ + Serial.print("RAW = "); + Serial.print(raw); + Serial.print(", TEMP = "); + Serial.print(Tmj); + Serial.print("\n"); +} +