PROJECT - EASY TO MAKE THERMOMETER

Objective: use a temperature sensor and 7-segment LED display to build a digital thermometer.

You will need: ESP8266 on breakout board (or similar), a Microchip MCP9808 sensor on an Adafruit I2C breakout board, Adafruit 4-digit 7-segment I2C display, breadboard and patch cables.

Exclamation symbolPower rail diagram Don't forget to connect the + and - power rails so that they run the full length of the breadboard - most boards have split rails.

INTRODUCTION

Picture of Adafruit MCP9808

This project shows how you can use a building-block technique to make a digital thermometer using the I2C bus. The temperature sensor is a pre-built Adafruit MCP9808 PCB and displays the temperature on an Adafruit 4-digit 7-segment LED display. Both items are delivered as a kit and you will need to solder the various components together - instructions are on the Adafruit website.

Assembling The Components

Connect together the components as shown here. The Fritzing library does not yet contain the MCP9808 and so I have put a comment box instead. The connections are in the correct sequence for just plugging the MCP9808 into the breadboard.

Fritzing diagram of connections

The Sketch

The ESP8266 reads the temperature, converts it alternately to degrees Celsius and Fahrenheit, works out which characters are required in each position and then displays the temperature. The standard LED functions will display integer, hex and floating point values but we need a composite display showing a numeric value and then C or F as appropriate, for example, -5.6C or 69.0F. The actual range of displayable temperatures is currently -9.9C to 99.9F. If you need a greater range then you would need to omit the decimal and just display -10C or 100F, for example. Alternatively, you could add a second LED display to have up to eight characters.

Changing The I2C Address

Setting I2C address

The MCP9808 has a default I2C address of 0x18. However, you can change this to between 0x19 and 0x1F by connecting one or more of the A0, A1 and A2 connections to VCC. The MCP9808 has pull-down resistors on each address connection and setting them to VCC will change the address. A0 will add 0x01 to the base address of 0x18, A1 will add 0x02 and A2 will add 0x04. For example, to set the address to 0x21 you would connect A0 and A1 to VCC to give 0x18 + 0x01 + 0x02 = 0x21.

You can download the ESP8266 sketch from here.

By taking a copy of the sketch and modifying it, you can create a more useful program that perhaps reads humidity from an appropriate sensor and displays that too, or reads temperatures from a number of sensors.

Do this with an Arduino.