mcp9808_simpletest.py
1 import time 2 import board 3 import busio 4 import adafruit_mcp9808 5 6 i2c_bus = busio.I2C(board.SCL, board.SDA) 7 8 # To initialise using the default address: 9 mcp = adafruit_mcp9808.MCP9808(i2c_bus) 10 11 # To initialise using a specified address: 12 # Necessary when, for example, connecting A0 to VDD to make address=0x19 13 # mcp = adafruit_mcp9808.MCP9808(i2c_bus, address=0x19) 14 15 16 while True: 17 tempC = mcp.temperature 18 tempF = tempC * 9 / 5 + 32 19 print("Temperature: {} C {} F ".format(tempC, tempF)) 20 time.sleep(2)