MLX90640 for Python

We provide an optional add-on for our MLX90640 driver which allows the device to be used from Python applications.

The demonstration application reports temperature readings in degrees celcius.

      
#! /usr/bin/env python

from iotdriversupply.mlx90640 import MLX90640

# Open a connection to the MLX90640 device using the first I2C bus.
mlx = MLX90640( "/dev/i2c-1" )

# Read a frame of 24x32 pixels from the MLX90640.
pixels = mlx.read()

# Draw a grid of the calibrated temperatures.  The driver reads the
# full 32 columns.  For display here we limit to showing only the
# first half.
for r in range( 24 ):
    print " ".join( "{:4.1f}".format( pixels[c][r] ) for c in range( 16 ) ) \
        + " ..."

# Close the driver connection before exiting the script.
mlx.close()
      
    

The following sample output is from a test run on a Jetson Nano. This is a 64-bit device running on an ARM A57 core.

      
ae@jetson:~$ ./mlxtemps.py 
19.7 21.2 22.7 20.9 22.8 23.1 21.8 22.8 20.5 21.3 23.0 20.9 22.5 22.2 21.3 22.1 ...
18.6 20.4 22.3 20.3 22.4 22.8 21.3 22.7 19.6 20.4 22.7 20.3 22.0 22.1 21.0 22.1 ...
23.6 23.7 23.0 23.6 22.8 23.2 23.8 22.8 23.3 23.7 23.2 22.6 22.4 22.4 23.0 22.2 ...
23.1 23.9 22.1 23.3 20.9 22.4 23.9 22.0 23.2 23.5 21.9 22.7 21.3 21.1 23.0 21.3 ...
20.4 20.1 22.7 21.7 22.3 23.5 21.9 22.8 20.8 20.7 22.4 21.4 22.2 22.1 21.1 22.1 ...
19.8 18.1 22.4 21.2 22.3 23.0 21.1 22.7 20.0 19.9 22.3 20.8 21.8 21.9 20.6 22.0 ...
23.7 24.9 23.2 23.5 22.6 23.4 23.8 23.2 23.2 24.1 22.9 22.9 22.4 23.0 23.0 22.2 ...
24.0 27.5 21.7 23.5 21.3 20.0 24.1 22.5 22.9 24.5 21.8 23.2 21.4 21.9 23.1 21.6 ...
20.8 22.7 22.9 21.7 22.2 20.4 21.5 23.1 21.1 22.6 22.4 21.6 22.4 20.5 20.9 22.3 ...
20.2 22.0 23.0 21.0 22.1 19.3 21.2 23.0 21.0 21.9 21.8 21.2 21.8 19.7 20.1 22.2 ...
23.8 22.7 23.2 23.9 22.6 23.3 23.9 23.1 23.5 22.6 22.7 23.0 22.3 23.5 23.1 22.3 ...
23.6 21.4 21.9 23.9 21.7 23.7 24.3 22.1 23.2 21.2 21.2 23.1 21.3 23.3 23.1 21.4 ...
21.7 22.8 23.4 21.4 22.6 21.0 21.1 23.1 21.6 22.3 22.4 21.2 22.1 20.7 20.2 22.1 ...
20.6 22.4 23.2 20.7 22.4 20.2 20.4 22.9 21.2 22.1 22.1 20.7 22.2 20.2 19.8 22.0 ...
23.9 22.7 23.2 24.1 23.1 22.8 24.7 23.0 23.7 22.4 23.6 23.2 22.5 23.0 23.8 22.4 ...
23.8 21.3 17.9 24.3 21.8 23.1 25.2 22.1 23.6 21.4 21.2 23.3 21.7 22.7 24.4 21.1 ...
21.4 22.5 20.7 21.1 22.9 21.2 22.6 22.7 22.0 22.3 20.8 20.9 22.4 21.1 22.4 22.0 ...
20.6 22.2 19.3 20.4 22.7 20.7 22.5 22.5 21.4 22.1 19.3 20.2 22.4 20.4 21.9 22.1 ...
23.7 22.4 23.5 24.1 23.1 23.5 22.7 23.3 23.6 22.7 23.1 23.4 22.7 22.7 22.6 22.3 ...
23.7 21.6 23.4 24.7 22.0 23.5 21.5 21.8 23.6 21.7 23.2 23.4 21.8 22.5 21.4 21.0 ...
21.4 22.8 20.3 21.5 22.8 21.4 22.6 23.2 21.5 22.5 20.9 20.3 22.4 21.2 22.3 22.3 ...
20.6 22.6 19.5 20.9 22.4 21.2 22.3 22.6 21.0 22.3 20.5 19.4 22.3 20.5 22.0 22.3 ...
23.8 22.8 23.1 24.7 23.1 23.9 22.4 23.1 23.2 22.8 23.1 23.7 22.6 22.8 22.6 22.8 ...
24.1 22.0 23.3 25.8 22.1 23.9 21.5 21.4 23.4 22.0 23.0 24.2 21.7 22.9 21.3 21.7 ...
      
    

Device Configuration

Our Python interface also supports reading and modifying the device configuration. These are values that are written to the non-persistent storage of the MLX90640, the settings are used until the device is restarted.

      
#! /usr/bin/env python

from iotdriversupply.mlx90640 import MLX90640

# Open a connection to the MLX90640 device using I2C bus 1 without filling
# the input buffer.  Since this application is not reading from the frame
# buffer, there is no reason to pre-fill the values.
mlx = MLX90640( "/dev/i2c-1", fill=False )

mlx.setInterleaveMode()
mlx.setFramesPerSecond( 16 )
mlx.setADCBits( 18 )

# This application is written in Python 2.  We also provide a Python 3
# compatible implementation.
print "Mode:", "chess" if mlx.isChessMode() else "interleave"
print " FPS:", mlx.getFramesPerSecond()
print "Bits:", mlx.getADCBits()

# Close the driver connection before exiting the script.
mlx.close()
      
    

The following sample output is from a test run on a Raspberry Pi 4. This is a 32-bit build running on an ARM Cortex-A72 core.

      
pi@pi9:~ $ ./mlxconfig.py 
Mode: interleave
 FPS: 16
Bits: 18
      
    

Ordering

More detail, including a pricing sheet, is available upon request.

Thanks for your interest! The pricing sheet for the driver has been sent to .