thermocouple

This commit is contained in:
bitscuit 2023-06-28 15:07:19 +02:00
parent 2729c13400
commit c499c458f2
1 changed files with 43 additions and 0 deletions

43
src/thermovouple.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <Arduino.h>
#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");
}