Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
311 f9daq 1
#include <SPI.h>
2
#include <Adafruit_MAX31865.h>
3
 
4
#define RREF 430.0
5
#define RNOMINAL 100.0
6
 
7
Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13);
8
int pinOut1 = 2;
9
int pinOut2 = 4;
10
int state1;
11
int state2;
12
void setup() {
13
  pinMode(pinOut1,OUTPUT);
14
  pinMode(pinOut2,OUTPUT);
15
  digitalWrite(pinOut1, HIGH);
16
  digitalWrite(pinOut2, HIGH);
17
  Serial.begin(115200);
18
  //Serial.println("Temperature");
19
 
20
  max.begin(MAX31865_4WIRE);
21
 
22
 
23
}
24
 
25
void loop() {
26
   char incomingByte;
27
   if (Serial.available() > 0) {
28
    // read the incoming byte:
29
    incomingByte = Serial.read();
30
 
31
    // say what you got:
32
    if (incomingByte == 0){
33
      digitalWrite(pinOut1, HIGH);
34
      digitalWrite(pinOut2, HIGH);
35
      //Serial.println("low");
36
    }
37
      else {
38
      digitalWrite(pinOut1, LOW);
39
      digitalWrite(pinOut2, LOW);
40
      //Serial.println("High");
41
    }
42
  }
43
 
44
  uint16_t rtd = max.readRTD();                                                                                                                             
45
  float t = max.temperature(RNOMINAL, RREF);
46
  state1 = digitalRead(pinOut1);
47
  state2 = digitalRead(pinOut2);
48
 
49
/*
50
  Serial.print("RTD value: "); Serial.println(rtd);
51
  float ratio = rtd;
52
  ratio /= 32768;
53
  Serial.print("Ratio = "); Serial.println(ratio,8);
54
  Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
55
  Serial.print("Temperature = "); Serial.println(max.temperature(RNOMINAL, RREF));
56
 
57
  // Preveri in vrne vrednost napak
58
  uint8_t fault = max.readFault();
59
    if(fault) {
60
      Serial.print("Fault 0x"); Serial.println(fault, HEX);
61
      if (fault & MAX31865_FAULT_HIGHTHRESH) {
62
        Serial.println("RTD High Threshold");
63
      }
64
        if (fault & MAX31865_FAULT_LOWTHRESH) {
65
          Serial.println("RTD Low Threshold");
66
          }
67
           if (fault & MAX31865_FAULT_REFINHIGH) {
68
            Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
69
            }
70
              if (fault & MAX31865_FAULT_RTDINLOW) {
71
                Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
72
                }
73
                  if (fault & MAX31865_FAULT_OVUV) {
74
                    Serial.println("Under/over voltage");
75
                    }
76
         max.clearFault();
77
        }
78
  */
79
 Serial.print(t);
80
 Serial.print(" ");
81
 Serial.print(state1);
82
 Serial.print(" ");
83
 Serial.println(state2);
84
 //Serial.println();
85
 delay(1000);
86
}