Automatic temperature detecting system
Automatic temperature detecting system that can be quite helpful to the offices at this time of the pandemic
Components and supplies
5 mm LED: Red
Alphanumeric LCD, 16 x 2
Buzzer, Piezo
Resistor 220 ohm
Ultrasonic Sensor - HC-SR04 (Generic)
Rotary potentiometer (generic)
Temperature Sensor
Arduino UNO
DC Motor, 12 V
PIR Sensor, 7 m
Apps and platforms
Arduino IDE
Tinkercad
Project description
Code
Automatic temperature detecting system
c_cpp
The code of Automatic temperature detecting system
1#include<LiquidCrystal.h> // Include LiquidCrystal library 2 3float temperature; // Variable for storing the input value of temperature sensor 4float voltage; // Variable for storing the given voltage of teperature sensor 5float temp_in_celsius; // Variable for storing the value in celsius 6float temp_in_fahernheit; // Variable for storing the value in fahernheit 7 8const int trigPin = 9; // Trigger pin of ultrasonic sensor 9const int echoPin = 10; // Echo pin of ultrasonic sensor 10long duration; // Variable for storing the input value of ultrasonic sensor 11int distance_in_cm; // Variable for storing the distance in centimeters 12int distance_in_inches; // Variable for storing the distance in Inches 13 14int pir_sensor = 8; // Pin connected to output pin of PIR sensor 15int Motor = 1; // Pin connected to motor 16int Buzzer = 11; // Pin connected to Buzzer 17int Led = 12; // Pin connected to LED 18int tmp_36 = A0; // Pin connected to output pin of temperature sensor 19int i = 0; // Variable for 'if' condiotion 20int s = 0; // Variable for 'while loop' 21 22 23int wait = 500; // delay time 24 25int pir_sensor_value; // Variable for storing the input value of PIR sensor value 26 27LiquidCrystal LCD1(13,A1,A2,A3,A4,A5); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7) for first LCD 28LiquidCrystal LCD2(2,3,4,5,6,7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7) for second LCD 29 30void setup() 31{ 32 33 34 LCD1.begin(16,2); // Initialize first LiquidCrystal display 35 LCD2.begin(16,2); // Initialize second LiquidCrystal display 36 37 pinMode(tmp_36, INPUT); // Set Temperature sensor pin as an INPUT pin 38 pinMode(trigPin, OUTPUT); // Set Trigger pin of ultrasonic sensor as an OUTPUT pin 39 pinMode(echoPin, INPUT); // Set Echo pin of ultrasonic sensor as an INPUT pin 40 pinMode(pir_sensor, INPUT); // Set PIR sensor pin as an INPUT pin 41 pinMode(Buzzer, OUTPUT); // Set Buzzer pin as an OUTPUT pin 42 pinMode(Motor, OUTPUT); // Set Electric Motor pin as an OUTPUT pin 43 pinMode(Led, OUTPUT); // Set LED pin as an OUTPUT pin 44 45 46} 47 48void loop() 49{ 50 pir_sensor_value = digitalRead(pir_sensor); // // See if PIR sensor senses or not 51 52 if (pir_sensor_value == HIGH || i == 1) 53 { 54 while(s<1) 55 { 56 LCD2.print("Alert"); // Print the text .Alert' on second LCD 57 delay(wait); 58 LCD2.clear(); 59 s=1; 60 } 61 62 digitalWrite(trigPin, LOW); // Clears the trigPin condition 63 delayMicroseconds(2); 64 digitalWrite(trigPin, HIGH); // Sets the trigPin HIGH (ACTIVE) for 10 microseconds 65 delayMicroseconds(10); 66 digitalWrite(trigPin, LOW); 67 duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds 68 distance_in_cm = duration*0.0343; 69 distance_in_cm = distance_in_cm/2; // Calculating the distance in centimeters 70 distance_in_inches = distance_in_cm * 0.3937; // Calculating the distance in inches 71 72 73 temperature = analogRead(tmp_36); //getting the voltage reading from the temperature sensor 74 voltage = temperature * 0.0048828125; // converting that reading to voltage 75 temp_in_celsius = (voltage - 0.5) * 100; //converting from 10 mv per degree with 500 mV offset 76 //to degrees ((voltage - 500mV) times 100) 77 temp_in_fahernheit = (temp_in_celsius * 9.0 / 5.0) + 32.0; // now convert to Fahrenheit 78 79 80 if (distance_in_cm < 30) // when the ultrasonic distance is less than 30 81 { 82 LCD1.print("Temp.C :"); 83 LCD1.print(temp_in_celsius); // Print the temperature value in Celsius 84 LCD1.setCursor(0,1); 85 LCD1.print("Temp.F :"); 86 LCD1.print(temp_in_fahernheit); // Print the temperature value in Celsius 87 88 LCD2.print("Distance: "); 89 LCD2 .print(distance_in_cm); // Print the distance of ultrasonic sensor in Centimeters 90 LCD2.print("cm"); 91 LCD2.setCursor(0,1); 92 LCD2.print("Distance: "); 93 LCD2 .print(distance_in_inches); // Print the distance of ultrasonic sensor in Inches 94 LCD2.print("in"); 95 delay(wait); 96 LCD2.clear(); 97 LCD1.clear(); 98 99 if ( temp_in_celsius > 37.5) // When temperature is greater than 37.5 degree celsius 100 { 101 digitalWrite(Buzzer, HIGH); // Buzzer will be turned on 102 digitalWrite(Led, HIGH); // LED will be turned on 103 digitalWrite(Motor, LOW); // Motor will stay off 104 } 105 106 else 107 { 108 digitalWrite(Buzzer, LOW); // Buzzer will stay off 109 digitalWrite(Led, LOW); // LED will stay off 110 digitalWrite(Motor, HIGH); // Motor willbe turned on 111 } 112 } 113 else 114 { 115 116 117 LCD1.print(""); 118 LCD1.setCursor(0,1); 119 LCD1.print(""); 120 121 LCD2.print("Distance: "); 122 LCD2 .print(distance_in_cm); // Print the distance of ultrasonic sensor in Centimeters 123 LCD2.print("cm"); 124 LCD2.setCursor(0,1); 125 LCD2.print("Distance: "); 126 LCD2 .print(distance_in_inches); // Print the distance of ultrasonic sensor in Inches 127 LCD2.print("in"); 128 delay(wait); 129 LCD1.clear(); 130 LCD2.clear(); 131 } 132 i=1; 133 } 134 135 else 136 { 137 i=0; 138 } 139 } 140
Automatic temperature detecting system
c_cpp
The code of Automatic temperature detecting system
1#include<LiquidCrystal.h> // Include LiquidCrystal library 2 3float 4 temperature; // Variable for storing the input value of temperature sensor 5float 6 voltage; // Variable for storing the given voltage of teperature sensor 7float 8 temp_in_celsius; // Variable for storing the value in celsius 9float temp_in_fahernheit; 10 // Variable for storing the value in fahernheit 11 12const int trigPin = 9; // 13 Trigger pin of ultrasonic sensor 14const int echoPin = 10; // Echo pin of ultrasonic 15 sensor 16long duration; // Variable for storing the input value of ultrasonic 17 sensor 18int distance_in_cm; // Variable for storing the distance in centimeters 19int 20 distance_in_inches; // Variable for storing the distance in Inches 21 22int pir_sensor 23 = 8; // Pin connected to output pin of PIR sensor 24int Motor = 1; // 25 Pin connected to motor 26int Buzzer = 11; // Pin connected to Buzzer 27int 28 Led = 12; // Pin connected to LED 29int tmp_36 = A0; // Pin connected 30 to output pin of temperature sensor 31int i = 0; // Variable for 'if' 32 condiotion 33int s = 0; // Variable for 'while loop' 34 35 36int 37 wait = 500; // delay time 38 39int pir_sensor_value; // Variable for storing 40 the input value of PIR sensor value 41 42LiquidCrystal LCD1(13,A1,A2,A3,A4,A5); 43 // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7) for first LCD 44LiquidCrystal 45 LCD2(2,3,4,5,6,7); // Creates an LCD object. Parameters: (rs, enable, d4, 46 d5, d6, d7) for second LCD 47 48void setup() 49{ 50 51 52 LCD1.begin(16,2); 53 // Initialize first LiquidCrystal display 54 LCD2.begin(16,2); // Initialize 55 second LiquidCrystal display 56 57 pinMode(tmp_36, INPUT); // Set Temperature 58 sensor pin as an INPUT pin 59 pinMode(trigPin, OUTPUT); // Set Trigger pin 60 of ultrasonic sensor as an OUTPUT pin 61 pinMode(echoPin, INPUT); // Set Echo 62 pin of ultrasonic sensor as an INPUT pin 63 pinMode(pir_sensor, INPUT); // Set 64 PIR sensor pin as an INPUT pin 65 pinMode(Buzzer, OUTPUT); // Set Buzzer pin 66 as an OUTPUT pin 67 pinMode(Motor, OUTPUT); // Set Electric Motor pin as an 68 OUTPUT pin 69 pinMode(Led, OUTPUT); // Set LED pin as an OUTPUT pin 70 71 72} 73 74void 75 loop() 76{ 77 pir_sensor_value = digitalRead(pir_sensor); // // See if PIR 78 sensor senses or not 79 80 if (pir_sensor_value == HIGH || i == 1) 81 { 82 83 while(s<1) 84 { 85 LCD2.print("Alert"); // Print the text 86 .Alert' on second LCD 87 delay(wait); 88 LCD2.clear(); 89 s=1; 90 91 } 92 93 digitalWrite(trigPin, LOW); // Clears the trigPin condition 94 95 delayMicroseconds(2); 96 digitalWrite(trigPin, HIGH); // Sets the trigPin 97 HIGH (ACTIVE) for 10 microseconds 98 delayMicroseconds(10); 99 digitalWrite(trigPin, 100 LOW); 101 duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns 102 the sound wave travel time in microseconds 103 distance_in_cm = duration*0.0343; 104 105 distance_in_cm = distance_in_cm/2; // Calculating the distance in centimeters 106 107 distance_in_inches = distance_in_cm * 0.3937; // Calculating the distance 108 in inches 109 110 111 temperature = analogRead(tmp_36); //getting the voltage 112 reading from the temperature sensor 113 voltage = temperature * 0.0048828125; // 114 converting that reading to voltage 115 temp_in_celsius = (voltage - 0.5) * 100; 116 //converting from 10 mv per degree with 500 mV offset 117 //to 118 degrees ((voltage - 500mV) times 100) 119 temp_in_fahernheit = (temp_in_celsius 120 * 9.0 / 5.0) + 32.0; // now convert to Fahrenheit 121 122 123 if (distance_in_cm 124 < 30) // when the ultrasonic distance is less than 30 125 { 126 LCD1.print("Temp.C 127 :"); 128 LCD1.print(temp_in_celsius); // Print the temperature 129 value in Celsius 130 LCD1.setCursor(0,1); 131 LCD1.print("Temp.F :"); 132 LCD1.print(temp_in_fahernheit); 133 // Print the temperature value in Celsius 134 135 LCD2.print("Distance: 136 "); 137 LCD2 .print(distance_in_cm); // Print the distance of ultrasonic 138 sensor in Centimeters 139 LCD2.print("cm"); 140 LCD2.setCursor(0,1); 141 142 LCD2.print("Distance: "); 143 LCD2 .print(distance_in_inches); // Print the 144 distance of ultrasonic sensor in Inches 145 LCD2.print("in"); 146 delay(wait); 147 148 LCD2.clear(); 149 LCD1.clear(); 150 151 if ( temp_in_celsius > 37.5) // 152 When temperature is greater than 37.5 degree celsius 153 { 154 digitalWrite(Buzzer, 155 HIGH); // Buzzer will be turned on 156 digitalWrite(Led, HIGH); // LED 157 will be turned on 158 digitalWrite(Motor, LOW); // Motor will stay off 159 160 } 161 162 else 163 { 164 digitalWrite(Buzzer, LOW); // Buzzer will stay 165 off 166 digitalWrite(Led, LOW); // LED will stay off 167 digitalWrite(Motor, 168 HIGH); // Motor willbe turned on 169 } 170 } 171 else 172 { 173 174 175 176 LCD1.print(""); 177 LCD1.setCursor(0,1); 178 LCD1.print(""); 179 180 LCD2.print("Distance: 181 "); 182 LCD2 .print(distance_in_cm); // Print the distance of ultrasonic sensor 183 in Centimeters 184 LCD2.print("cm"); 185 LCD2.setCursor(0,1); 186 LCD2.print("Distance: 187 "); 188 LCD2 .print(distance_in_inches); // Print the distance of ultrasonic 189 sensor in Inches 190 LCD2.print("in"); 191 delay(wait); 192 LCD1.clear(); 193 194 LCD2.clear(); 195 } 196 i=1; 197 } 198 199 else 200 { 201 i=0; 202 203 } 204 } 205
Downloadable files
Automatic temperature detecting system
Working image of the project
Automatic temperature detecting system

Automatic temperature detecting system
The video of working project
Automatic temperature detecting system
Automatic temperature detecting system
Working image of the project
Automatic temperature detecting system

Comments
Only logged in users can leave comments