Advertisement
AstraLET

Untitled

Feb 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. // Default connection is using software SPI, but comment and uncomment one of
  2. // the two examples below to switch between software SPI and hardware SPI:
  3.  
  4. // Example creating a thermocouple instance with software SPI on any three
  5. // digital IO pins.
  6. int thermoCLK = 11;
  7. int thermoCS = 12;
  8. int thermoDO = 13;
  9.  
  10. // initialize the Thermocouple
  11. Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
  12.  
  13. // Example creating a thermocouple instance with hardware SPI
  14. // on a given CS pin.
  15. //#define MAXCS 10
  16. //Adafruit_MAX31855 thermocouple(MAXCS);
  17.  
  18. void setup() {
  19. while (!Serial); // wait for Serial on Leonardo/Zero, etc
  20.  
  21. Serial.begin(9600);
  22.  
  23. Serial.println("MAX31855 test");
  24. // wait for MAX chip to stabilize
  25. delay(500);
  26. }
  27.  
  28. void loop() {
  29. // basic readout test, just print the current temp
  30. Serial.print("Internal Temp = ");
  31. Serial.println(thermocouple.readInternal());
  32.  
  33. double c = thermocouple.readCelsius();
  34. if (isnan(c)) {
  35. Serial.println("Something wrong with thermocouple!");
  36. } else {
  37. Serial.print("C = ");
  38. Serial.println(c);
  39. }
  40. //Serial.print("F = ");
  41. //Serial.println(thermocouple.readFarenheit());
  42.  
  43. delay(1000);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement