Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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
SeeedIRTempSensor.h@16:cebc9f55d2a6, 2017-05-18 (annotated)
- Committer:
- tulanthoar
- Date:
- Thu May 18 10:48:12 2017 -0600
- Revision:
- 16:cebc9f55d2a6
supplimental files to previous commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tulanthoar | 16:cebc9f55d2a6 | 1 | /* #include <cmath> */ |
| tulanthoar | 16:cebc9f55d2a6 | 2 | #include "mbed.h" |
| tulanthoar | 16:cebc9f55d2a6 | 3 | namespace IRTempSensor{ |
| tulanthoar | 16:cebc9f55d2a6 | 4 | #define SUR_TEMP_PIN PA_3 // Analog input pin connect to temperature sensor SUR pin |
| tulanthoar | 16:cebc9f55d2a6 | 5 | #define OBJ_TEMP_PIN PC_0 // Analog input pin connect to temperature sensor OBJ pin |
| tulanthoar | 16:cebc9f55d2a6 | 6 | |
| tulanthoar | 16:cebc9f55d2a6 | 7 | double measuresureTemp(PinName surPin) { |
| tulanthoar | 16:cebc9f55d2a6 | 8 | AnalogIn surTPin(surPin); |
| tulanthoar | 16:cebc9f55d2a6 | 9 | float volts, resistance, temperature; |
| tulanthoar | 16:cebc9f55d2a6 | 10 | volts = 0; |
| tulanthoar | 16:cebc9f55d2a6 | 11 | for (int i = 0; i < 100; i++) { |
| tulanthoar | 16:cebc9f55d2a6 | 12 | volts += surTPin.read(); |
| tulanthoar | 16:cebc9f55d2a6 | 13 | wait_us(10); |
| tulanthoar | 16:cebc9f55d2a6 | 14 | } |
| tulanthoar | 16:cebc9f55d2a6 | 15 | volts *= 3.3/100; |
| tulanthoar | 16:cebc9f55d2a6 | 16 | resistance = 2000000*volts/(2.5-volts); |
| tulanthoar | 16:cebc9f55d2a6 | 17 | temperature = 1/(log(resistance/100000)/3964 +(1/298.15)) - 273.15; |
| tulanthoar | 16:cebc9f55d2a6 | 18 | return temperature; |
| tulanthoar | 16:cebc9f55d2a6 | 19 | } |
| tulanthoar | 16:cebc9f55d2a6 | 20 | |
| tulanthoar | 16:cebc9f55d2a6 | 21 | float measureObjectTemp(PinName surPin, PinName objPin) { |
| tulanthoar | 16:cebc9f55d2a6 | 22 | AnalogIn objTPin(objPin); |
| tulanthoar | 16:cebc9f55d2a6 | 23 | float objV = 0; |
| tulanthoar | 16:cebc9f55d2a6 | 24 | for (int i = 0; i < 100; i++) { |
| tulanthoar | 16:cebc9f55d2a6 | 25 | objV += objTPin.read(); |
| tulanthoar | 16:cebc9f55d2a6 | 26 | wait_us(10); |
| tulanthoar | 16:cebc9f55d2a6 | 27 | } |
| tulanthoar | 16:cebc9f55d2a6 | 28 | objV *= 3.3/100; |
| tulanthoar | 16:cebc9f55d2a6 | 29 | /* float pileSignal= objV - 2.5*17.4/(17.4+64); */ |
| tulanthoar | 16:cebc9f55d2a6 | 30 | float pileSignal = objV - 0.52; |
| tulanthoar | 16:cebc9f55d2a6 | 31 | pileSignal *= 0.01; |
| tulanthoar | 16:cebc9f55d2a6 | 32 | float ts = measuresureTemp(surPin) + 273.15; |
| tulanthoar | 16:cebc9f55d2a6 | 33 | /* float calib = 1+(298.15 - ts)*0.0011; */ |
| tulanthoar | 16:cebc9f55d2a6 | 34 | float calib = 1; |
| tulanthoar | 16:cebc9f55d2a6 | 35 | float k = 3.45*pow(10,-13)*calib; |
| tulanthoar | 16:cebc9f55d2a6 | 36 | float kRecip = 2976078405624.9985; |
| tulanthoar | 16:cebc9f55d2a6 | 37 | float kRecipAmp = kRecip * 0.01; |
| tulanthoar | 16:cebc9f55d2a6 | 38 | /* float objT = (pileSignal*kRecip + ts*ts*ts*ts); */ |
| tulanthoar | 16:cebc9f55d2a6 | 39 | float objT = (objV*kRecipAmp -0.51*kRecipAmp + ts*ts*ts*ts); |
| tulanthoar | 16:cebc9f55d2a6 | 40 | return pow(objT,0.25) - 273.15; |
| tulanthoar | 16:cebc9f55d2a6 | 41 | /* return pileSignal*1000; */ |
| tulanthoar | 16:cebc9f55d2a6 | 42 | /* return objV*100; */ |
| tulanthoar | 16:cebc9f55d2a6 | 43 | }}; |
