Introduction: Arduino Thermometer(7-Segment)

Using a dual 7-segment display, a DS18B20 temperature sensor and a couple of shift registers I figured that I could build a digital thermometer.

Step 1: Temperature Sensor

The sensor I'm using is the DS18B20, it's a 3pin sensor that just requires a single input pin from the arduino. Multiple sensors can be hooked together, however I'm just using one for this project. As with a lot of different sensors there's a handy library that makes it particularly easy to get the temperature in centigrade or fahrenheit, it's the Dallas_Temperature library available here and a spec sheet for the sensor available from maxim.

To connect it to the arduino connect the ground pin on the sensor to a ground pin on the arduino, put a 4.7k resistor between pin 2 and pin 3 on the sensor, connect pin 3 to 3.3v from the arduino and then connect pin 2 to digital input on the arduino. Once this is done, we're ready to read the temperature!

Step 2: Controlling the Display

I chose to use a dual 7-segment , it didn't take long to figure out the pin outs, however an issue was the number of pins this would require from the arduino if I hooked it up directly, a massive 16. With two shift registers hooked up together this could reduce the number of pins required to only 3, as the two shift registers require only 3 pins and with being hooked together provide 16 parallel outputs.

Step 3: Putting It Together

The code I've put together is at the end of this post. It basically sets up the temperature libraries, reads the temp, and then puts this into the shift registers.

#include OneWire.h
#include DallasTemperature.h

// pin setups
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int tempPin = 7;

// librraries for connecting to sensor
OneWire oneWire(tempPin);
DallasTemperature tempSens(&oneWire);

// characters for displaying on 7-seg display 0-9
byte numberSet[10] = {
B01111011, B01000001, B00110111, B01100111, // 0,1,2,3
B01001101, B01101110, B01111110, B01000011, // 4,5,6,7
B01111111, B01101111 // 8,9

void setup() {
// init serial
// init temp sensor

// set pin modes for shift registors
pinMode(latchPin, OUTPUT);
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);


void loop() {

float t = tempSens.getTempCByIndex(0);

// cast to float (only have 2 digits to use on display)
int rT = (int)t;

// get units of temp
int units = rT % 10;

// get tens value of temp
rT = rT/10;
int tens = rT % 10;

displayNumb(units, tens);


void displayNumb(int a, int b) {
// get the code for the numbers
byte bitsA = numberSet[a];
byte bitsB = numberSet[b];

// set ready to shift out
digitalWrite(latchPin, LOW);

// shift units
shiftOut(dataPin, clockPin, bitsA);
// shift tens
shiftOut(dataPin, clockPin, bitsB);

// shift out data
digitalWrite(latchPin, HIGH);

// shift the data out to the shift registors
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
int i=0;
int pinState;

digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);

// iterate over each bit in the myDataOut byte
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);

if ( myDataOut & (1< pinState= 1;
else {
pinState= 0;

digitalWrite(myDataPin, pinState);
digitalWrite(myClockPin, 1);
digitalWrite(myDataPin, 0);

digitalWrite(myClockPin, 0);

Step 4: Final Build

The temperature is displayed in the dual 7 segment display.


JaredE made it!(author)2015-08-05

The shift registers are probably SN74HC595N from Texas Instruments.

ddani1 made it!(author)2015-05-31

Multiplexing IC name Please???

avuli%C4%87 made it!(author)2013-03-09

which IC you used here

mmendoza10 made it!(author)2011-11-24


nice project, i wonder if i can put an interrupt on this program. I will greatly appreciate if you can help me making it work.Thank you.

rho2k10 made it!(author)2011-11-08

Hello Rahul,
Could you please help out with the schematics? The schematics pic you posted seems very blur.. cant make out what the pinouts are. Thanks!

Simpson_jr made it!(author)2011-11-07

I like your design, using shift registers to free arduino pins is nice and expandable should one want to display really hot or cold temperatures or 1/10 of a degree.

One small detail, you do use Shift-registers, but haven't told which ones, several different ones exist...

About This Instructable




More by rahulkar:LOGO Emulator using AVRLED Blinking With Raspberry PiConnecting 16x2 LCD to Raspberry Pi
Add instructable to: