// Include the necessary libraries for I2C communication and for handling the MLX90614 sensor #include #include // Create an object for the MLX90614 sensor Adafruit_MLX90614 mlx = Adafruit_MLX90614(); // Initial program setup void setup() { // Start serial communication with the computer for debugging Serial.begin(115200); // Wait for serial connection to be ready to send data while (!Serial); // Inform via serial that the MLX90614 sensor test is starting Serial.println("Starting MLX90614 sensor test"); // Start the MLX90614 sensor and check for any initialization errors if (!mlx.begin()) { // If there's an initialization error, send an error message via serial Serial.println("Error initializing MLX90614 sensor"); // Enter an infinite loop to halt further program execution while (1); } } // Main program loop, executed repeatedly void loop() { // Read the temperature of the object pointed by the sensor in Celsius degrees float objectTemp = mlx.readObjectTempC(); // Check if the temperature value is valid if (isnan(objectTemp)) { // If the value is not valid, print an error message via serial Serial.println("Error reading temperatures"); } else { // If the value is valid, print the temperature via serial Serial.print("Object Temperature= "); Serial.print(objectTemp); Serial.println(" °C"); } // Print a newline to separate readings Serial.println(); // Wait one second before the next reading delay(1000); }