From 939136867bf74fa569f51d495425898b15e8a8f0 Mon Sep 17 00:00:00 2001 From: RobTillaart Date: Wed, 31 Jul 2019 22:38:29 +0200 Subject: [PATCH] example how to use new status functions --- .../max31855_test_error.ino | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 libraries/MAX31855/examples/max31855_test_error/max31855_test_error.ino diff --git a/libraries/MAX31855/examples/max31855_test_error/max31855_test_error.ino b/libraries/MAX31855/examples/max31855_test_error/max31855_test_error.ino new file mode 100644 index 00000000..1d7dc0dc --- /dev/null +++ b/libraries/MAX31855/examples/max31855_test_error/max31855_test_error.ino @@ -0,0 +1,54 @@ +// +// FILE: max31855_test_error.ino +// AUTHOR: Rob Tillaart +// VERSION: 0.1.0 +// PURPOSE: thermocouple lib inline tests +// DATE: 2019-07-31 +// URL: http://forum.arduino.cc/index.php?topic=208061 +// +// Released to the public domain +// + +#include "MAX31855.h" + +const int doPin = 7; +const int csPin = 6; +const int clPin = 5; + +MAX31855 tc(clPin, csPin, doPin); + +void setup() +{ + Serial.begin(115200); + Serial.print("Start max31855_demo0: "); + Serial.println(MAX31855_VERSION); + Serial.println(); + + tc.begin(); +} + +void loop() +{ + int status = tc.read(); + Serial.print("stat:\t\t"); + Serial.println(status); + + if (tc.statusError()) + { + Serial.print("error:\t\t"); + if (tc.shortToGND()) Serial.println("SHORT TO GROUND"); + if (tc.shortToVCC()) Serial.println("SHORT TO VCC"); + if (tc.openCircuit()) Serial.println("OPEN CIRCUIT"); + } + + float internal = tc.getInternal(); + Serial.print("internal:\t"); + Serial.println(internal, 3); + + float temp = tc.getTemperature(); + Serial.print("temperature:\t"); + Serial.println(temp, 2); + delay(1000); +} + +// END OF FILE \ No newline at end of file