Lab5 Weather
Lab5 Weather
Laboratory Activity 5
Submitted by:
Miro G. Angeles
Deen Reinier B. Crusem
Julius Caezar R. Eugenio
BS CPE 4-1
Submitted to:
Prof. Aileen V. Rocillo
December 2024
Laboratory Activity 5
Arduino-Based Weather Station for Monitoring Environmental Conditions
OBJECTIVES
At the end of the experiment, the students should be able to:
1. Design a weather station using various sensors to measure temperature, humidity,
and atmospheric pressure.
2. Integrate sensors with an Arduino to display real-time environmental data.
3. Display sensor data on an OLED display.
4. Understand the functionality of temperature, humidity, and pressure sensors.
Introduction
The barometric pressure sensor, a crucial part of contemporary weather stations, gauges air
pressure to predict changes like storms or clear skies. According to Kumar (2020), variations
in barometric pressure are directly related to changes in the weather, which makes the
sensor essential for precise forecasting. According to Liu et al. (2023), barometric pressure
data is essential for both short-term and long-term weather forecasts since it aids
researchers and meteorologists in understanding atmospheric dynamics. Temperature and
humidity are important environmental factors that weather stations track in addition to
barometric pressure. These parameters are precisely measured by the DHT22 sensor,
which is well-known for its great accuracy. Nasution (2023) highlights that the DHT22 is
particularly valued for its reliability and consistency, making it a preferred choice in both
academic and professional applications. Together, these sensors provide comprehensive
environmental data essential for effective weather analysis. To provide a cohesive system
for tracking and displaying environmental conditions, the weather station combines a number
of different parts. Accurate and real-time data is provided by the DHT22 sensor, which
measures the surrounding temperature and humidity. The barometric pressure sensor helps
predict weather changes by measuring air pressure simultaneously. An OLED panel, which
offers an intuitive user interface for instant information access, displays the gathered data.
The Arduino microcontroller works as the central processing unit, managing the inputs from
sensors and regulating the display output.
CIRCUIT DIAGRAM
Procedure
The table below provides a summary of the pin assignments for the various components
connected to the Arduino Uno board:
Code
#include <Wire.h>
// Read temperature and humidity from DHT11
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> float humi = dht22.readHumidity();
#include <SFE_BMP180.h> float tempC = dht22.readTemperature();
#include <DHT.h>
// Check if DHT22 readings failed
#define SCREEN_WIDTH 128 // OLED display width, in
pixels if (isnan(humi) || isnan(tempC)) {
#define SCREEN_HEIGHT 64 // OLED display height, in Serial.println("Failed to read from DHT11
pixels sensor!");
#define DHT22_PIN 2 } else {
Serial.print("Humidity: ");
// Create display object
Adafruit_SSD1306 oled(SCREEN_WIDTH, Serial.print(humi);
SCREEN_HEIGHT, &Wire, -1); Serial.print("%, Temp: ");
// Create BMP180 object Serial.print(tempC);
SFE_BMP180 pressure;
Serial.println("°C");
// Create DHT22 object
DHT dht22(DHT22_PIN, DHT22);
// Display humidity and temperature on OLED
// Altitude for sea-level pressure calculation oled.clearDisplay();
#define ALTITUDE 1655.0 oled.setCursor(0, 10);
oled.print("Temp: ");
void setup() {
Serial.begin(9600); oled.print(tempC);
dht22.begin(); // Initialize the DHT22 sensor oled.println(" C");
oled.print("Humidity: ");
// Initialize BMP180 (Address is fixed at 0x77)
oled.print(humi);
if (pressure.begin()) {
Serial.println("BMP180 init success"); oled.println(" %");
} else { oled.display();
Serial.println("BMP180 init fail"); }
while (1); // Stop program if BMP180 initialization fails
}
// Start temperature measurement for BMP180
// Initialize OLED display with I2C address 0x3C status = pressure.startTemperature();
if if (status != 0) {
(!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Use delay(status); // Wait for the measurement to
0x3D if I2C scanner shows a different address
complete
Serial.println("SSD1306 allocation failed");
while (1); // Stop program if OLED initialization fails status = pressure.getTemperature(T);
} if (status != 0) {
// Start pressure measurement
delay(2000); // Wait for initialization
status = pressure.startPressure(3);
oled.clearDisplay();
oled.setTextSize(1); if (status != 0) {
oled.setTextColor(WHITE); delay(status); // Wait for pressure measurement
oled.setCursor(0, 10);
oled.println("Hello World!");
status = pressure.getPressure(P, T);
oled.display();
} if (status != 0) {
// Sea-level compensated pressure
void loop() { p0 = pressure.sealevel(P, ALTITUDE);
char status;
a = pressure.altitude(P, p0);
double T, P, p0, a;
// Display pressure and altitude
Serial.print("Pressure: ");
Serial.print(p0);
Serial.println(" mb");
Serial.print("Altitude: ");
Serial.print(a);
Serial.println(" meters");
// Display on OLED
oled.setCursor(0, 30);
oled.print("Pressure: ");
oled.print(p0);
oled.println(" mb");
oled.print("Altitude: ");
oled.print(a);
oled.println(" m");
oled.display();
}
}
}
}
Results
The outcomes of the Arduino-Based Weather Station successfully aligned with the
intended objectives of the project. The system effectively monitored environmental
parameters, including temperature, humidity, atmospheric pressure, and altitude. The
DHT22 sensor accurately recorded temperature and humidity levels, while the BMP180
sensor reliably measured atmospheric pressure and provided altitude data. These readings
were displayed in real time on the OLED screen, ensuring clear and accessible feedback for
the user.
Discussions
Despite its strengths, several challenges emerged during testing. One notable issue
was the occurrence of sensor drift, particularly in varying environmental conditions. Sensor
drift, which involves gradual inaccuracies over time, could compromise long-term reliability.
For instance, the DHT22 and BMP180 sensors occasionally exhibited slight deviations when
subjected to prolonged exposure to fluctuating weather patterns. Additionally, the system's
battery dependency posed limitations on extended operation, especially in off-grid scenarios.
Regular battery replacement or recharging increases maintenance demands, reducing
usability in remote deployments.
Arduino Uno: The Arduino Uno serves as the central microcontroller for the weather station
system, orchestrating communication between all connected components. It processes
sensor inputs from the DHT22 and BMP180, formats the data, and outputs it to the OLED
display. With its versatile digital and analog pins, the Arduino Uno enables seamless
integration of multiple devices. Its ease of use and compatibility with various sensors and
libraries make it an ideal choice for embedded systems. Future upgrades could involve
transitioning to more advanced Arduino boards with increased memory and processing
power to accommodate additional features, such as IoT functionality or predictive modeling.
DHT22 Sensor: The DHT22 sensor serves as a key component in the system, providing
accurate temperature and humidity readings. Its integration allows the weather station to
monitor and display critical environmental data, making it an essential sensor for climate-
based applications. As an affordable and reliable option, it performs well in a variety of
environments, though its performance may degrade over time due to sensor drift. For
improved longevity and precision, future iterations of the system could include calibration
routines or additional sensors to provide more accurate readings.
BMP180 Sensor: The BMP180 sensor measures atmospheric pressure and provides
altitude data, adding a significant layer of environmental awareness to the weather station.
By incorporating this sensor, the system can offer users valuable information not only about
temperature and humidity but also about atmospheric conditions, which are crucial for
weather forecasting. However, similar to the DHT22, sensor drift could impact the accuracy
of long-term readings, especially in varying environmental conditions. Regular calibration
and validation against reliable data sources are recommended to maintain high accuracy
over time.
OLED Display: The OLED display provides a clear and readable interface for displaying the
real-time weather data. Its compact size and high resolution allow for easy visualization of
temperature, humidity, pressure, and elevation. This is especially beneficial in outdoor or
field environments where space and battery efficiency are important. The system’s
portability, aided by the OLED display, ensures that the weather station can be deployed in a
variety of settings, making it a versatile tool for weather monitoring.
Resistors: are essential for maintaining appropriate current levels in the circuit, protecting
the sensors and the OLED display from damage due to overcurrent. They also stabilize
signal transmissions between components. Although often overlooked, their correct usage
ensures the reliability and longevity of the system. Future designs may include precision
resistors for enhanced stability in sensitive connections.
Fig 2. Weather Station Prototype
Kumar, S., & Tanwar, A. (2020). Development of a MEMS-based barometric pressure sensor for
micro air vehicle (MAV) altitude measurement. Microsystem Technologies, 26(3), 901-912.
Liu, Y., Yang, X., Li, J., Zhang, K., Wang, H., Zeng, X., ... & Wang, X. (2023). Microstructured Gel
Polymer Electrolyte and an Interdigital Electrode-Based Iontronic Barometric Pressure Sensor with
High Resolution over a Broad Range. ACS Applied Materials & Interfaces, 15(50), 58976-58983.
Essiane, S. N., & Essama, B. G. O. (2021). Development of a micro weather station using Arduino
and Internet of Things. Physics Education, 57(1), 015005.
Nasution, T. I., & Sinaga, S. H. (2023). Design of monitoring system temperature and humidity using
DHT22 sensor and NRF24L01 based on Arduino. In Journal of Physics: Conference Series (Vol.
2421, No. 1, p. 012018). IOP Publishing.
Appendices
Table 2. DHT22 Temperature and Humidity Sensor Data sheet
Parameters Details/Value
Model DHT22
Type Temperature and Humidity Sensor
Operating Voltage 3.3V to 6V
Data Output Digital (Single-Wire Protocol)
Humidity Range 0% to 100% RH
Temperature Range -40°C to +80°C
Accuracy (Humidity) ±2-5% RH
Accuracy (Temperature) ±0.5°C
Response Time 2 seconds
Power Consumption 2.5mA (active)
Pin out VCC, GND, DATA
Resolution 0.1°C for temperature, 0.1% RH
Parameters Details/Value
Sensor Type Barometric Pressure and Temperature
Sensor
Operating Voltage 1.8V to 3.6V
Typical Supply Voltage 3.3V
Current Consumption 3 µA (ultra-low power mode)
Pressure Range 300 hPa to 1100 hPa
Pressure Resolution 0.01hPa
Temperature Range -40°C to +85°C
Temperature Resolution 0.1°C
I2C Address 0x77 (default)
Altitude Resolution ±1 meter
Output Data Rate Up to 128 Hz
Operating Temperature -40°C to +85°C
Accuracy (Pressure) ±1 hPa
Accuracy (Temperature) ±2°C
Dimensions 3.6 mm × 3.8 mm × 0.93 mm
Table 3. BMP180 Sensor Data Sheet
Fig 4. Implementing the wiring of the system