# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries # SPDX-License-Identifier: MIT """CircuitPython I2C MCP9808 Temperature Sensor Example""" import time import board import adafruit_mcp9808 i2c = board.I2C() # uses board.SCL and board.SDA # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller # import busio # i2c = busio.I2C(board.SCL1, board.SDA1) # For QT Py RP2040, QT Py ESP32-S2 mcp9808 = adafruit_mcp9808.MCP9808(i2c) while True: temperature_celsius = mcp9808.temperature temperature_fahrenheit = temperature_celsius * 9 / 5 + 32 print("Temperature: {:.2f} C {:.2f} F ".format(temperature_celsius, temperature_fahrenheit)) time.sleep(2)