mlx90614的python程序
时间: 2023-03-29 12:03:18 浏览: 122
以下是 mlx90614 的 Python 程序示例:
```python
import smbus
import time
# MLX90614 default address
MLX90614_I2C_ADDR = x5A
# MLX90614 registers
MLX90614_TA = x06
MLX90614_TOBJ1 = x07
MLX90614_TOBJ2 = x08
# SMBus object
bus = smbus.SMBus(1)
def read_temp(reg):
# Read two bytes from the specified register
raw = bus.read_word_data(MLX90614_I2C_ADDR, reg)
# Convert the raw data to temperature in Celsius
temp = (raw * .02) - 273.15
return temp
while True:
# Read ambient temperature
ta = read_temp(MLX90614_TA)
# Read object temperature 1
tobj1 = read_temp(MLX90614_TOBJ1)
# Read object temperature 2
tobj2 = read_temp(MLX90614_TOBJ2)
# Print the temperatures
print("Ambient temperature: {:.2f} C".format(ta))
print("Object temperature 1: {:.2f} C".format(tobj1))
print("Object temperature 2: {:.2f} C".format(tobj2))
# Wait for 1 second
time.sleep(1)
```
希望能对您有所帮助。
阅读全文