MLX90614 contactless temperature sensor

Non Contact Temperature Sensor MLX90614 With Arduino Tutorial

One of the solutions to build a sensor system that can measure high temperature without damaging the system is using a contactless or non-contact temperature sensor. This sensor can sense the temperature of an object without touching the object.

Mlx90614 is an infrared-based sensor, it measures the temperature based on infrared emitted by an object. It senses electromagnetic waves in the range of about 700 nm to 14,000 nm.

Mlx90614 is a great cheap sensor that costs under 10$.

You can buy this device at the link below (affiliate links) :

""

Sensor Spesification

These are some good features of this sensor taken from its datasheet.

  • Small size, low cost
  • Factory calibrated in wide temperature range:
    40 to 125 °C for sensor temperature and
    70 to 380 °C for object temperature.
  • High accuracy of 0.5°C over wide temperature
    range (0..+50°C for both Ta and To)
  • Measurement resolution of 0.02°C
  • Available in 3V and 5V versions

Wiring Diagram

wiring diagram mlx90614 and arduino
wiring diagram mlx90614 and arduino

Vin -> 3.3V

GND -> GND

SCL -> SCL or A5

SDA -> SDA or A4

You can choose to connect sensor I²C pin to Arduino SCL, SDA or Arduino pin A4, A5 they have the same function. Make sure use 3.3V for 3.3V module type. Because it will damage if connected to 5V. I damaged mine twice.

MLX90614 With Arduino Code

Before you start the code, make sure you have the library. Download library from adafruit here.

You can get the sample code to measure temperature using the library sample or copy the code below :

/*************************************************** 
  This is a library example 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 <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(9600);

  Serial.println("Adafruit MLX90614 test");  

  mlx.begin();  
}

void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); 
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); 
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

  Serial.println();
  delay(500);
}

Paste the code above to your Arduino IDE and upload. After done uploading, you can test the sensor. It should work now!. You can measure an object’s temperature by facing the sensor toward the object.



Watch the full video tutorial below :

Add an Alarm if temperature reading is more than threshold

If you want to make some alarm based on this sensor, you can simply add a buzzer to pin 2 of Arduino and the ground connected to the ground.

In this example, I will set the threshold to 37. So every time the temperature read more than 37 degrees of celsius. It will turn on the buzzer. Here’s the complete code. You can easily edit the threshold too.

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

const int buzzer=2;
const int threshold=37;

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test"); 
  pinMode(2,OUTPUT);
  mlx.begin();  
}

void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); 
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); 
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");\
  Serial.println();

  if (mlx.readObjectTempC()>threshold){
    digitalWrite(buzzer, HIGH);
  } else {
    digitalWrite(buzzer, LOW);
  }
  delay(500);
}

7 Replies to “Non Contact Temperature Sensor MLX90614 With Arduino Tutorial”

Leave a Reply

Your email address will not be published. Required fields are marked *