adafruit_mcp9808

CircuitPython library to support MCP9808 high accuracy temperature sensor.

  • Author(s): Scott Shawcroft

Implementation Notes

Hardware:

Software and Dependencies:

Notes:

  1. Datasheet: http://www.adafruit.com/datasheets/MCP9808.pdf
class adafruit_mcp9808.MCP9808(i2c_bus, address=24)[source]

Interface to the MCP9808 temperature sensor.

Parameters:
  • i2c_bus (I2C) – The I2C bus the MCP9808 is connected to.
  • address (int) – The I2C address of the device. Defaults to 0x18

Quickstart: Importing and using the MCP9808

Here is an example of using the MCP9808 class. First you will need to import the libraries to use the sensor

import board
import adafruit_mcp9808

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
mcp = adafruit_mcp9808.MCP9808(i2c_bus)

Now you have access to the change in temperature using the temperature attribute. This temperature is in Celsius.

temperature = mcp.temperature
temperature

Temperature in Celsius. Read-only.