Skip to content

Commit 9667d14

Browse files
authored
Merge pull request #4 from kattni/example-update
Simplifying simpletest.
2 parents 032c135 + eebcf96 commit 9667d14

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

examples/mcp9600_simpletest.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import time
22
import board
33
import busio
4-
from adafruit_mcp9600 import MCP9600
4+
import adafruit_mcp9600
55

6-
SENSOR_ADDR = 0x67
6+
# frequency must be set for the MCP9600 to function.
7+
# If you experience I/O errors, try changing the frequency.
8+
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
9+
mcp = adafruit_mcp9600.MCP9600(i2c)
710

8-
# try different frequency values if you get an i2c input/output error
9-
i2c = busio.I2C(board.SCL, board.SDA, frequency=200000)
10-
11-
try:
12-
device = MCP9600(i2c,SENSOR_ADDR,"K")
13-
print("version:", device.version)
14-
while True:
15-
print((
16-
device.ambient_temperature,
17-
device.temperature,
18-
device.delta_temperature
19-
))
20-
time.sleep(1)
21-
except ValueError:
22-
print("MCP9600 sensor not detected")
11+
while True:
12+
print((
13+
mcp.ambient_temperature,
14+
mcp.temperature,
15+
mcp.delta_temperature
16+
))
17+
time.sleep(1)

0 commit comments

Comments
 (0)