Hackscribble MCP9804 - I2C temperature sensor for Arduino.

Comprehensive library for the Microchip Technology MCP9804 digital temperature sensor.


Taking the temperature.

We like the MCP9804 temperature sensor: small, lots of features, I2C connected and readable data sheet. The accuracy is claimed to be within +/- 1 degree Celsius.

However, when we searched for sample code or an Arduino library for the MCP9804, we could not find anything which made use of all its features. So, we wrote one.

The Hackscribble_MCP9804 library lets you:

  • read the ambient temperature with configurable resolution (down to 0.0625 degrees)
  • set and monitor upper, lower and critical temperature thresholds
  • respond to a hardware alert signal from the MCP9804 when a threshold is exceeded

We have hidden all the complicated details of communications, register addressing and value conversions. Just connect the sensor, specify its I2C address and you can start reading temperatures.

#include <Hackscribble_MCP9804.h> Hackscribble_MCP9804 sensor(0x1B); ... sensor.begin(); Serial.print("Ambient temperature(Ta) = "); Serial.println(sensor.getTAFloat(), 2);

To test the MCP9804, we designed and made a small evaluation board. You can download the designs from the hardware project page.



New! Release 1.0 gives you control over the MCP9804's shutdown mode and threshold locks, and adds more options for the alert output.

Download the library, example sketches and user guide.

  Go to GitHub repository