MCP9808 sensor and LCD keypad shield Arduino example

In this example we will create a temperature meter using a mcp9808 sensor and display the readings on an LCD shield

Lets look at the mcp9808 first

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


An easy sensor to connect which we connect to the LCD keypad shield like this

arduino lcd shield and mcp9808
arduino lcd shield and mcp9808


Parts List

Description Link
Arduino Uno 1pcs UNO R3 CH340G+MEGA328P for Arduino UNO R3 (NO USB CABLE)
LCD Keypad shield 1PCS LCD Keypad Shield LCD 1602 Module Display For Arduino
mcp9808 High Accuracy Temperature Sensor MCP9808 I2C Breakout Board Module 2.7V-5V Logic Voltage for Ardunio in Stock
connecting wire 40pcs Dupont jumper wire cable 30cm male to male,female to female,male to female Dupont jump wire line 2.54mm breadboard cable



In this example we show the connections to a typical LCD shield

lcd shield and bmp180
lcd shield and bmp180



You need to add the adafruit mcp9808 library, this is available in the library manager

#include <Wire.h>
#include <LiquidCrystal.h>
#include "Adafruit_MCP9808.h"
//setup for the LCD keypad shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
void setup()
//init serial for some debug
Serial.println("MCP9808 Sensor Test");
//init MCP9808
if (!tempsensor.begin())
Serial.println("Couldn't find MCP9808!");
while (1);
//init LCD
//line 1 - temperature
lcd.print("Temp = ");
void loop()
//read temperature in
float c = tempsensor.readTempC();
//convert to fahrenheit - not used in this example
float f = c * 9.0 / 5.0 + 32;
//display temperature and altitude on lcd
Serial.print("Temp: "); //debug
Serial.println(c); //debug
lcd.print("Temp = ");