Mangue Baja Personalized MLX program

Committer:
einsteingustavo
Date:
Thu Aug 01 11:41:20 2019 +0000
Revision:
0:b8c679416b97
Mangue Baja personalized MLX program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
einsteingustavo 0:b8c679416b97 1 /***************************************************
einsteingustavo 0:b8c679416b97 2 This is a library for the MLX90614 Temp Sensor
einsteingustavo 0:b8c679416b97 3 Designed specifically to work with the MLX90614 sensors in the
einsteingustavo 0:b8c679416b97 4 adafruit shop
einsteingustavo 0:b8c679416b97 5 ----> https://www.adafruit.com/products/1748
einsteingustavo 0:b8c679416b97 6 ----> https://www.adafruit.com/products/1749
einsteingustavo 0:b8c679416b97 7 These sensors use I2C to communicate, 2 pins are required to
einsteingustavo 0:b8c679416b97 8 interface
einsteingustavo 0:b8c679416b97 9 Adafruit invests time and resources providing this open source code,
einsteingustavo 0:b8c679416b97 10 please support Adafruit and open-source hardware by purchasing
einsteingustavo 0:b8c679416b97 11 products from Adafruit!
einsteingustavo 0:b8c679416b97 12 Written by Limor Fried/Ladyada for Adafruied in any redistribution
einsteingustavo 0:b8c679416b97 13 ****************************************************/
einsteingustavo 0:b8c679416b97 14
einsteingustavo 0:b8c679416b97 15 #include "mbed.h"
einsteingustavo 0:b8c679416b97 16
einsteingustavo 0:b8c679416b97 17 #define _addr 0x5A
einsteingustavo 0:b8c679416b97 18 #define MLX90614_I2CADDR 0x5A
einsteingustavo 0:b8c679416b97 19
einsteingustavo 0:b8c679416b97 20 // RAM
einsteingustavo 0:b8c679416b97 21 #define MLX90614_RAWIR1 0x04
einsteingustavo 0:b8c679416b97 22 #define MLX90614_RAWIR2 0x05
einsteingustavo 0:b8c679416b97 23 #define MLX90614_TA 0x06
einsteingustavo 0:b8c679416b97 24 #define MLX90614_TOBJ1 0x07
einsteingustavo 0:b8c679416b97 25 #define MLX90614_TOBJ2 0x08
einsteingustavo 0:b8c679416b97 26 // EEPROM
einsteingustavo 0:b8c679416b97 27 #define MLX90614_TOMAX 0x20
einsteingustavo 0:b8c679416b97 28 #define MLX90614_TOMIN 0x21
einsteingustavo 0:b8c679416b97 29 #define MLX90614_PWMCTRL 0x22
einsteingustavo 0:b8c679416b97 30 #define MLX90614_TARANGE 0x23
einsteingustavo 0:b8c679416b97 31 #define MLX90614_EMISS 0x24
einsteingustavo 0:b8c679416b97 32 #define MLX90614_CONFIG 0x25
einsteingustavo 0:b8c679416b97 33 #define MLX90614_ADDR 0x0E
einsteingustavo 0:b8c679416b97 34 #define MLX90614_ID1 0x3C
einsteingustavo 0:b8c679416b97 35 #define MLX90614_ID2 0x3D
einsteingustavo 0:b8c679416b97 36 #define MLX90614_ID3 0x3E
einsteingustavo 0:b8c679416b97 37 #define MLX90614_ID4 0x3F
einsteingustavo 0:b8c679416b97 38
einsteingustavo 0:b8c679416b97 39 class Adafruit_MLX90614 {
einsteingustavo 0:b8c679416b97 40 public:
einsteingustavo 0:b8c679416b97 41 Adafruit_MLX90614(PinName sda, PinName scl);
einsteingustavo 0:b8c679416b97 42 Adafruit_MLX90614(I2C *i2c);
einsteingustavo 0:b8c679416b97 43 ~Adafruit_MLX90614();
einsteingustavo 0:b8c679416b97 44 bool begin();
einsteingustavo 0:b8c679416b97 45 uint32_t readID(void);
einsteingustavo 0:b8c679416b97 46
einsteingustavo 0:b8c679416b97 47 double readObjectTempC(void);
einsteingustavo 0:b8c679416b97 48 double readAmbientTempC(void);
einsteingustavo 0:b8c679416b97 49 double readObjectTempF(void);
einsteingustavo 0:b8c679416b97 50 double readAmbientTempF(void);
einsteingustavo 0:b8c679416b97 51
einsteingustavo 0:b8c679416b97 52 private:
einsteingustavo 0:b8c679416b97 53 float readTemp(uint8_t reg);
einsteingustavo 0:b8c679416b97 54 I2C *i2c_;
einsteingustavo 0:b8c679416b97 55 uint16_t read16(uint8_t addr);
einsteingustavo 0:b8c679416b97 56 void write16(uint8_t addr, uint16_t data);
einsteingustavo 0:b8c679416b97 57 };