Here is the code I am using
type or p#include <Adafruit_MLX90614.h>
#include<Wire.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup() {
Serial.begin(9600);
mlx.begin();
}
void loop() {
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); Serial.print("\xC2\xB0");
Serial.print("C, \tObject = "); Serial.print(mlx.readObjectTempC()); Serial.print("\xC2\xB0");
Serial.println("C,");
//Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); Serial.print("\xC2\xB0");
//Serial.print("F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.print("\xC2\xB0");
//Serial.println("F");
//Serial.println();
delay(500);
}
And the library I am using for the MLX90614 sensor
/***************************************************
This is a library for the MLX90614 Temp Sensor
Designed specifically to work with the MLX90614 sensors in the
adafruit shop
----> https://www.adafruit.com/products/1748
----> https://www.adafruit.com/products/1749
These sensors use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include "Adafruit_MLX90614.h"
Adafruit_MLX90614::Adafruit_MLX90614(uint8_t i2caddr) { _addr = i2caddr; }
boolean Adafruit_MLX90614::begin(void) {
Wire.begin();
/*
for (uint8_t i=0; i<0x20; i++) {
Serial.print(i); Serial.print(" = ");
Serial.println(read16(i), HEX);
}
*/
return true;
}
//////////////////////////////////////////////////////
double Adafruit_MLX90614::readObjectTempF(void) {
return (readTemp(MLX90614_TOBJ1) * 9 / 5) + 32;
}
double Adafruit_MLX90614::readAmbientTempF(void) {
return (readTemp(MLX90614_TA) * 9 / 5) + 32;
}
double Adafruit_MLX90614::readObjectTempC(void) {
return readTemp(MLX90614_TOBJ1);
}
double Adafruit_MLX90614::readAmbientTempC(void) {
return readTemp(MLX90614_TA);
}
float Adafruit_MLX90614::readTemp(uint8_t reg) {
float temp;
temp = read16(reg);
temp *= .02;
temp -= 273.15000;
return temp;
}
/*********************************************************************/
uint16_t Adafruit_MLX90614::read16(uint8_t a) {
uint16_t ret;
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.endTransmission(false); // end transmission
Wire.requestFrom(_addr, (size_t)3); // send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
return ret;
}
I am using the preset Adafruit library for the MLX90614 and just calling the functions for reading the temperature. I know I likely have to change something in the library but I don't see any functions to change the precision. Sorry I am inexperienced with Arduino.