National University of Science and Technology School of Electrical Engineering and Computer Science Department of Electrical Engineering Faculty Member: Dr. Ahmad Rasheed Dated: 12/10/22 Lab Engineer: Engr. Ali Semester: 5th Section: BEE-12D EE-383-Instrumentation and Measurements Lab 5 Arduino Task: Temperature Sensing using Arduino Viva + Lab Performance (Individual) Name Analysis of data in Lab Report Teamwork Total 5 Marks 20 Marks Reg. No 5+5 Marks Arif Iqbal 334371 Muhammad Zaid Iftikhar 334845 Sami Ullah 333816 Yaminah Shafique 334227 5 Marks Temperature Sensing using Arduino Equipment used: DHT11 – Temperature and Humidity Sensor Arduino UNO LEDs Bread Board Jumper Wires Task Code: //Including libraries #include <LiquidCrystal.h> #include "DHT.h" DHT dht; const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 6; //declaring constants for pins LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //initializing lcd void setup() { Serial.begin(9600);//setting up serial frequency Serial.println(); Serial.println("Status\tHumidity (%)\tTemperature (C)");//display on serial monitor dht.setup(2);//initializing sensor with the pin it is attached with on arduino lcd.begin(16, 2); //setting up lcd with its number of columns and rows lcd.print("Temp Hum"); //printing the heading on lcd. this needs to be done once } void loop() { delay(dht.getMinimumSamplingPeriod()*2); float humidity = dht.getHumidity(); //delay in loop for sampling of the sensor //gets humidity level float temperature = dht.getTemperature(); //gets temperature value Serial.print(dht.getStatusString()); //prints the status of the sensor Serial.print("\t");//displays on the serial monitor Serial.print(humidity, 1); Serial.print("\t\t"); Serial.print(temperature, 1); Serial.print("\t\t"); lcd.setCursor(0, 1); lcd.print(temperature); lcd.setCursor(9, 1); lcd.print(humidity); } Simulation: Results on serial monitor Hardware Pic Conclusion This task was implemented on Arduino mega 2560, DHT11 sensor and 16x2 LCD. The pictures of the implementation have been attached above. This lab familiarized students with DHT11 sensor and Arduino. Students got knowledge of interfacing the sensor with Arduino. The results received from the sensor were displayed on serial monitor as well as 16x2 LCD which was also connected to Arduino.