Hexiwear / Mbed OS Hexi_Click_IRThermo_Example

Dependencies:   Hexi_KW40Z Hexi_MLX90614 Hexi_OLED_SSD1351

Fork of Hexi_Click_IRThermo_Example by Hexiwear

Committer:
GregC
Date:
Thu Oct 20 01:20:45 2016 +0000
Revision:
1:2df78187cf01
Parent:
0:bbaf949d2a27
Child:
2:14a1a79639db
in development

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
GregC 1:2df78187cf01 5 I2C i2c(PTD9,PTD8); //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
GregC 1:2df78187cf01 21 printf("Temperature is %4.2F 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 }