Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use MLX90640: Examples, Pinouts, and Specs

Image of MLX90640Design with MLX90640 in Cirkit Designer

Introduction

The MLX90640 is a 32x24 pixel thermal imaging sensor designed for non-contact temperature measurement. It operates in the infrared spectrum, allowing it to detect temperature variations across a surface or object. With a wide temperature detection range of -40°C to 300°C, the MLX90640 is ideal for applications such as thermal monitoring, HVAC systems, robotics, and even human body temperature detection. Its compact design and high accuracy make it a popular choice for both industrial and consumer applications.

Explore Projects Built with MLX90640

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ESP32-Based Infrared Thermometer with I2C LCD Display: A project utilizing MLX90640 in a practical application
ESP32-Based Infrared Thermometer with I2C LCD Display

This circuit features an ESP32 microcontroller powered by a 18650 Li-Ion battery, with a TP4056 module for charging the battery via a USB plug. The ESP32 reads temperature data from an MLX90614 infrared temperature sensor and displays it on an I2C LCD 16x2 screen. The ESP32, MLX90614 sensor, and LCD screen are connected via I2C communication lines (SCL, SDA), and the circuit is designed to measure and display ambient and object temperatures.

Open Project in Cirkit Designer
Image of Arduino Mega 2560-Based Autonomous Robot with GPS, Bluetooth, and Environmental Sensors: A project utilizing MLX90640 in a practical application
Arduino Mega 2560-Based Autonomous Robot with GPS, Bluetooth, and Environmental Sensors

This circuit is a robotic system controlled by an Arduino Mega 2560, which uses multiple sensors including temperature sensors (MLX90614), gas sensors (MQ-136), a GPS module, and a Bluetooth module to navigate and detect environmental conditions. The system drives motors via an L298N motor driver and displays information on a 16x2 I2C LCD, with the ability to receive commands via Bluetooth.

Open Project in Cirkit Designer

Technical Specifications

Pin Configuration and Descriptions

The MLX90640 is typically available in a breakout board format. Below is the pin configuration for a common MLX90640 breakout board:

Pin Name Description
1 VCC Power supply input (3.3V)
2 GND Ground connection
3 SDA I²C data line (connect to microcontroller's SDA pin)
4 SCL I²C clock line (connect to microcontroller's SCL pin)
5 INT Interrupt pin (optional, used for advanced configurations)
6 ADDR I²C address selection pin (used to set the device's I²C address)

Usage Instructions

How to Use the MLX90640 in a Circuit

  1. Power Supply: Connect the VCC pin to a 3.3V power source and the GND pin to ground.
  2. I²C Communication: Connect the SDA and SCL pins to the corresponding I²C pins on your microcontroller. Use pull-up resistors (typically 4.7kΩ) on the SDA and SCL lines if not already present on the breakout board.
  3. I²C Address: Configure the ADDR pin to set the I²C address. Refer to the breakout board's datasheet for address selection details.
  4. Interrupt Pin (Optional): If required, connect the INT pin to a GPIO pin on your microcontroller for advanced configurations.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to interface the MLX90640 with an Arduino UNO using the I²C protocol. This code uses the Adafruit MLX90640 library.

#include <Wire.h>
#include <Adafruit_MLX90640.h>

// Create an instance of the MLX90640 object
Adafruit_MLX90640 mlx;

// Define the frame buffer to store temperature data
float frame[32 * 24]; // 32x24 resolution

void setup() {
  Serial.begin(115200); // Initialize serial communication
  Wire.begin();         // Initialize I²C communication

  // Initialize the MLX90640 sensor
  if (!mlx.begin()) {
    Serial.println("MLX90640 not detected. Check wiring!");
    while (1); // Halt execution if sensor is not found
  }

  // Set the refresh rate to 8Hz (adjustable: 0.5Hz to 64Hz)
  mlx.setMode(MLX90640_INTERLEAVED);
  mlx.setRefreshRate(MLX90640_8_HZ);

  Serial.println("MLX90640 initialized successfully!");
}

void loop() {
  // Read temperature data into the frame buffer
  if (mlx.getFrame(frame)) {
    Serial.println("Temperature data:");
    for (int i = 0; i < 32 * 24; i++) {
      Serial.print(frame[i], 1); // Print temperature with 1 decimal place
      Serial.print(" ");
      if ((i + 1) % 32 == 0) {
        Serial.println(); // New line after every 32 pixels
      }
    }
    delay(125); // Delay to match the 8Hz refresh rate
  } else {
    Serial.println("Failed to read frame data!");
  }
}

Notes on the Code

Troubleshooting and FAQs

Common Issues

  1. Sensor Not Detected:

    • Cause: Incorrect wiring or I²C address mismatch.
    • Solution: Verify the connections and ensure the ADDR pin is configured correctly.
  2. Inaccurate Temperature Readings:

    • Cause: Sensor exposed to heat sources or reflective surfaces.
    • Solution: Isolate the sensor from external heat sources and avoid reflective objects in its field of view.
  3. I²C Communication Errors:

    • Cause: Missing or incorrect pull-up resistors on SDA/SCL lines.
    • Solution: Add 4.7kΩ pull-up resistors if not already present.
  4. Frame Data Not Updating:

    • Cause: Incorrect frame rate configuration.
    • Solution: Ensure the frame rate matches the delay in your code.

FAQs

  1. Can the MLX90640 detect human body temperature?

    • Yes, the MLX90640 can accurately measure human body temperature. However, ensure proper calibration for medical-grade accuracy.
  2. What is the maximum distance for temperature measurement?

    • The effective distance depends on the object size and the sensor's FoV. For small objects, the sensor should be closer for accurate readings.
  3. Can I use the MLX90640 with a 5V microcontroller?

    • Yes, but you must use a logic level shifter to convert the 5V I²C signals to 3.3V.
  4. How do I change the I²C address?

    • The I²C address is configured using the ADDR pin. Refer to the breakout board's documentation for details.

By following this documentation, you can effectively integrate the MLX90640 into your projects and troubleshoot common issues.