TMP sensor

Dependencies:   mbed

Fork of Analog_Temp_2 by Umair Aftab

Files at this revision

API Documentation at this revision

Comitter:
lanmaomao7
Date:
Wed Apr 09 20:45:32 2014 +0000
Parent:
0:ab91d2a9a3bd
Commit message:
1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ab91d2a9a3bd -r 348dd46843f4 main.cpp
--- a/main.cpp	Fri Mar 07 04:18:43 2014 +0000
+++ b/main.cpp	Wed Apr 09 20:45:32 2014 +0000
@@ -3,29 +3,47 @@
 //Print temperature from LM61 analog temperature sensor
  
 //set p15 to analog input to read LM61 sensor's voltage output
-AnalogIn LM61(PTB0);
+AnalogIn TMP35(PTB0);
  
 //also setting unused analog input pins to digital outputs reduces A/D noise a bit
 //see http://mbed.org/users/chris/notebook/Getting-best-ADC-performance/
+/*
 DigitalOut P16(PTB1);
 DigitalOut P17(PTB2);
 DigitalOut P18(PTB3);
 DigitalOut P19(PTC0);
 //DigitalOut P20(p20);
- 
+
+/* 
 int main()
 {
     float tempC, tempF;
-    float val;
+    //float val;
  
     while(1) {
         //conversion to degrees C - from sensor output voltage per LM61 data sheet
-        tempC = ((LM61*3.3)-0.500)*100.0;
-        val = 
+        tempC = TMP35** 3.3 * 100;
+       
         //convert to degrees F
         tempF = (9.0*tempC)/5.0 + 32.0;
         //print current temp
         printf("%5.2F C %5.2F F \n\r", tempC, tempF);
         wait(.5);
     }
-}
\ No newline at end of file
+}
+*/
+
+float TMP_read_temp(){
+    float tempC, a[10], avg;
+    int i;
+    avg=0;
+    for(i=0;i<10;i++){
+        a[i]=TMP35.read();
+        wait(.02);
+        }
+    for(i=0;i<10;i++){
+        avg=avg+(a[i]/10);
+        }
+    tempC = avg * 3.3 * 100;
+    return tempC;
+}