Temperature Monitoring With Arduino | Arduino Project

by | Dec 20, 2022 | Arduino, Basic Coding, Coding

Home » Coding » Temperature Monitoring With Arduino | Arduino Project

Introduction

Today we will discuss the Arduino project for temperature monitoring with Arduino. The temperature sensor is used to measure the temperature. It works on the principle of voltage across the diode terminals. If the voltage increases, the temperature also increases, and vice versa.

In this project, we will glow the LEDs based on the rise in the temperature. The components required are readily available at any nearby electronic stores. Or it can also be made online using websites like Tinkercad.

 

Supplies

In order to do Temperature Monitoring With Arduino, we will require the following components:

Components

Circuit Diagram

Steps To Perform Temperature Monitoring With Arduino

Step 1: Gather all the components on the Digital Board or Physical Table.

Step 2: Place 3 LEDs and a Temperature sensor on the BreadBoard.

Step 3: Connect the Anode terminal of the LEDs to pin numbers 2, 3 & 4, respectively, of Arduino Uno.

Step 4: Connect the Resistors to the cathode end of the LED.

Step 5: Connect the second end of the resistor to the GND pin of the Arduino Uno.

Temperature Sensor:

Step 6: Connect the Vout terminal of it to analog pin number A0 of the Arduino.

Step 7: Connect the GND of it to the GND pin of the Arduino using black-colored wire.

Step 8: Connect the power terminal of it to the 5V pin of Arduino using red-colored wire.

Source Code

int base = 0;
int temp = 0;
int status = 0;
float voltage = 0.0;
void setup()
{
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop()
{
base = 0;


status = analogRead(A0);
voltage = status * 5.0;
voltage = voltage/1024.0;


temp = (voltage - 0.5) * 100;
Serial.print(temp);
Serial.print(" C,\n");


if(temp < base)
{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
}


if(temp >= base && temp < base + 50)
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
}


if(temp >= base + 50 && temp < base + 100)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
}


if(temp >= base + 100)
{
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
}


delay(1000);


}

Explanation of the Code

To monitor temperature using Arduino, we need to input the above source code.

1. In the beginning, we initialized four variables to 0.

2. Then, we have two functions: setup and loop.

3. In the setup function, we have initialized serial communication between the Arduino and the sensor.

4. Thereafter, we have declared the pinMode, to denote which pin is for which purpose, input or output.

5. Now, in the loop function, we give the value 0 to the base.

6. Since the input is Analog in nature, we are converting it to digital using these formulas.

7. Serial print is used to print the temperature value in the serial monitor.

8. Now, using the if statement, we are deciding on what temperature to glow and how many LEDs.

9. So, here we are glowing one LED if the base value( temperature) is between 0 to 50.

10. Two LEDs if the temperature is between 50 to 100 and all three if the temperature rises above 100.

11. Lastly, We are using a delay function, which takes time in milliseconds.

Output

Temperature Monitoring With Arduino | Arduino Project

On changing the temperature from -40 to 125 degrees, LEDs will glow as per our programmed code.

  • Below 0-degree temperature – No LED will glow,
  • From 0 to 50 degree – 1 LED will glow,
  • From 50 to 100 – 2 LEDs will glow, and
  • Above 100 – All three LEDs will glow.

This can be used to indicate the temperature based on color code rather than numerical values.

 

You May Also Like To Create…