13 lines
427 B
Python
13 lines
427 B
Python
"""CircuitPython I2C MCP9808 Temperature Sensor Example"""
|
|
import time
|
|
import board
|
|
import adafruit_mcp9808
|
|
|
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
|
mcp9808 = adafruit_mcp9808.MCP9808(i2c)
|
|
|
|
while True:
|
|
temperature_celsius = mcp9808.temperature
|
|
temperature_fahrenheit = temperature_celsius * 9 / 5 + 32
|
|
print("Temperature: {} C {} F ".format(temperature_celsius, temperature_fahrenheit))
|
|
time.sleep(2)
|