Raspberry Pi B.Tech/Diploma Beginner

DIY Thermal Imaging Camera with MLX90640 & Raspberry Pi

Building a DIY Thermal Imaging Camera with MLX90640 & Raspberry Pi 4 with Python Code to visualize 24x32 IR Thermal Image Array on LCD Screen

  • Suitable forB.Tech/Diploma Raspberry Pi students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this project, we will build our own
Thermal Imaging Camera
with
MLX90640
&
Raspberry Pi
. The MLX90640
far-infrared camera
is an array of
768 (32×24)
thermal sensors that can detect temperatures from
-40
to
300°C
with approximately 1°C accuracy.
Earlier we build a
Thermal Camera using AMG8833
& Raspberry Pi Board. The AMG8833 has a lower resolution of
8×8
pixels, totaling

thermal detectors. But the MLX90640 sensor offers a higher resolution of
32×24
pixels, which translates to

individual thermal detectors. This higher resolution provides more detailed thermal images. The AMG8833 offers a
lower refresh rate
of
10 Hz
, making it less ideal for monitoring fast-changing thermal events, while the MLX90640 supports a
higher refresh rate
of up to
64 Hz
for smoother thermal video capture.
This
DIY Thermal Imaging Camera
using MLX90640 & Raspberry Pi uses a
Python Code
and multiple Python libraries like
Numpy
and
Matplotlib
for visualization of Thermal images in a 7-inch
HDMI LCD Screen
. Thus building a thermal imaging camera using the
Raspberry Pi
and the
MLX90640
is a fun and affordable project that can be done by anyone with basic electronic skills. Whether your aim is to
spot temperature variations
around the house, identify heat escapes in building structures,
Fever Detection System
, or merely take unique infrared photos on
MLX90640 Webserver
, this project provides an excellent starting point.
Bill of Materials
Following are the list of components required to build this
DIY Thermal Imaging Camera
. You can purchase all the components from Amazon or the SunFounder.
S.N.
Components
Quantity
Purchase Link

Raspberry Pi 4

Amazon
SunFounder

MLX90640 Thermal Image Sensor

Amazon
AliExpress

TS-Pro 7 inch LCD Display

Amazon
SunFounder

SD Card 16/32 GB

Amazon
SunFounder

5V, 3A DC Adapter for RPi

Amazon
SunFounder

UPS Power Supply with Battery (Optional)

Amazon
SunFounder

Mouse & Keyboard (Optional)

Amazon
SunFounder
MLX90640 32×24 IR Array Temperature Sensor
The
MLX90640
from
Melexis
is a small size, non-contact, and low cost
far-infrared thermal sensor
array that integrates
768 (32×24)
thermal sensors into a compact and standard 4-lead TO39 package.
This sensor is capable of capturing detailed
thermal images
by measuring the infrared radiation emitted by objects in its field of view, translating it into temperature readings ranging from
-40°C
to
300°C
Different MLX90640 Breakout Boards
The sensor achieves a high
degree of accuracy
, maintaining approximately
±1°C
across its operational range. Furthermore, the
MLX90640
includes additional functionalities like an ambient temperature sensor and a supply voltage sensor, enhancing its precision and reliability. Data from the
IR sensors
, as well as the ambient and supply voltage measurements, are stored in
internal RAM
and can be accessed via an I2C interface.
The
MLX90640 thermal camera
features a
32×24 array
, totaling 768 individual far-infrared pixels. Each pixel captures temperature data, allowing for detailed
thermal imaging
and accurate temperature measurements across the sensor’s field of view.
The MLX90640 is not only functional but also user-friendly, tailored for hobbyists and professionals alike. It supports both
3.3V
and
5V
operating voltages and communicates through a configurable
I2C interface
that can reach data rates up to
1MHz
. This sensor is compatible with platforms like Arduino, Raspberry Pi, or STM32.
The sensor’s capability to adjust the frame rate from
0.5
to
64Hz
allows users to fine-tune its performance based on specific application requirements, whether it’s tracking fast-moving objects or conducting detailed thermal evaluations over a slower period. Refer to
MLX90640 Datasheet
for more information about this Thermal Camera.
Features and Benefits
Small size, low cost 32×24 pixels IR array
Easy to integrate
Industry standard four lead TO39 package
Factory calibrated
Noise Equivalent Temperature Difference (NETD): 0.1K RMS @1Hz refresh rate
I2C compatible digital interface
Programmable refresh rate 0.5Hz…64Hz
3.3V supply voltage
Current consumption is less than 23mA
2 FOV options – 55°x35° and 110°x75°
Operating temperature -40°C ÷ 85°C
Target temperature -40°C ÷ 300°C
Complies with RoHS regulations
Applications of MLX90640
High-precision non-contact temperature measurements
Intrusion / Movement detection
Presence detection / Person localization
Temperature sensing element for intelligent building air conditioning
Thermal Comfort sensor in automotive Air Conditioning control system
Microwave ovens
Industrial temperature control of moving parts
Visual IR thermometers
Pinout of MLX90640
The
MLX90640 Thermal Camera
has 4 pins that need to be connected to the controller and currently supports the Raspberry Pi, STM32F405R, and ESP32 series.
VCC
: Power supply pin, should be connected to the control 3.3V or 5V power supply.
GND
: Ground pin, corresponds to the connection of the ground (GND).
SDA
: Data pin for I2C communication, connected to the GPIO of the controller.
SCL
: Clock pin for I2C communication, connected to the GPIO of the controller
Certain variants of the MLX90640 thermal camera module are equipped to support the
UART communication protocol
in addition to the standard
I2C interface
. This feature allows for greater flexibility in integrating the sensor with a wider range of microcontrollers and systems that might prefer
UART
for simplicity or specific application requirements.
Measurement Distance & FOV
The
MLX90640 thermal sensor
offers a
field of view (FOV)
of either

