Reading Values from I2C MLX90614 Infrared Temperature Sensor
Here is the Python code to read values from an I2C MLX90614 infrared temperature sensor:
# -*- coding: UTF-8 -*-
# Experiment effect: Read values from the I2C MLX90614 infrared temperature sensor
# Wiring: Connect an Arduino main control board to a Windows or Linux computer, and connect the infrared temperature sensor to the I2C port SCL and SDA
import time
from pinpong.board import Board
from pinpong.libs.dfrobot_mlx90614 import MLX90614 # Import the mlx90614 library from libs
Board("uno").begin() # Initialization, choose the board type (uno, leonardo, xugu) and port number. If the port number is not entered, automatic recognition will be performed
#Board("uno","COM36").begin() # Initialization with specified port on Windows
#Board("uno","/dev/ttyACM0").begin() # Initialization with specified port on Linux
#Board("uno","/dev/cu.usbmodem14101").begin() # Initialization with specified port on Mac
irt = MLX90614()
while True:
print("Object %s *C"% irt.obj_temp_c()) # Read the object temperature in Celsius (℃)
print("Object %s *F"% irt.obj_temp_f()) # Read the object temperature in Fahrenheit (℉)
print("Ambient %s *C"% irt.env_temp_c()) # Read the ambient temperature in Celsius (℃)
print("Ambient %s *F"% irt.env_temp_f()) # Read the ambient temperature in Fahrenheit (℉)
print() # Empty line
time.sleep(1)