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, address=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_ct this value will be set to
True
when Ta is above this limitabove_ut: this value will be set to
True
when Ta is above this limitbelow_lt: 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
- property critical_temperature¶
Critical alarm temperature in Celsius
- property lower_temperature¶
Lower alarm temperature in Celsius
- property resolution¶
Temperature Resolution in Celsius
Value
Resolution
Reading Time
0
0.5°C
30 ms
1
0.25°C
65 ms
2
0.125°C
130 ms
3
0.0625°C
250 ms
- property temperature¶
Temperature in Celsius. Read-only.
- property upper_temperature¶
Upper alarm temperature in Celsius