adafruit_mcp9808
CircuitPython library to support MCP9808 high accuracy temperature sensor.
Author(s): Scott Shawcroft, Jose David M.
Implementation Notes
Hardware:
Adafruit MCP9808 High Accuracy I2C Temperature Sensor Breakout (Product ID: 1782)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
Notes:
- class adafruit_mcp9808.MCP9808(i2c_bus: I2C, address: int = 24)[source]
Interface to the MCP9808 temperature sensor.
- Parameters:
- MCP9808 Settings
You could set the MCP9808 with different temperature limits and compare them with the ambient temperature Ta
above_critical: this value will be set to
True
when Ta is above this limitabove_upper: this value will be set to
True
when Ta is above this limitbelow_lower: this value will be set to
True
when Ta is below this limit
To get this value, you will need to read the temperature, and then access the attribute
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 sensorimport board import adafruit_mcp9808
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = 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
- above_critical
True when the temperature is above the currently set critical temperature. False Otherwise
- above_upper
True when the temperature is above the currently set high temperature. False Otherwise
- below_lower
True when the temperature is below the currently set lower temperature. False Otherwise