Project tutorial
Temperature Indicator with Arduino

Temperature Indicator with Arduino © GPL3+

Learn how to build a temperature gauge thermometer with Arduino, DS18B20 sensor and TM1637 module.

  • 502 views
  • 0 comments
  • 6 respects

Components and supplies

About this project

Introduction

In several systems, there is a need to read the system temperature and to indicate the value for the user. Through these systems, it is possible to monitor its value and to perform interventions to solve problems in the machines or process.

Therefore, through this article, we'll create a temperature indicator using the DS18B20 sensor to read the temperature, the Arduino to process the sensor signal and the TM1637 module to show the temperature value.

Now, we'll initialize the step by step explanation of the project.

Project Development

Initially, we presenting the schematic circuit of the project. in Figure 1. Through this schematic is possible to see all devices used to create the project and its connections.

Based in this circuit, following will be explained all the programming logic of the Arduino.

Programming Logic of the Arduino

Firstly, was declarated all libraries and performed pin definition of the DS18B20 sensor.

#include <OneWire.h>            
#include <DallasTemperature.h>            
#include <TM1637Display.h>            
            
#define ONE_WIRE_BUS 8 //Digital Pin to connect the DS18B20 Sensor            
OneWire oneWire(ONE_WIRE_BUS);            
            
DallasTemperature sensors(&oneWire);            
DeviceAddress sensor1;            

Soon after, was defined the pins used to connect the TM1637 in the Arduino and the vector DEGREES. The vector DEGREES is used to store the degree symbol and the letter C, to signalize the centigrade degrees.

Following, the variables was declared and the code execution flow will enter in the void setup function.

TM1637Display display(2,3);        
        
const uint8_t DEGREES[] = {        
  0x0, 0x0,        
  SEG_A | SEG_B | SEG_G | SEG_F,    // Degree Symbol        
  SEG_A | SEG_F | SEG_E | SEG_D,    // C        
  };        
        
byte PreviousValue = 0;         

After this, in void setup function the DS18B20 sensor will be initialized and the brightness of the TM1637 Display will be configured.

void setup()      
{      
      sensors.begin();      
      display.setBrightness(7);      // set display to maximum brightness      
      if (!sensors.getAddress(sensor1, 0))      
      {                       
        Serial.println("Sensor not found!");      
      }      
}       

Finally, in void loop function will be read the value of temperature through the sensor. Following, the value will be shown in TM1637 display with centigrade symbol.

void loop()      
{      
       //Request sensor data      
       sensors.requestTemperatures();      
       int tempC = sensors.getTempC(sensor1); //Read temperature of DS18B20 Sensor      
                  
            if(tempC != PreviousValue)      
            {      
              PreviousValue = tempC;      
              display.setSegments(DEGREES); //Display the Variable value      
              display.showNumberDec(tempC,false,2,0);      
              delay(2000);      
            }                             
}      

Through the condiction presented below, the value will be shown only when occur a new variation in the value of temperature.

if(tempC != PreviousValue)      

The readed value is shown in Figure 1.

Therefore, through this system was possible create a temperature indicator using Arduino Nano and DS18B20 sensor.

Now, you can create new projects with this temperature indicator.

Acknowledgments

The Silícios Lab thanks PCBWay.com for its support and work together.

Code

Thermometer CodeArduino
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TM1637Display.h>

#define ONE_WIRE_BUS 8 //Digital Pin to connect the DS18B20 Sensor

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress sensor1;

TM1637Display display(2,3);

const uint8_t DEGREES[] = {
   0x0, 0x0,
   SEG_A | SEG_B | SEG_G | SEG_F,    // Degree Symbol
   SEG_A | SEG_F | SEG_E | SEG_D,    // C
   };

unsigned int temperature = 0;
byte PreviousValue = 0;

void setup()
{
       sensors.begin();
       display.setBrightness(7);      // set display to maximum brightness

       if (!sensors.getAddress(sensor1, 0))
       {                 
         Serial.println("Sensor not found!");
       }
}

void loop()
{
        //Request sensor data
        sensors.requestTemperatures();
        int tempC = sensors.getTempC(sensor1); //Read temperature of DS18B20 Sensor
            
             if(tempC != PreviousValue)
             {
               PreviousValue = tempC;
               display.setSegments(DEGREES); //Display the Variable value
               display.showNumberDec(tempC,false,2,0);
               delay(2000);
             }                       
}

Custom parts and enclosures

Electronic Schematic
Uploads2ftmp2f13990fec ef99 4287 aa30 e849141c50a32fcircuito esquema edit jktv0quwl4

Comments

Similar projects you might like

Arduino - Web-Based Thermometer

Project tutorial by khanhhs

  • 13,780 views
  • 13 comments
  • 45 respects

Easy Thermometer v1

Project tutorial by hixel

  • 1,222 views
  • 1 comment
  • 3 respects

Simple Arduino-based Thermometer

Project showcase by circuito.io team

  • 4,518 views
  • 0 comments
  • 13 respects

One Pixel Thermometer

Project tutorial by Ian Cumming

  • 2,265 views
  • 2 comments
  • 7 respects

Storing the Charge State with Arduino

by PCBWay and Silícios Lab

  • 773 views
  • 0 comments
  • 8 respects

Matrix Orbital GTT TFT Thermometer Stage 1

Project tutorial by MatrixOrbital

  • 6,276 views
  • 0 comments
  • 14 respects
Add projectSign up / Login