
This code just prints out the current temperature sensed by a TMP102 temperature sensor over serial when requested. Here's the Python code that lets you log data locally and to a Google Docs spreadsheet: https://github.com/m01/Tiny-Temperature-Logger For an example, see: http://playground.m01.eu/live-temperature For general information about the TMP102 and mbed, see http://mbed.org/cookbook/TMP102-Temperature-Sensor An additional wiring diagram can be obtained from here: http://wiring.org.co/learning/libraries/tmp102sparkfun.html
main.cpp
00001 #include "mbed.h" 00002 00003 #include "TMP102.h" 00004 00005 #define LF "\r\n" 00006 00007 Serial pc(USBTX, USBRX); // tx, rx to PC 00008 00009 TMP102 temperature(p9, p10, 0x90); //A0 pin is connected to ground 00010 00011 int main() 00012 { 00013 pc.printf("TMP102 logger ready. Press 'u' to see the temperature." LF); 00014 00015 while(1) { 00016 //whenever the computer sends a 'u', give it the current temperature. 00017 char c = pc.getc(); 00018 if (c == 'u') { 00019 pc.printf("%f" LF, temperature.read()); 00020 } 00021 wait(1); 00022 } 00023 return 0; 00024 }
Generated on Tue Jul 12 2022 19:02:26 by
