We'll be using the MLX90640 IR Thermal Camera Breakout to display an animated image comprised of thermal data to our notebook.

This breakout contains a 24x32 array of IR thermal sensors. When it's connected to the MCP2221, it returns an array of 768 individual infrared temperature readings over I2C. We'll read these values, manipulate, and display them in our Jupyter Notebook.

The MCP2221 and MLX90640 both have STEMMA QT connectors, so you can either wire it up on a breadboard or use a STEMMA QT cable.

You can now add affordable heat-vision to your project and with an Adafruit MLX90640 Thermal Camera Breakout. This sensor contains a 24x32 array of IR thermal sensors. When connected...
Out of Stock
This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of...
Out of Stock

Code Usage

In the Jupyter file browser, click Upload. From the file browser, select the MLX90640 Thermal Camera.ipynb example.

Click the Run button to execute the first cell. This cell first sets an environment variable so Blinka knows we're using the MCP2221 sensor.

Then, it installs the adafruit-circuitpython-mlx90640 library for interfacing with the thermal camera breakout .

The next code cell imports CircuitPython libraries such as board, busio, and adafruit_mlx90640. Then, it initializes an I2C connection with the sensor and creates a mlx object.

We also set the refresh rate to 1HZ for this notebook.

Before continuing, make sure your code prints the MLX was found on I2C.

If it the MCP2221 was unable to detect the MLX breakout, unplug the sensor and plug it back in. Then, restart the Jupyter kernel by clicking Kernel->Restart.

Click run on the next cell. This cell reads data from the thermal camera and splits it into a 32x24 array of thermal readings. We're using the numpy package so we can do perform fast manipulations to the data within the array. 

The next cell plots the data read from the previous cell. Click run to see a heatmap of your data.

This sensor reads the data twice per frame, in a checker-board pattern, so it's normal to see a checker-board dither effect when moving the sensor around - the effect isn't noticable when things move slowly.

The final cell in this notebook produces a live heat-map from your thermal camera. Point the camera towards yourself and click run.

Note: This GIF has been sped up (2x), we suggest moving very slowly to avoid a dithering effect.

This guide was first published on Dec 24, 2019. It was last updated on Dec 24, 2019.

This page (Thermal Camera) was last updated on Oct 25, 2020.