degrees or

degrees, depending on the model.
Field Of View Measurement
The
Field of View (FOV)
of the MLX90640 thermal sensor is defined by the
50% radiation signal
received by its thermopile and is oriented along the sensor’s main axis. It measures a weighted average temperature of objects within this FOV, requiring full coverage of the target within the FOV for accurate readings.
Variants of MLX90640
The MLX90640 is an
infrared thermal sensor array
that comes in two variants:
MLX90640BAA
and
MLX90640BAB
MLX90640BAA
: It has a
wider field of view
of
110° x 75°
. This variant is suitable for applications where a larger area needs to be observed at once, such as broad area surveillance or room occupancy sensing.
MLX90640BAB
: It has a
narrower field
of view of
55° x 35°
. This variant is better for focused thermal measurements, making it ideal for applications like electronic device thermal testing or targeted object detection.
MLX90640 Communication Protocol
The MLX90640 utilizes the
I2C communication protocol
with support for FM+ mode, allowing up to
1MHz clock frequency
. It operates solely as a slave device on the I2C bus. Both
SDA
and
SCL
ports are 5V tolerant, enabling direct connection to a 5V I2C network. The sensor’s slave address is programmable, supporting up to 127 different addresses.
I2C write command format (default SA=0x33 is used)
Each session starts with a
START
condition (SDA transitions from HIGH to LOW while SCL is HIGH) and ends with a
STOP
condition (SDA transitions from LOW to HIGH while SCL is HIGH).
I2C read command format (default SA=0x33 is used)
The device is addressed using a
7-bit slave address
followed by a Read/Write bit, where HIGH indicates a read operation and LOW indicates a write operation. Each byte transfer is followed by an
acknowledgment (ACK)
, where the receiver pulls the SDA line low to indicate receipt.
MLX90640 Refresh Rate
The
MLX90640’s refresh rate
can be configured via “Control register 1” (
0x800D
), with options ranging from
0.5Hz
to
64Hz
, corresponding to data updates from every
2 seconds
to every 15.6 milliseconds.
Refresh rate control = 011b (4Hz)
Settings can be permanently saved in the
EEPROM
at address
0x240C
to avoid reconfiguration after power cycling. Accurate temperature calculations require reading from both of

Technologies used

ESP32ArduinoRaspberry PiSTM32BLELCDPythonI2CUART

Hardware components

  • ESP32
  • Arduino
  • Raspberry Pi
  • STM32
  • IR Sensor
  • SD Card

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.