How to Interface MLX90614 Infrared Temperature Sensor with Arduino

The MLX90614 is an infrared temperature sensor that can precisely measure an object's temperature without touching it. It works by detecting the infrared radiation emitted by the object and converting it into a temperature reading. The sensor has a thermopile detector made of multiple thermocouples that generate a small voltage when exposed to heat. It also has a reference thermistor to ensure accuracy. The sensor communicates with an Arduino using the I2C protocol and is helpful in various applications where contact sensors may not be suitable. 

How to Interface the MLX90614 Infrared Temperature Sensor with Arduino
How to Interface the MLX90614 Infrared Temperature Sensor with Arduino

MLX90614 Infrared Temperature Sensor Pinout

The sensor comes with the following 4 pins:

MLX90614 infrared temperature sensor Pinout
MLX90614 temperature sensor Pinout

VIN, also called VCC, is the power pin of the sensor. You have to connect it to 3.3v or 5v.   

GND is the ground pin that goes to the Arduino GND pin.

SCL is the I2C clock pin that connects with the Arduino SCL clock pin.

SDA is the data pin of I2C that connects with the Arduino SDA pin.

Step 1: Gather the Components

You will need the following components:

  • MLX90614 sensor
  • Arduino Uno board
  • Jumper wires

Step 2: Circuit Diagram of MLX90614 and Arduino 

Follow the circuit and connect the VIN pin of the MLX90614 sensor to the 5v pin of the Arduino Uno, the GND pin of the sensor to the GND pin of the Arduino Uno, and the SDA and SCL pins of the sensor to the A4 and A5 pins or SDA and SCL pins of the Arduino Uno, respectively.

Circuit Diagram of MLX90614 and Arduino Uno
Circuit Diagram of MLX90614 and Arduino Uno

Step 3: Installing Adafruit Library for MLX90614

To install the Adafruit library for the MLX90614 temperature sensor, follow these steps:

  1. Go to Arduino IDE. Select "Sketch" from the menu bar, then select "Include Library"> "Manage Libraries." Or go to "Library Manager" in the new Arduino IDE. 
  2. In the Library Manager window, search for "Adafruit MLX90614".
  3. Select the Adafruit MLX90614 library and click the "Install" button.
  4. Wait for the installation to be completed.

Note: If you encounter any errors during the library installation process, ensure that you have an active internet connection and that your Arduino IDE is up to date.alert-info

Step 4: Arduino Code for MLX90614

Open the Arduino IDE and paste the following code into the code editor:

#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup() {
  Serial.begin(9600);
  mlx.begin();  
}
void loop() {
  Serial.print("Ambient Temperature: "); 
  Serial.print(mlx.readAmbientTempC()); 
  Serial.print("C / "); 
  Serial.print(mlx.readAmbientTempF()); 
  Serial.println("F");
  Serial.print("Object Temperature:  "); 
  Serial.print(mlx.readObjectTempC()); 
  Serial.print("C / "); 
  Serial.print(mlx.readObjectTempF()); 
  Serial.println("F");
  Serial.println();
  delay(500);
}code-box

Arduino Code Explanation

The serial communication is initialized in the setup() function, and the begin() function from the library is called to initialize the sensor.

In the loop() function, the ambient and object temperature readings in Celsius and Fahrenheit are printed to the serial monitor using the readAmbientTempC(), readAmbientTempF(), readObjectTempC(), and readObjectTempF() functions from the library.

The delay(500) function pauses the program for half a second before taking another reading.

Step 5: Upload the Code to the Arduino Uno Board

Connect the Arduino Uno board to your computer using a USB cable. Select the right port and upload the code to the board.

Step 6: View the Temperature Value on the Serial Monitor

Once the Arduino code is uploaded, open the Serial Monitor in the Arduino IDE. You should see the ambient temperature and object temperature readings in Celsius and Fahrenheit as follows:

MLX90614 Infrared Temperature Sensor output on Arduino
The MLX90614 Temperature Sensor Output on Arduino Serial Monitor

Video Demonstration

The following video demonstrates the operations and uses of the MLX90614 Infrared Temperature Sensor case.


Conclusion

The MLX90614's non-contact temperature measurement capabilities make it useful in various applications, including industrial automation, medical devices, and home appliances. Its ability to accurately measure temperature without physical contact allows it to be used when contact sensors may not be suitable or safe. The MLX90614 is a reliable and accurate temperature sensor that can provide valuable, non-invasive temperature measurements.

2/Post a Comment/Comments

  1. How to connect MLX90614 infrared temperature sensor to Arduino is very useful, through the post I know how to connect, thank you

    ReplyDelete
    Replies
    1. We're thrilled to hear that you found our guide on connecting the MLX90614 infrared temperature sensor to Arduino helpful! Discovering how to establish the connection is a crucial step in unlocking the sensor's capabilities. Thank you for your feedback, and if you have any more questions or if there's anything else you'd like to learn about Arduino projects, feel free to explore our other tutorials. Happy coding! 🔧🌡️ #MLX90614 #ArduinoConnection #TemperatureSensorTutorial

      Delete

Post a Comment