diff --git a/examples/printtemp.py b/examples/printtemp.py new file mode 100644 index 0000000..730d9fe --- /dev/null +++ b/examples/printtemp.py @@ -0,0 +1,14 @@ +import time +import board +import busio +import adafruit_mcp9808 + +# This example shows how to get the temperature from a MCP9808 board +i2c_bus = busio.I2C(board.SCL, board.SDA) +mcp = adafruit_mcp9808.MCP9808(i2c_bus) + +while True: + tempC = mcp.temperature + tempF = tempC * 9 / 5 + 32 + print('Temperature: {} C {} F '.format(tempC, tempF)) + time.sleep(2)