This shows you the differences between two versions of the page.
pm:prj2023:tmiu:weathermonitoringsystem [2023/05/05 18:57] malak.safiya [General Description] |
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 18: | Line 18: | ||
The following components are required for this project: | The following components are required for this project: | ||
- | • Arduino Uno board | + | * Arduino board |
- | • BMP280 sensor for measuring temperature, humidity, and air pressure | ||
- | • LCD display (16x2) | + | * DHT11 (RHT01) sensor |
- | • SD card module for logging data | ||
- | • Connecting wires | + | * 1602 LCD screen |
- | • breadboard | ||
- | • Computer with Serial monitor software (such as PuTTY) | + | * 4.7K ohm resistor |
+ | |||
+ | |||
+ | * 10K ohm variable resistor | ||
+ | |||
+ | |||
+ | * 330 ohm resistor | ||
+ | |||
+ | |||
+ | * Breadboard | ||
+ | |||
+ | |||
+ | * Jumper wires | ||
+ | |||
+ | |||
+ | * Computer with Serial monitor software (such as PuTTY) | ||
Line 40: | Line 52: | ||
- | • Arduino Integrated Development Environment (IDE) | + | * Arduino Integrated Development Environment (IDE) |
- | • library for the BMP280 sensor may be needed to read the temperature, humidity, and air pressure data | + | * library for the BMP280 sensor may be needed to read the temperature, humidity, and air pressure data |
- | • 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 52: | 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 80: | 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 | ||