Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 #define MLX90614_ADDR (0x5A) // Slave address 00004 #define MLX90614_TOBJ (0x07) // Object temperature register 00005 00006 DigitalOut led(D13); //link leg 00007 I2C i2c(D14, D15); //I2C reg(SDA, SCL) 00008 Serial pc(D1, D0); //Serial reg 00009 Ticker TT; //call a timer 00010 00011 char data_write[1]; //buff for write 00012 char data_read [3]; //buff for read 00013 short Buff = 0x00; 00014 float TOBJ = 0.0; 00015 void read_MLX(); 00016 00017 int main() 00018 { 00019 led = 0; 00020 pc.baud(9600); //set baud rate 00021 i2c.frequency(100000); //100kHz 00022 read_MLX(); //update MLX data 00023 TOBJ = ((float)Buff * 0.02f) - 273.0f; 00024 printf("%.2f\n",TOBJ); 00025 } 00026 00027 00028 void read_MLX(void) //read MLX data give raw data 00029 { 00030 led = 1; 00031 //TOBJ 00032 data_write[0] = MLX90614_TOBJ; //TOBJ address to buff 00033 i2c.write( MLX90614_ADDR<<1 | 0x00, data_write, 1, 1); //command to RAM access SR activated 00034 i2c.read ( MLX90614_ADDR<<1 | 0x01, data_read , 3, 0); //read callback 00035 Buff = data_read[1] << 8; // merging 00036 Buff |= data_read[0]; 00037 led = 0; 00038 }
Generated on Sun Jul 17 2022 10:12:13 by
1.7.2