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

Dependencies:   mbed TMP102

Committer:
mblokzijl
Date:
Wed May 25 10:06:42 2011 +0000
Revision:
0:4cb63470a757
First revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mblokzijl 0:4cb63470a757 1 #include "mbed.h"
mblokzijl 0:4cb63470a757 2
mblokzijl 0:4cb63470a757 3 #include "TMP102.h"
mblokzijl 0:4cb63470a757 4
mblokzijl 0:4cb63470a757 5 #define LF "\r\n"
mblokzijl 0:4cb63470a757 6
mblokzijl 0:4cb63470a757 7 Serial pc(USBTX, USBRX); // tx, rx to PC
mblokzijl 0:4cb63470a757 8
mblokzijl 0:4cb63470a757 9 TMP102 temperature(p9, p10, 0x90); //A0 pin is connected to ground
mblokzijl 0:4cb63470a757 10
mblokzijl 0:4cb63470a757 11 int main()
mblokzijl 0:4cb63470a757 12 {
mblokzijl 0:4cb63470a757 13 pc.printf("TMP102 logger ready. Press 'u' to see the temperature." LF);
mblokzijl 0:4cb63470a757 14
mblokzijl 0:4cb63470a757 15 while(1) {
mblokzijl 0:4cb63470a757 16 //whenever the computer sends a 'u', give it the current temperature.
mblokzijl 0:4cb63470a757 17 char c = pc.getc();
mblokzijl 0:4cb63470a757 18 if (c == 'u') {
mblokzijl 0:4cb63470a757 19 pc.printf("%f" LF, temperature.read());
mblokzijl 0:4cb63470a757 20 }
mblokzijl 0:4cb63470a757 21 wait(1);
mblokzijl 0:4cb63470a757 22 }
mblokzijl 0:4cb63470a757 23 return 0;
mblokzijl 0:4cb63470a757 24 }