Simple test

Ensure your device works with this simple test.

examples/tmp006_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7import busio
 8
 9import adafruit_tmp006
10
11
12# Define a function to convert celsius to fahrenheit.
13def c_to_f(c):
14    return c * 9.0 / 5.0 + 32.0
15
16
17# Create library object using our Bus I2C port
18i2c = busio.I2C(board.SCL, board.SDA)
19sensor = adafruit_tmp006.TMP006(i2c)
20
21# Initialize communication with the sensor, using the default 16 samples per conversion.
22# This is the best accuracy but a little slower at reacting to changes.
23# The first sample will be meaningless
24while True:
25    obj_temp = sensor.temperature
26    print(f"Object temperature: {obj_temp:0.3F}*C / {c_to_f(obj_temp):0.3F}*F")
27    time.sleep(5.0)