Thermal Camera April 2024
Python driver for the MLX90640 thermal sensor, using an Arduino as a simple I2C to serial relay.
The MLX90640 is a neat little thermal sensor with a resolution of just 32x24 pixels. That doesn't sound like much, but it's plenty for recognizing a person, as you can see in the animation.
ATmega-based Arduinos like the Arduino Nano don't have enough RAM to hold the 16-bit image in memory, so the usual MLX90640 libraries don't work. Instead, my code uses the Arduino as a simple I2C to serial relay and leaves all of the calibration and image processing to Python code running on the computer. The calibration math comes straight from the datasheet and is implemented with numpy. (The sensor reads its pixels in two passes using an interleaved checkerboard pattern, which is why you can see a checkerboard around anything that moves quickly.)
I also mounted the sensor on a motorized pan-tilt head and wrote a follow mode that steers it toward the warmest thing in view!
Links: GitHub