A RetroSearch Logo

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

Search Query:

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

Website Navigation


Simple test — Adafruit TMP006 Library 1.0 documentation

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)

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