Simple test
Ensure your device works with this simple test.
examples/tmp007_simpletest.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4#!/usr/bin/python
5# Author: Adapted to CircuitPython by Jerry Needell
6# Adafruit_Python_TMP example by Tony DiCola
7#
8
9import time
10
11import board
12import busio
13
14import adafruit_tmp007
15
16
17# Define a function to convert celsius to fahrenheit.
18def c_to_f(c):
19 return c * 9.0 / 5.0 + 32.0
20
21
22# Create library object using our Bus I2C port
23i2c = busio.I2C(board.SCL, board.SDA)
24sensor = adafruit_tmp007.TMP007(i2c)
25
26
27# Initialize communication with the sensor, using the default 16 samples per conversion.
28# This is the best accuracy but a little slower at reacting to changes.
29# The first sample will be meaningless
30while True:
31 die_temp = sensor.die_temperature
32 print(f" Die temperature: {die_temp:0.3F}*C / {c_to_f(die_temp):0.3F}*F")
33 obj_temp = sensor.temperature
34 print(f"Object temperature: {obj_temp:0.3F}*C / {c_to_f(obj_temp):0.3F}*F")
35 time.sleep(5.0)