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"); +} +