Пример #1
0
while (not flag_exit):
    tObject = 0
    tAmbient = 0
    listTObject = []
    listTAmbient = []
    meanTObjecto = 0
    meanTAmbient = 0
    stadevTObjecto = 0
    stadevTAmbient = 0

    print(
        "mensagem curta com explicação para se aproximar a testa a 3 cm do sensor, mas sem tocar, ficar parado por tantos segundos"
    )
    measurements = 0
    while (measurements < NUM_TEMPERATURE_MEASUREMENTS and not flag_exit):
        tObject, tAmbient = MLX90615.Read_MLX90615_Temperatures()
        sleep_ms(TIME_MS_BETWEEN_TEMPERATURE_MEASUREMENTS)
        if (tObject < MAX_TEMPERATURE_ACCEPTABLE
                and tObject > MIN_TEMPERATURE_ACCEPTABLE):
            measurements += 1
            listTObject.append(tObject)
            listTAmbient.append(tAmbient)
            print("Medindo, fique parado")

    if (measurements == NUM_TEMPERATURE_MEASUREMENTS):
        meanTObjecto = statistics.mean(listTObject)
        meanTAmbient = statistics.mean(listTAmbient)

        stadevTObjecto = statistics.pstdev(listTObject)
        stadevTAmbient = statistics.pstdev(listTAmbient)
Пример #2
0
import MLX90615, time

mlx90615 = MLX90615.MLX90615(0) # Creates an mlx90615 instance on I2C bus 0.

while True:
    print("Object Temperature: ", mlx90615.temperature()) # Prints the temperature in Celcius of the object the MLX90615 is pointing at.
    print("Ambient Temperature: ", mlx90615.ambient()) # Prints the temperature in Celcius of the MLX90615 package.
    print("Raw data: ", mlx90615.raw()) # Prints the raw ir sensor data.
    print("-"*50)
    time.sleep(1)