用openmv硬件iic读不出MLX90614的RAM中TOBJ1的值,希望大佬给份代码,附上我的错误代码,求改正
-
import sensor, image, time
from pyb import I2Csensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)i2c = I2C(2) # create on bus 2
i2c.init(I2C.MASTER, baudrate=2000) # 初始化为masterdef data_to_temp(data): #对读取的数据做处理
temp = (data*0.02) - 273.15
return tempMLX90614_RAWIR1=0x04
MLX90614_RAWIR2=0x05
MLX90614_TA=0x06
MLX90614_TOBJ1=0x07
MLX90614_TOBJ2=0x08MLX90614_TOMAX=0x20
MLX90614_TOMIN=0x21
MLX90614_PWMCTRL=0x22
MLX90614_TARANGE=0x23
MLX90614_EMISS=0x24
MLX90614_CONFIG=0x25
MLX90614_ADDR=0x0E
MLX90614_ID1=0x3C
MLX90614_ID2=0x3D
MLX90614_ID3=0x3E
MLX90614_ID4=0x3Fclock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
data = bytearray(16)
i2c.mem_read(data, 0x00, MLX90614_TOBJ1,0, timeout=5000, addr_size=8)
data_to_temp(data)
print(temp)
-
我没有硬件测试,肯定没法写。
我找到了一个网上的,不知道能不能用。https://github.com/mcauser/micropython-mlx90614
-
-
-
我没有硬件肯定没办法测试。感觉你线没连对。