Temperature

Dependencies:   MLX90614 mbed

Fork of IR_temperature by jim hamblen

Committer:
4180_1
Date:
Tue Feb 21 01:47:13 2012 +0000
Revision:
0:bbaf949d2a27
Child:
1:acf9d29475a6

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:bbaf949d2a27 1 #include "mbed.h"
4180_1 0:bbaf949d2a27 2 #include "mlx90614.h"
4180_1 0:bbaf949d2a27 3
4180_1 0:bbaf949d2a27 4 DigitalOut myled(LED1); //displays I2C wait
4180_1 0:bbaf949d2a27 5 I2C i2c(p28,p27); //sda,scl
4180_1 0:bbaf949d2a27 6 Serial pc(USBTX,USBRX); //serial usb config
4180_1 0:bbaf949d2a27 7
4180_1 0:bbaf949d2a27 8 MLX90614 IR_thermometer(&i2c);
4180_1 0:bbaf949d2a27 9 //setup an MLX90614 using MLX90614 library from
4180_1 0:bbaf949d2a27 10 // http://mbed.org/users/aquahika/libraries/MLX90614/lsixz6
4180_1 0:bbaf949d2a27 11
4180_1 0:bbaf949d2a27 12 float temp; //temperature in degrees C
4180_1 0:bbaf949d2a27 13
4180_1 0:bbaf949d2a27 14 int main() {
4180_1 0:bbaf949d2a27 15 while (1) {
4180_1 0:bbaf949d2a27 16 myled=1; // if led1 on - waiting on I2C
4180_1 0:bbaf949d2a27 17 if (IR_thermometer.getTemp(&temp)) {
4180_1 0:bbaf949d2a27 18 //gets temperature from sensor via I2C bus
4180_1 0:bbaf949d2a27 19 myled=0;
4180_1 0:bbaf949d2a27 20 //print temperature on PC
4180_1 0:bbaf949d2a27 21 printf("Temperature is %5.1F degrees C\r\n",temp);
4180_1 0:bbaf949d2a27 22 }
4180_1 0:bbaf949d2a27 23 //wait for device to produce next temperature reading
4180_1 0:bbaf949d2a27 24 wait(0.5);
4180_1 0:bbaf949d2a27 25 }
4180_1 0:bbaf949d2a27 26 }