Adafruit MLX90640 Sensor Library
Adafruit_MLX90640.h
Go to the documentation of this file.
1 
17 #ifndef _ADAFRUIT_MLX90640_H
18 #define _ADAFRUIT_MLX90640_H
19 
20 #include "Arduino.h"
21 #include "headers/MLX90640_API.h"
22 #include <Adafruit_I2CDevice.h>
23 #include <Wire.h>
24 
25 #define MLX90640_I2CADDR_DEFAULT 0x33
26 
27 #define MLX90640_DEVICEID1 0x2407
28 
29 
30 typedef enum mlx90640_mode {
34 
36 typedef enum mlx90640_res {
37  MLX90640_ADC_16BIT,
38  MLX90640_ADC_17BIT,
39  MLX90640_ADC_18BIT,
40  MLX90640_ADC_19BIT,
42 
44 typedef enum mlx90640_refreshrate {
45  MLX90640_0_5_HZ,
46  MLX90640_1_HZ,
47  MLX90640_2_HZ,
48  MLX90640_4_HZ,
49  MLX90640_8_HZ,
50  MLX90640_16_HZ,
51  MLX90640_32_HZ,
52  MLX90640_64_HZ,
54 
55 #define OPENAIR_TA_SHIFT 8
56 
57 
62 public:
64  boolean begin(uint8_t i2c_addr = MLX90640_I2CADDR_DEFAULT,
65  TwoWire *wire = &Wire);
66 
68  void setMode(mlx90640_mode_t mode);
73 
74  int getFrame(float *framebuf);
75 
76  float getTa(bool newFrame = true);
77 
78  uint16_t serialNumber[3];
79 
80 private:
81  int MLX90640_I2CRead(uint8_t slaveAddr, uint16_t startAddress,
82  uint16_t nMemAddressRead, uint16_t *data);
83  int MLX90640_I2CWrite(uint8_t slaveAddr, uint16_t writeAddress,
84  uint16_t data);
85 
86  Adafruit_I2CDevice *i2c_dev;
87  paramsMLX90640 _params;
88  float ta = -999.0;
89 
90  int MLX90640_DumpEE(uint8_t slaveAddr, uint16_t *eeData);
91  int MLX90640_GetFrameData(uint8_t slaveAddr, uint16_t *frameData);
92  int MLX90640_ExtractParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
93  float MLX90640_GetVdd(uint16_t *frameData, const paramsMLX90640 *params);
94  float MLX90640_GetTa(uint16_t *frameData, const paramsMLX90640 *params);
95  void MLX90640_GetImage(uint16_t *frameData, const paramsMLX90640 *params,
96  float *result);
97  void MLX90640_CalculateTo(uint16_t *frameData, const paramsMLX90640 *params,
98  float emissivity, float tr, float *result);
99  int MLX90640_SetResolution(uint8_t slaveAddr, uint8_t resolution);
100  int MLX90640_GetCurResolution(uint8_t slaveAddr);
101  int MLX90640_SetRefreshRate(uint8_t slaveAddr, uint8_t refreshRate);
102  int MLX90640_GetRefreshRate(uint8_t slaveAddr);
103  int MLX90640_GetSubPageNumber(uint16_t *frameData);
104  int MLX90640_GetCurMode(uint8_t slaveAddr);
105  int MLX90640_SetInterleavedMode(uint8_t slaveAddr);
106  int MLX90640_SetChessMode(uint8_t slaveAddr);
107  void MLX90640_BadPixelsCorrection(uint16_t *pixels, float *to, int mode,
108  paramsMLX90640 *params);
109 };
110 #endif
int getFrame(float *framebuf)
Read 2 pages, calculate temperatures and place into framebuf.
Definition: Adafruit_MLX90640.cpp:167
#define MLX90640_I2CADDR_DEFAULT
I2C address by default.
Definition: Adafruit_MLX90640.h:25
mlx90640_res
Definition: Adafruit_MLX90640.h:36
mlx90640_resolution_t getResolution(void)
Get resolution for temperature precision.
Definition: Adafruit_MLX90640.cpp:132
void setRefreshRate(mlx90640_refreshrate_t res)
Set max refresh rate - too fast and we can&#39;t read the the pages in time, start low and then increment...
Definition: Adafruit_MLX90640.cpp:158
uint16_t serialNumber[3]
Unique serial number read from device.
Definition: Adafruit_MLX90640.h:78
void setMode(mlx90640_mode_t mode)
Set the frame-read mode.
Definition: Adafruit_MLX90640.cpp:120
enum mlx90640_res mlx90640_resolution_t
mlx90640_mode_t getMode(void)
Get the frame-read mode.
Definition: Adafruit_MLX90640.cpp:112
enum mlx90640_refreshrate mlx90640_refreshrate_t
boolean begin(uint8_t i2c_addr=MLX90640_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
Sets up the hardware and initializes I2C.
Definition: Adafruit_MLX90640.cpp:16
Read data from camera by interleaved lines.
Definition: Adafruit_MLX90640.h:31
enum mlx90640_mode mlx90640_mode_t
float getTa(bool newFrame=true)
Return ambient temperature of the TO39 package.
Definition: Adafruit_MLX90640.cpp:206
mlx90640_refreshrate
Definition: Adafruit_MLX90640.h:44
Read data from camera in alternating pixels.
Definition: Adafruit_MLX90640.h:32
mlx90640_refreshrate_t getRefreshRate(void)
Get max refresh rate.
Definition: Adafruit_MLX90640.cpp:148
mlx90640_mode
Definition: Adafruit_MLX90640.h:30
Adafruit_MLX90640()
Instantiates a new MLX90640 class.
Definition: Adafruit_MLX90640.cpp:6
void setResolution(mlx90640_resolution_t res)
Set resolution for temperature precision.
Definition: Adafruit_MLX90640.cpp:140
Class that stores state and functions for interacting with the MLX90640 sensor.
Definition: Adafruit_MLX90640.h:61