Sample host software for the Maxim Integrated MAX31875 Low Power Small Package Temperature Sensor. Hosted on the MAX32630FTHR. The MAX31875 may be used in wearables, thermostats, thermometers, and hardware temperature supervisors.

Dependencies:   MAX31875_Temperature_Sensor_Low_Power max32630fthr USBDevice

Revision:
2:32c0d11d8c0d
Parent:
1:c5ac6967b6bf
Child:
3:587c7c740902
--- a/main.cpp	Mon Feb 04 23:39:11 2019 +0000
+++ b/main.cpp	Wed Feb 13 05:02:26 2019 +0000
@@ -48,7 +48,7 @@
 // (note the calls to Thread::wait below for delays)
 /**
 * @brief Sample main program for MAX31875
-* @version 1.0000.0001
+* @version 1.0000.0002
 *
 * @details Sample main program for MAX31875
 * The prints are sent to the terminal window (9600, 8n1).
@@ -82,6 +82,7 @@
         MAX31875_CFG_COMPARATOR_MODE | MAX31875_CFG_CONTINUOUS | 
         MAX31875_CFG_NORMAL_FORMAT | MAX31875_CFG_CONV_RATE_8 | 
         MAX31875_CFG_RESOLUTION_12BIT));
+
     for (i = 0; i < 10; i++) {
         wait(MAX31875_WAIT_CONV_RATE_8);
         temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TEMPERATURE);
@@ -90,14 +91,27 @@
     }
     temp_sensor.read_reg(&cfg, MAX31875_REG_CONFIGURATION);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
+#if 0
+    temp_sensor.write_trip_low(-63.9375);
+    wait(0.03);
+    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP);
+    printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, temp_sensor.celsius_to_fahrenheit(temperature));
+
+    temp_sensor.write_trip_high(64.0625f);
+    wait(0.03);
+    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP);
+    printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, temp_sensor.celsius_to_fahrenheit(temperature));
+    printf("\r\n\r\n");
+#endif
 
     printf("\r\n");
 
-
     /* Configure for fault filter 4, interrupt, shutdown,
      * extended format, 0.25 sps, 10 bit resolution, start one-shot
      */
-    for (i = 0; i < 5; i++) {
+    for (i = 0; i < 2; i++) {
         temp_sensor.write_cfg(uint16_t(MAX31875_CFG_FAULT_FILTER_4 | 
             MAX31875_CFG_INTERRUPT_MODE | MAX31875_CFG_SHUTDOWN |
             MAX31875_CFG_EXTENDED_FORMAT| MAX31875_CFG_CONV_RATE_0_25 | 
@@ -111,15 +125,18 @@
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
 
     printf("\r\n\r\n");
+
 #if 0
-    temp_sensor.write_trip_low(3.0625f);
+    temp_sensor.write_trip_low(-127.9375);
+    wait(0.03);
     temp_sensor.read_reg(&cfg, MAX31875_REG_CONFIGURATION);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_THYST);
+    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP);
     printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
 
     temp_sensor.write_trip_high(129.0625f);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS);
+    wait(0.03);
+    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP);
     printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     printf("\r\n\r\n");
@@ -130,6 +147,7 @@
      ***************************************************************************
      */
 #include "max31875_c.h"
+    printf("C implementation of the code\r\n");
     max31875_init(MAX31875_I2C_SLAVE_ADR_R0);
     /* Configure for fault filter 1, comparator, continuous,
      * normal format, 8 sps, 12 bit resolution
@@ -148,6 +166,52 @@
     max31875_read_reg(&cfg, MAX31875_REG_CONFIGURATION, i2cBus);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
 
+#if 0
+    max31875_write_trip_low(-63.9375, i2cBus);
+    wait(0.03);
+    temperature = max31875_read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP, i2cBus);
+    printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, max31875_celsius_to_fahrenheit(temperature));
+
+    max31875_write_trip_high(64.0625f, i2cBus);
+    wait(0.03);
+    temperature = max31875_read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP, i2cBus);
+    printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, max31875_celsius_to_fahrenheit(temperature));
+#endif
+
+    printf("\r\n");
+    for (i = 0; i < 2; i++) {
+        max31875_write_cfg(uint16_t(MAX31875_CFG_FAULT_FILTER_4 | 
+            MAX31875_CFG_INTERRUPT_MODE | MAX31875_CFG_SHUTDOWN |
+            MAX31875_CFG_EXTENDED_FORMAT| MAX31875_CFG_CONV_RATE_0_25 | 
+            MAX31875_CFG_RESOLUTION_10BIT | MAX31875_CFG_ONE_SHOT_START),
+            i2cBus);
+        wait(MAX31875_WAIT_CONV_RATE_0_25);
+        temperature = max31875_read_reg_as_temperature(MAX31875_REG_TEMPERATURE,
+            i2cBus);
+        printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, temp_sensor.celsius_to_fahrenheit(temperature));
+    }
+    max31875_read_reg(&cfg, MAX31875_REG_CONFIGURATION, i2cBus);
+    printf("Configuration Register = 0x%04Xh \r\n", cfg);
+
+#if 0
+    temp_sensor.write_trip_low(-127.9375);
+    max31875_write_trip_low(-127.9375, i2cBus);
+    wait(0.03);
+    temperature = max31875_read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP, i2cBus);
+    printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, max31875_celsius_to_fahrenheit(temperature));
+
+    max31875_write_trip_high(129.0625f, i2cBus);
+    wait(0.03);
+    temperature = max31875_read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP, i2cBus);
+    printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
+            temperature, max31875_celsius_to_fahrenheit(temperature));
+#endif
+    printf("\r\n\r\n\r\n");
+
 
     while (true) {  // Blink the green LED 
         gLED = !gLED;