Datasheet
sudo pip3 install adafruit-circuitpython-mlx90640
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use
CircuitPython on Python 2.x, it isn't supported!
CircuitPython & Python Usage
To demonstrate the usage of the sensor we'll run the mlx90640_simpletest.py program which prints the temperatures
or shows them as ASCII. As this example is too complicated to run from the REPL, you'll save the following code to your
board as code.py and connect to the serial console to see the output.
import time
import board
import busio
import adafruit_mlx90640
PRINT_TEMPERATURES = False
PRINT_ASCIIART = True
i2c = busio.I2C(board.SCL, board.SDA, frequency=800000)
mlx = adafruit_mlx90640.MLX90640(i2c)
print("MLX addr detected on I2C")
print([hex(i) for i in mlx.serial_number])
mlx.refresh_rate = adafruit_mlx90640.RefreshRate.REFRESH_2_HZ
frame = [0] * 768
while True:
stamp = time.monotonic()
try:
mlx.getFrame(frame)
except ValueError:
# these happen, no biggie - retry
continue
print("Read 2 frames in %0.2f s" % (time.monotonic()-stamp))
for h in range(24):
for w in range(32):
t = frame[h*32 + w]
if PRINT_TEMPERATURES:
print("%0.1f, " % t, end="")
if PRINT_ASCIIART:
c = '&'
# pylint: disable=multiple-statements
if t < 20: c = ' '
elif t < 23: c = '.'
elif t < 25: c = '-'
elif t < 27: c = '*'
elif t < 29: c = '+'
elif t < 31: c = 'x'
elif t < 33: c = '%'
elif t < 35: c = '#'
elif t < 37: c = 'X'
# pylint: enable=multiple-statements
print(c, end="")
print()
print()
© Adafruit Industries https://learn.adafruit.com/adafruit-mlx90640-ir-thermal-camera Page 20 of 30










