Nathan Yonkee / Mbed OS Seeed_Grove_4_Digit_Display_Clock

Dependencies:   Data_Clock_Pair Seeed_Chainable_LED Seeed_Four_Digit_Disp Seeed_IR_Temp_Sensor Seeed_Led_Bar

Fork of Seeed_Grove_4_Digit_Display_Clock by Seeed

Revision:
16:cebc9f55d2a6
diff -r abda719ba6e6 -r cebc9f55d2a6 SeeedIRTempSensor.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SeeedIRTempSensor.h	Thu May 18 10:48:12 2017 -0600
@@ -0,0 +1,43 @@
+/* #include <cmath> */
+#include "mbed.h"
+namespace IRTempSensor{
+#define SUR_TEMP_PIN PA_3 // Analog input pin connect to temperature sensor SUR pin
+#define OBJ_TEMP_PIN PC_0 // Analog input pin connect to temperature sensor OBJ pin
+
+double measuresureTemp(PinName surPin) {
+    AnalogIn surTPin(surPin);
+    float volts, resistance, temperature;
+    volts = 0;
+    for (int i = 0; i < 100; i++) {
+        volts += surTPin.read();
+        wait_us(10);
+    }
+    volts *= 3.3/100;
+    resistance = 2000000*volts/(2.5-volts);
+    temperature = 1/(log(resistance/100000)/3964 +(1/298.15)) - 273.15;
+    return temperature;
+}
+
+float measureObjectTemp(PinName surPin, PinName objPin) {
+    AnalogIn objTPin(objPin);
+    float objV = 0;
+    for (int i = 0; i < 100; i++) {
+        objV += objTPin.read();
+        wait_us(10);
+    }
+    objV *= 3.3/100;
+    /* float pileSignal= objV - 2.5*17.4/(17.4+64); */
+    float pileSignal = objV - 0.52;
+    pileSignal *= 0.01;
+    float ts = measuresureTemp(surPin) + 273.15;
+    /* float calib = 1+(298.15 - ts)*0.0011; */
+    float calib = 1;
+    float k = 3.45*pow(10,-13)*calib;
+    float kRecip = 2976078405624.9985;
+    float kRecipAmp = kRecip * 0.01;
+    /* float objT = (pileSignal*kRecip + ts*ts*ts*ts); */
+    float objT = (objV*kRecipAmp -0.51*kRecipAmp + ts*ts*ts*ts);
+    return pow(objT,0.25) - 273.15;
+    /* return pileSignal*1000; */
+    /* return objV*100; */
+}};