Skip to content

Commit 50d4adb

Browse files
mrmcwethytannewt
authored andcommitted
added examples folder and .py file
1 parent 1f4ea43 commit 50d4adb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/printtemp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
import board
3+
import busio
4+
import adafruit_mcp9808
5+
6+
# This example shows how to get the temperature from a MCP9808 board
7+
i2c_bus = busio.I2C(board.SCL, board.SDA)
8+
mcp = adafruit_mcp9808.MCP9808(i2c_bus)
9+
10+
while True:
11+
tempC = mcp.temperature
12+
tempF = tempC * 9 / 5 + 32
13+
print('Temperature: {} C {} F '.format(tempC, tempF))
14+
time.sleep(2)

0 commit comments

Comments
 (0)