thermocouple
This commit is contained in:
parent
2729c13400
commit
c499c458f2
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue