PCB lives now in its own git repo https://git.la10cy.net/DeltaLima/CanGrow-12V-PCB
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
/*
|
|
*
|
|
* include/Sensor/05_MLX90614.h - MLX90614 I2C IR temp sensor
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
#include <Adafruit_MLX90614.h>
|
|
|
|
#define SENSOR_05_NAME "MLX90614"
|
|
|
|
const byte Sensor_05_MLX90614_Addr[] = { 0x5A, 0x5B, 0x5C, 0x5D };
|
|
|
|
Adafruit_MLX90614 MLX90614[sizeof(Sensor_05_MLX90614_Addr)];
|
|
|
|
/* Create main data array specifying max amount of readings */
|
|
float Sensor_05_MLX90614[sizeof(Sensor_05_MLX90614_Addr)][2];
|
|
|
|
void Sensor_05_MLX90614_Update(const byte AddrId) {
|
|
/* keep the same order as in SensorIndex[].read[] !! */
|
|
Sensor_05_MLX90614[AddrId][0] = MLX90614[AddrId].readAmbientTempC();
|
|
Sensor_05_MLX90614[AddrId][1] = MLX90614[AddrId].readObjectTempC();
|
|
}
|
|
|
|
bool Sensor_05_MLX90614_Init(const byte AddrId) {
|
|
/* Sensor Init function
|
|
*
|
|
* returns true (1) when Init was successful
|
|
* returns false (0) if not.
|
|
*/
|
|
const static char LogLoc[] PROGMEM = "[Sensor:05_MLX90614:Init]";
|
|
bool returnCode;
|
|
|
|
if(MLX90614[AddrId].begin(Sensor_05_MLX90614_Addr[AddrId])) {
|
|
Log.notice(F("%s found at addr 0x%x - emissivity set to %F" CR), LogLoc, Sensor_05_MLX90614_Addr[AddrId], MLX90614[AddrId].readEmissivity());
|
|
Sensor_05_MLX90614_Update(AddrId);
|
|
returnCode = true;
|
|
} else {
|
|
Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Sensor_05_MLX90614_Addr[AddrId]);
|
|
returnCode = false;
|
|
}
|
|
return returnCode;
|
|
}
|