Home Projects MCP9808 temperature readings on a Digit Shield Example

MCP9808 temperature readings on a Digit Shield Example

by shedboy71
[lebox id="1"]

In this example we want to display temperature readings from an MCP9808 temperature sensor on an Arduino Digit Shield. We have already looked at the shield and sensor in previous articles.

We have covered the digit shield in the following post

Arduino Digit Shield – link here

We have covered the MCP9808 sensor in the following post

MCP9808 temperature sensor – link here

 

Connection

The shield fits onto your Arduino UNO – so thats easy. The MCP9808 is an I2C device so its easy to connect to the shield header

 

Shield MCP9808
3v3 Vin
Gnd Gnd
A4 SDA
A5 SCl

 

Code

Basically you just have to tray and merge two examples together and you end up a working example, here is our code

[codesyntax lang=”cpp”]

#include <Wire.h>
#include "Adafruit_MCP9808.h"
#include <DigitShield.h>

// Create the MCP9808 temperature sensor object
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();

void setup()
{ 
  // initiliase the DigitShield
  DigitShield.begin();
  // Begin serial connection at 9600 baud for debug
  Serial.begin(9600);
  
  if (!tempsensor.begin()) 
  {
    Serial.println("Couldn't find MCP9808!");
    while (1);
  }
}

void loop()
{
  float c = tempsensor.readTempC();
  DigitShield.setPrecision(2);
  DigitShield.setValue(c);
  delay(250);
  // Wait a while
  tempsensor.shutdown_wake(1);
  delay(1000);
  tempsensor.shutdown_wake(0);
}

[/codesyntax]

 

Video

This example and some of the default examples in the library joined together in this video

 

Links

Digit Shield 4 digit tube display module fast 5641 digital tube module

High Accuracy Temperature Sensor MCP9808 I2C Breakout Board Module 2.7V-5V Logic Voltage for Ardunio in Stock

Share
[lebox id="2"]

You may also like

Leave a Comment