Skip to content

Commit 5d20bb2

Browse files
Update mcp9808_simpletest.py
The original example code did not show the syntax for setting up a module with anything other than the default address. While this information is to be found in the object definition document, a simple amendment to the sample code gives the default and an amended address example.
1 parent 75be706 commit 5d20bb2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/mcp9808_simpletest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
# This example shows how to get the temperature from a MCP9808 board
77
i2c_bus = busio.I2C(board.SCL, board.SDA)
8-
mcp = adafruit_mcp9808.MCP9808(i2c_bus)
8+
mcp = adafruit_mcp9808.MCP9808(i2c_bus) # Object has only one parameter specified so default address (0x18) is used
9+
10+
# If the address of the module has been changed (eg by connecting A0 to VDD making address 0x19)
11+
# mcp = adafruit_mcp9808.MCP9808(i2c_bus,0x19) # Object now has two parameters - the new address 0x19 being the second one
12+
913

1014
while True:
1115
tempC = mcp.temperature

0 commit comments

Comments
 (0)