Espruino and an MCP9808 digital temperature sensor

by shedboy712nd December 20160 comments

MCP9808 digital temperature sensor example

The MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C to a digital word with ±0.5°C (max.) accuracy. The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or low-power modes and the specification of temperature Event and Critical output boundaries. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Event signal. The user has the option of setting the event output signal polarity as an active-low or active-high comparator output for thermostat operation, or as temperature event interrupt output for microprocessor-based systems.

The event output can also be configured as a Critical temperature output. This sensor has an industry standard 2-wire, SMBus and Standard I2C™Compatible compatible (100kHz/400kHz bus clock) serial interface, allowing up to eight sensors to be controlled in a single serial bus.

±0.25°C (typical) from -40°C to +125°C
±0.5°C (maximum) from -20°C to +100°C

User Selectable Measurement Resolution:
0.5°C, 0.25°C, 0.125°C, 0.0625°C

User Programmable Temperature Limits:
Temperature Window Limit
Critical Temperature Limit

User Programmable Temperature Alert Output
Operating Voltage Range: 2.7V to 5.5V

More details about the sensor at

This typically comes in a breakout such as the one in the breakout below





Here is the connections I used to connect the MCP9808 module to my Espruino

MCP9808 Pin Espruino Pin
VCC 3.3v




This is a layout of the connection above





I2C1.setup({scl:B6,sda:B7, bitrate: 60000});
var mcp = require("MCP9808").connect(I2C1, 0b000);
setInterval(function() {
  var temperature = mcp.getTemperature();
  console.log("Temperature: " + temperature + " C");
}, 1000);



You should see something like this in the console window of the web ide

Temperature: 19.625 C
Temperature: 19.625 C
Temperature: 19.625 C
Temperature: 19.625 C
Temperature: 19.6875 C
Temperature: 19.625 C
Temperature: 19.6875 C
Temperature: 19.6875 C
Temperature: 19.625 C
Temperature: 19.6875 C
Temperature: 19.6875 C
Temperature: 19.75 C
Temperature: 23.5 C
Temperature: 25.1875 C
Temperature: 26 C
Temperature: 26.625 C
Temperature: 27.125 C
Temperature: 27.625 C
Temperature: 27.625 C


Adafruit MCP9808 High Accuracy I2C Temperature Sensor Breakout Board [ADA1782]

Be Sociable, Share!
Latest posts
Using an MMA7455 accelerometer with an ESP32 board
by shedboy712nd January 2018
MBed LPC1768 and ADXL345 GY-291 example
by shedboy712nd December 2016