Added the functions to read and set the emissivity of the sensor.

Committer:
lamell
Date:
Fri Sep 18 13:54:59 2020 -0400
Revision:
7:be827071bcb0
Parent:
6:689f0dab386c
Downgraded mbed-os to version 5.13 so accrodingly:
Changed thread_sleep_for to wait

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aquahika 1:4a60d3f1e91e 1 #include "mbed.h"
aquahika 1:4a60d3f1e91e 2
aquahika 1:4a60d3f1e91e 3 //Melexis Infrared Thermometer MLX90614 Library
aquahika 1:4a60d3f1e91e 4
aquahika 1:4a60d3f1e91e 5 //*****************************************************************
aquahika 1:4a60d3f1e91e 6 // Build : 2011-06-08 Hikaru Sugiura
aquahika 1:4a60d3f1e91e 7 // Only read thermo data.
aquahika 1:4a60d3f1e91e 8 //
aquahika 1:4a60d3f1e91e 9 // This program is based on Mr.Mitesh Patel's "mlx90614".
aquahika 1:4a60d3f1e91e 10 // http://mbed.org/users/mitesh2patel/programs/mlx90614/lqnetj
aquahika 1:4a60d3f1e91e 11 //
aquahika 1:4a60d3f1e91e 12 // This program does not check CRC.
aquahika 1:4a60d3f1e91e 13 // If you want to check CRC, please do it your self :)
aquahika 1:4a60d3f1e91e 14 //****************************************************************//
aquahika 1:4a60d3f1e91e 15
aquahika 3:eb618e916622 16 /**An Interface for MLX90614
aquahika 3:eb618e916622 17 *
aquahika 3:eb618e916622 18 * @code
aquahika 2:01d333d06727 19 * //Print temperature data
aquahika 2:01d333d06727 20 * #include "mbed.h"
aquahika 2:01d333d06727 21 * #include "mlx90614.h"
aquahika 2:01d333d06727 22 *
aquahika 2:01d333d06727 23 * I2C i2c(p28,p27); //sda,scl
aquahika 2:01d333d06727 24 * MLX90614 thermometer(&i2c);
aquahika 4:dcd4fe76bd13 25 * float temp;
aquahika 2:01d333d06727 26 *
aquahika 2:01d333d06727 27 * void main(void){
aquahika 4:dcd4fe76bd13 28 * if(thermometer.getTemp(&temp)){
aquahika 2:01d333d06727 29 * printf("Temperature : %f \r\n",temp);
aquahika 2:01d333d06727 30 * }
aquahika 2:01d333d06727 31 * wait(0.5);
aquahika 2:01d333d06727 32 *
aquahika 2:01d333d06727 33 * }
aquahika 3:eb618e916622 34 * @endcode
aquahika 3:eb618e916622 35 */
aquahika 2:01d333d06727 36
lamell 6:689f0dab386c 37 #define DEBUG_MLX90614 false
aquahika 2:01d333d06727 38
aquahika 1:4a60d3f1e91e 39 class MLX90614{
aquahika 1:4a60d3f1e91e 40
aquahika 1:4a60d3f1e91e 41 public:
aquahika 2:01d333d06727 42 /** Create MLX90614 interface, initialize with selected I2C port and address.
aquahika 2:01d333d06727 43 *
aquahika 2:01d333d06727 44 * @param i2c I2C device pointer
aquahika 2:01d333d06727 45 * @param addr Device address(default=0xB4)
aquahika 2:01d333d06727 46 */
aquahika 1:4a60d3f1e91e 47 MLX90614(I2C* i2c,int addr=0xB4);
aquahika 2:01d333d06727 48
aquahika 2:01d333d06727 49 /** Get Temperature data from MLX90614.
aquahika 2:01d333d06727 50 *
aquahika 2:01d333d06727 51 * @param temp_val return valiable pointer
aquahika 2:01d333d06727 52 * @return 0 on success (ack), or non-0 on failure (nack)
aquahika 2:01d333d06727 53 */
aquahika 1:4a60d3f1e91e 54 bool getTemp(float* temp_val);
aquahika 1:4a60d3f1e91e 55
lamell 5:3c4431224932 56 float GetEmissivity(void);
lamell 5:3c4431224932 57
lamell 6:689f0dab386c 58 int SetEmissivity(float *em);
lamell 5:3c4431224932 59
lamell 5:3c4431224932 60
aquahika 1:4a60d3f1e91e 61 private:
aquahika 1:4a60d3f1e91e 62 I2C* i2c;
aquahika 1:4a60d3f1e91e 63 int i2caddress;
lamell 6:689f0dab386c 64
lamell 6:689f0dab386c 65 bool debug_mlx90614=DEBUG_MLX90614;
lamell 6:689f0dab386c 66 int InternalSet(uint8_t *p, int index);
aquahika 1:4a60d3f1e91e 67
lamell 6:689f0dab386c 68 int BlankEEPROM(int em);
aquahika 0:9237d31f0d03 69 };