├── libmlx90640.so ├── README.md └── mlx90640.py /libmlx90640.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayeGu/Raspberry-MLX90640/HEAD/libmlx90640.so -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 1.open the i2c 2 | 2.set I2C baudrate on /boot/config.txt file 3 | sudo nano /boot/config.txt 4 | 5 | add the following in the last line 6 | dtparam=i2c1_baudrate=1000000 7 | 8 | 3.reboot raspberrypi 9 | 10 | 4.python3 mlx90640.py 11 | -------------------------------------------------------------------------------- /mlx90640.py: -------------------------------------------------------------------------------- 1 | from ctypes import * 2 | import numpy as np 3 | mlx90640 = cdll.LoadLibrary('./libmlx90640.so') 4 | import matplotlib.pyplot as plt 5 | import time 6 | import smbus 7 | bus=smbus.SMBus(1) 8 | data = bus.read_word_data(0x33,0x800D) 9 | bus.write_word_data(0x33,0x800D,data|0x0380) #设置高帧率模式 10 | # 11 | # mlx90640 will output 32*24 temperature array with chess mode 12 | # 13 | temp=(c_float*768)() 14 | ptemp=pointer(temp) 15 | mlx90640.get_mlx90640_temp(ptemp) 16 | time.sleep(1) 17 | mlx90640.get_mlx90640_temp(ptemp) 18 | plt.figure(1) 19 | while True: 20 | mlx90640.get_mlx90640_temp(ptemp) 21 | img = (temp-np.min(temp))/(np.max(temp)-np.min(temp))*255 #归一化 22 | img.resize(24,32) #将一维数组转化为二维数组,便于转化为图片 23 | #img = img.astype(np.uint8) #opencv处理的话就要 24 | plt.clf() 25 | plt.imshow(img,cmap='jet') # jet/hsv/ranbow/gunplot等颜色模式可以选择,具体见网址https://blog.csdn.net/lly1122334/article/details/88535217 26 | plt.text(16,12,str(round(temp[383],2))+'°C') #显示图像中心的物体温度 27 | plt.pause(0.001) --------------------------------------------------------------------------------