A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.circuitpython.org/projects/tmp007/en/latest/examples.html below:

Website Navigation


Simple test — Adafruit TMP007 Library 1.0 documentation

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)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4