Demo for MLX90614

Dependencies:   MLX90614 mbed

Committer:
masrodjie
Date:
Fri May 04 07:35:07 2018 +0000
Revision:
0:9dcc95868add
Initial Release

Who changed what in which revision?

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