def __init__(self, i2c_address: int = TC74_I2C_ADDRESS, temp_offset_c: float = -5): i2c = board.I2C() sensor = adafruit_tc74.TC74(i2c, address=i2c_address) super().__init__(sensor, temp_offset_c=temp_offset_c) if sensor.shutdown: sensor.shutdown = False if sensor.shutdown: logging.warning("Unable to set TC74 shutdown bit to False") else: logging.info("Successfully set TC74 shutdown bit to False") else: logging.info("TC74 sensor is in normal (non-shutdown) mode")
import time import board import busio import adafruit_tc74 i2c = busio.I2C(board.SCL, board.SDA) tc = adafruit_tc74.TC74(i2c) while True: print(f"Temperature: {tc.temperature} C") time.sleep(0.5)
Note: This adafruit_pct2075 library might not calculate the temperature correctly since the PCT2075 seems to have an accuracy of less than 1 degree Celsius whereas the TC74 only returns whole (integer) degrees Celsius. """ import time import board import busio import adafruit_tc74 TC74_TO_220_I2C_ADDRESS = 0x48 i2c = busio.I2C(board.SCL, board.SDA) tc74 = adafruit_tc74.TC74(i2c, address=TC74_TO_220_I2C_ADDRESS) def main(): if tc74.shutdown: tc74.shutdown = False if tc74.shutdown != False: print("Unable to set shutdown bit to False") else: print("Successfully set shutdown bit to False") else: print("Sensor is in normal (non-shutdown) mode") while True: print(f"Data ready: {tc74.data_ready}") print(f" raw temp: {tc74._temperature:08b}") print(f"Temperature: {tc74.temperature:.1f}")