Blame | Last modification | View Log | RSS feed
#include <SPI.h>
#include <Adafruit_MAX31865.h>
#define RREF 430.0
#define RNOMINAL 100.0
Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13);
int pinOut1 = 2;
int pinOut2 = 4;
int state1;
int state2;
void setup() {
pinMode(pinOut1,OUTPUT);
pinMode(pinOut2,OUTPUT);
digitalWrite(pinOut1, HIGH);
digitalWrite(pinOut2, HIGH);
Serial.begin(115200);
//Serial.println("Temperature");
max.begin(MAX31865_4WIRE);
}
void loop() {
char incomingByte;
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
if (incomingByte == 0){
digitalWrite(pinOut1, HIGH);
digitalWrite(pinOut2, HIGH);
//Serial.println("low");
}
else {
digitalWrite(pinOut1, LOW);
digitalWrite(pinOut2, LOW);
//Serial.println("High");
}
}
uint16_t rtd = max.readRTD();
float t = max.temperature(RNOMINAL, RREF);
state1 = digitalRead(pinOut1);
state2 = digitalRead(pinOut2);
/*
Serial.print("RTD value: "); Serial.println(rtd);
float ratio = rtd;
ratio /= 32768;
Serial.print("Ratio = "); Serial.println(ratio,8);
Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
Serial.print("Temperature = "); Serial.println(max.temperature(RNOMINAL, RREF));
// Preveri in vrne vrednost napak
uint8_t fault = max.readFault();
if(fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (fault & MAX31865_FAULT_HIGHTHRESH) {
Serial.println("RTD High Threshold");
}
if (fault & MAX31865_FAULT_LOWTHRESH) {
Serial.println("RTD Low Threshold");
}
if (fault & MAX31865_FAULT_REFINHIGH) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_RTDINLOW) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (fault & MAX31865_FAULT_OVUV) {
Serial.println("Under/over voltage");
}
max.clearFault();
}
*/
Serial.print(t);
Serial.print(" ");
Serial.print(state1);
Serial.print(" ");
Serial.println(state2);
//Serial.println();
delay(1000);
}