Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:tmiu:weathermonitoringsystem [2023/05/27 22:03]
malak.safiya [Software Design]
pm:prj2023:tmiu:weathermonitoringsystem [2023/05/30 12:43] (current)
malak.safiya [Bibliography/Resources]
Line 12: Line 12:
        
  
-===== Hardware Design =====+{{:​pm:​prj2023:​tmiu:​project.jpg?​200|}}===== Hardware Design =====
  
  
Line 58: Line 58:
 * Serial monitor software * Serial monitor software
  
 +
 +// Interfacing Arduino with DHT22 humidity and temperature sensor
 + 
 +// include LCD library code
 +#include <​LiquidCrystal.h>​
 +// include DHT library code
 +#include "​DHT.h"​
 + 
 +#define DHTPIN 8            // DHT22 data pin is connected to Arduino pin 8
 + 
 +// LCD module connections (RS, E, D4, D5, D6, D7)
 +LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
 + 
 +#define DHTTYPE DHT22       // DHT22 sensor is used
 +DHT dht(DHTPIN, DHTTYPE); ​  // Initialize DHT library
 + 
 +char temperature[] = "Temp = 00.0 C";
 +char humidity[] ​   = "​RH ​  = 00.0 %";
 +void setup() {
 +  // set up the LCD's number of columns and rows
 +  lcd.begin(16,​ 2);
 +  dht.begin();​
 +}
 + 
 +void loop() {
 +  delay(1000); ​              // wait 1s between readings
 +  // Read humidity
 +  int RH = dht.readHumidity() * 10;
 +  //Read temperature in degree Celsius
 +  int Temp = dht.readTemperature() * 10;
 +  ​
 +  // Check if any reads failed and exit early (to try again)
 +  if (isnan(RH) || isnan(Temp)) {
 +    lcd.clear();​
 +    lcd.setCursor(5,​ 0);
 +    lcd.print("​Error"​);​
 +    return;
 +  }
 + 
 +  if(Temp < 0){
 +    temperature[6] = '​-';​
 +    Temp = abs(Temp);
 +  }
 +  else
 +    temperature[6] = ' ';
 +  temperature[7] ​  = (Temp / 100) % 10  + 48;
 +  temperature[8] ​  = (Temp / 10)  % 10  + 48;
 +  temperature[10] ​ =  Temp % 10 + 48;
 +  temperature[11] ​ = 223;        // Degree symbol ( °)
 +  if(RH >= 1000)
 +    humidity[6] ​   = '​1';​
 +  else
 +    humidity[6] ​   = ' ';
 +  humidity[7] ​     = (RH / 100) % 10 + 48;
 +  humidity[8] ​     = (RH / 10) % 10 + 48;
 +  humidity[10] ​    ​= ​ RH % 10 + 48;
 +  lcd.setCursor(0,​ 0);
 +  lcd.print(temperature);​
 +  lcd.setCursor(0,​ 1);
 +  lcd.print(humidity);​
 +}
        
  
Line 64: Line 125:
  
     ​     ​
-What were the results obtained after the realization of your project.+For example if the temperature = 37.2 °C and this is the value which the Adafruit library returns using the function dht.readTemperature(),​ by multiplying this value by 10 we get 372. 
 +yields: (372 / 100) % 10 = 3 
 +(372 / 10) % 10  = 7 
 +372 % 10  = 2 
 +The number 48 is used to convert decimal numbers to AscII because the LCD works with AscII format. 
 +The line temperature[11] = 223; is for the degree symbol ( °).
  
        
  
 ===== Conclusions =====  ===== Conclusions ===== 
 +The conclusion is that the code converts the floating-point values of temperature and humidity into a formatted string representation with one decimal place. This string representation is stored in character arrays, which can be used to display the values on an LCD or any other output device that can handle character arrays.
 ===== Download ===== ===== Download =====
  
Line 92: Line 158:
  
     ​     ​
-List of documents, datasheets, Internet resources used, possibly grouped by **Software Resources** and **Hardware Resources**.+https://www.youtube.com/​watch?​v=pgOvNURUoT0  
 +https://​www.youtube.com/​watch?​v=l5VVnn-Wl3A  
 +https://​www.youtube.com/​watch?​v=Xsde8OmxxBU  
 +https://​www.youtube.com/​watch?​v=Br79h2zSfKg 
 +https://​www.youtube.com/​@simple-circuit 
  
        
  
  
pm/prj2023/tmiu/weathermonitoringsystem.1685214183.txt.gz · Last modified: 2023/05/27 22:03 by malak.safiya
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0