CircuitPython driver for the MCP9600 thermocouple I2C amplifier

  • Author(s): Dan Cogliano, Kattni Rembor

Implementation Notes


Software and Dependencies:

class adafruit_mcp9600.MCP9600(i2c: I2C, address: int = 103, tctype: str = 'K', tcfilter: int = 0)

Interface to the MCP9600 thermocouple amplifier breakout

  • i2c (I2C) – The I2C bus the MCP9600 is connected to.

  • address (int) – The I2C address of the device. Defaults to 0x67

  • tctype (str) – Thermocouple type. Defaults to "K"

  • tcfilter (int) – Value for the temperature filter. Can limit spikes in temperature readings. Defaults to 0

Quickstart: Importing and using the MCP9600 temperature sensor

Here is one way of importing the MCP9600 class so you can use it with the name mcp. First you will need to import the libraries to use the sensor

import busio
import board
import adafruit_mcp9600

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

i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
mcp = adafruit_mcp9600.MCP9600(i2c)

Now you have access to the change in temperature using the delta_temperature attribute, the thermocouple or hot junction temperature in degrees Celsius using the temperature attribute and the ambient or cold-junction temperature in degrees Celsius using the ambient_temperature attribute

delta_temperature = mcp.delta_temperature
temperature = mcp.temperature
ambient_temperature = mcp.ambient_temperature
alert_1 = 4

Alert 1 status.

alert_2 = 4

Alert 2 status.

alert_3 = 4

Alert 3 status.

alert_4 = 4

Alert 4 status.

alert_config(*, alert_number: int, alert_temp_source: int, alert_temp_limit: float, alert_hysteresis: float, alert_temp_direction: int, alert_mode: int, alert_state: int) None

Configure a specified alert pin. Alert is enabled by default when alert is configured. To disable an alert pin, use alert_disable().

  • alert_number (int) – The alert pin number. Must be 1-4.

  • alert_temp_source – The temperature source to monitor for the alert. Options are: THERMOCOUPLE (hot-junction) or AMBIENT (cold-junction). Temperatures are in Celsius.

  • alert_temp_limit (float) – The temperature in degrees Celsius at which the alert should trigger. For rising temperatures, the alert will trigger when the temperature rises above this limit. For falling temperatures, the alert will trigger when the temperature falls below this limit.

  • alert_hysteresis (float) – The alert hysteresis range. Must be 0-255 degrees Celsius. For rising temperatures, the hysteresis is below alert limit. For falling temperatures, the hysteresis is above alert limit. See data-sheet for further information.

  • alert_temp_direction – The direction the temperature must change to trigger the alert. Options are RISING (heating up) or FALLING (cooling down).

  • alert_mode – The alert mode. Options are COMPARATOR or INTERRUPT. In comparator mode, the pin will follow the alert, so if the temperature drops, for example, the alert pin will go back low. In interrupt mode, by comparison, once the alert goes off, you must manually clear it. If setting mode to INTERRUPT, use alert_interrupt_clear() to clear the interrupt flag.

  • alert_state – Alert pin output state. Options are ACTIVE_HIGH or ACTIVE_LOW.

For example, to configure alert 1:

import board
import busio
import digitalio
import adafruit_mcp9600

i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
mcp = adafruit_mcp9600.MCP9600(i2c)
alert_1 = digitalio.DigitalInOut(board.D5)

mcp.alert_config(alert_number=1, alert_temp_source=mcp.THERMOCOUPLE,
                 alert_temp_limit=25, alert_hysteresis=0,
                 alert_temp_direction=mcp.RISING, alert_mode=mcp.COMPARATOR,
alert_disable(alert_number: int) None

Configuring an alert using alert_config() enables the specified alert by default. Use alert_disable() to disable an alert pin.


alert_number (int) – The alert pin number. Must be 1-4.

alert_interrupt_clear(alert_number: int, interrupt_clear: bool = True) None

Turns off the alert flag in the MCP9600, and clears the pin state (not used if the alert is in comparator mode). Required when alert_mode is INTERRUPT.

  • alert_number (int) – The alert pin number. Must be 1-4.

  • interrupt_clear (bool) – The bit to write the interrupt state flag

ambient_resolution = 6

Ambient (cold-junction) temperature resolution. Options are AMBIENT_RESOLUTION_0_0625 (0.0625 degrees Celsius) or AMBIENT_RESOLUTION_0_25 (0.25 degrees Celsius).

property ambient_temperature: float

Cold junction/ambient/room temperature in Celsius

burst_complete = 4

Burst complete.

burst_mode_samples = 3

The number of samples taken during a burst in burst mode. Options are BURST_SAMPLES_1, BURST_SAMPLES_2, BURST_SAMPLES_4, BURST_SAMPLES_8, BURST_SAMPLES_16, BURST_SAMPLES_32, BURST_SAMPLES_64, BURST_SAMPLES_128.

property delta_temperature: float

Delta between hot junction (thermocouple probe) and cold junction (ambient/room) temperatures in Celsius

input_range = 4

Input range.

shutdown_mode = 2

Shutdown modes. Options are NORMAL, SHUTDOWN, and BURST.

property temperature: float

Hot junction temperature in Celsius

temperature_update = 4

Temperature update.

property version: int

MCP9600 chip version