In the video below I experimenting to test the distance range of the temperature sensor MLX90614. I measure the temperature of an object every 1 cm distance with the sensor. And here’s the result.
You can buy this device at the link below (affiliate links) :
In the video above, I average the sensor read by reading the data 30 times and then average that. This averaging technique makes the read result more stable. I use the sketch below.
#include <Wire.h> #include <Adafruit_MLX90614.h> float temperature, temp; float sum; int i=0; Adafruit_MLX90614 mlx = Adafruit_MLX90614(); void setup() { Serial.begin(9600); Serial.println("MLX90614 smoothing test"); mlx.begin(); } void loop() { while (i < 30) { temp= mlx.readObjectTempC(); sum += temp; i++; delay(1); } temperature = sum/30.0; sum = 0; i = 0; Serial.println(temperature); delay(50); }