0% found this document useful (0 votes)
19 views16 pages

Lab5 Weather

Weather Station Laboratory using Arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views16 pages

Lab5 Weather

Weather Station Laboratory using Arduino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

CPEN 130 - Embedded Systems

Laboratory Activity 5

Arduino-Based Weather Station for Monitoring Environmental Conditions

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

Monitoring environmental conditions is essential for understanding weather patterns,


managing risks, and making informed decisions across various sectors, including agriculture,
transportation, and disaster preparedness. Weather stations equipped with advanced
sensors enable real-time data collection, providing crucial insights into parameters such as
temperature, humidity, and atmospheric pressure. These measurements not only support
weather forecasting but also enhance our ability to adapt to environmental changes and
optimize resource usage. The integration of microcontrollers like Arduino has revolutionized
the accessibility and affordability of these devices. According to Essiane (2021), Arduino-
based weather stations empower individuals and communities to develop efficient monitoring
systems using readily available components, eliminating the need for expensive,
professional-grade equipment. These systems seamlessly collect, process, and display
environmental data, making them vital tools for improving weather analysis capabilities.
Advances in sensor technology have further enhanced the accuracy and reliability of
weather monitoring, paving the way for better planning and forecasting while mitigating risks
associated with extreme weather conditions.

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.

Materials and Components


 Arduino Uno Board
 Temperature and Humidity Sensor (DHT22)
 Barometric Pressure Sensor (BMP180)
 OLED Display
 Breadboard
 Jumper Wires

CIRCUIT DIAGRAM

Figure 1. Wiring Diagram of the Weather Station


Figure 2. Schematic Diagram of the Weather Station

The schematic diagram illustrates the configuration of a weather station designed to


measure and display environmental conditions. At the core of the system is the Arduino Uno,
which acts as the microcontroller interfacing with all components. The barometric pressure
sensor monitors temperature, humidity, and atmospheric pressure and connects to the
Arduino via its I2C pins (A4 and A5). Its power supply (VCC) is linked to a 3.3V source, and
its ground (GND) connects to the Arduino’s GND. Environmental data is displayed in real
time using an OLED display. The display's SCL and SDA pins are also connected to the
Arduino's I2C pins (A4 and A5), while its DC and CS pins are assigned to digital pins for
control and communication. Additionally, the DHT22 temperature and humidity sensor
interfaces with one of the Arduino’s digital pins for data transmission and uses the 5V and
GND pins for its power supply. This integration of components, paired with the appropriate
software, allows the weather station to effectively monitor and present environmental data.

Procedure

Step 1. Connection of Components


1.1. Setting up the Breadboard
a. Place the Arduino Uno, BMP180 sensor, DHT22 sensor, and OLED display on
the breadboard, ensuring enough space for wiring.
b. Connect the Arduino Uno's GND pin to the negative rail of the breadboard and
the 5V pin to the positive rail of the breadboard.
c. Distribute power and ground to the components by connecting the positive and
negative rails across the breadboard.
1.2. Connect the DHT22 Sensor
a. Connect the VCC pin of the DHT11 sensor to the 5V rail of the breadboard.
b. Connect the GND pin of the DHT11 sensor to the GND rail of the breadboard.
c. Connect the data pin of the DHT11 sensor to digital pin 2 of the Arduino Uno.
1.3: Connect the BMP180 Sensor
a. Connect the VIN pin of the BMP180 sensor to the 3.3V rail of the breadboard.
b. Connect the GND pin of the BMP180 sensor to the GND rail of the breadboard.
c. Connect the SCL pin of the BMP180 sensor to the A5 pin of the Arduino Uno (I2C
clock).
d. Connect the SDA pin of the BMP180 sensor to the A4 pin of the Arduino Uno
(I2C data).
1.4: Connect the OLED Display
a. Connect the VCC pin of the OLED display to the 5V rail of the breadboard.
b. Connect the GND pin of the OLED display to the GND rail of the breadboard.
c. Connect the SCL pin of the OLED display to the A5 pin of the Arduino Uno (I2C
clock).
d. Connect the SDA pin of the OLED display to the A4 pin of the Arduino Uno (I2C
data).

The table below provides a summary of the pin assignments for the various components
connected to the Arduino Uno board:

Components Connection Arduino Pin Description


Assignment
SDA A4 Data line for I2C
communication with
the Arduino.
SCL A5 Clock line for I2C
OLED Display communication with
the Arduino.
VCC 5V Provides power to
the OLED display.
GND GND Ground connection
for the OLED
display.
SDA A4 Data line for I2C
communication with
the Arduino.
SCL A5 Clock line for I2C
communication with
BMP180 Sensor the Arduino.
VCC 5V Provides power to
the BMP180 sensor.
GND GND Ground connection
for the BMP180
sensor.
Data 2 Reads temperature
and humidity data
from the DHT22
sensor.
DHT22 Sensor VCC 5V Provides power to
the DHT22 sensor.
GND GND Ground connection
for the DHT22
sensor.

Table 1. Pin Assignments

Step 2. Code Development or Algorithm Design


a. Connect the DHT22 temperature and humidity sensor, OLED display, and BMP180
barometer pressure sensor before beginning to write the Arduino code for the
weather station system. All components are initialized, I2C connectivity is
established, and the sensors are configured to gather data by the code. After
processing this data, the Arduino produces an output that is easy to understand
and shows the current ambient conditions on the OLED panel.

b. The algorithm is designed to:


 Initialize the sensors and OLED display.
 Read temperature and humidity data from the DHT22 sensor.
 Measure atmospheric pressure and calculate altitude using the BMP180
sensor.
 Format the sensor readings for display.
 Display real-time temperature, humidity, pressure, and altitude on the OLED
screen.
 Continuously update the readings every five seconds for real-time monitoring.
Step 3. Explanation of Logic Used
a. Loop: The loop function continuously executes the processes to collect,
calculate, and display data from the connected sensors. This ensures that the
weather station provides real-time monitoring of temperature, humidity,
atmospheric pressure, and altitude.
b. Conditional Logic: The program uses a structured sequence of logical
conditions to determine actions based on sensor readings:
 Reading Temperature and Humidity: The DHT22 sensor measures the
current temperature and humidity. If the sensor fails to provide valid data, a
warning message is printed in the Serial Monitor to indicate a sensor error.
Otherwise, the valid readings are processed and displayed on the OLED.
 Measuring Atmospheric Pressure and Altitude: The BMP180 sensor is
used to measure atmospheric pressure. If the sensor initialization or data
collection fails, an error message is printed in the Serial Monitor. Otherwise,
the measured pressure is converted to sea-level pressure and used to
calculate altitude. Both pressure and altitude are displayed on the OLED
screen.
 Data Display and Update: Real-time readings of temperature, humidity,
pressure, and altitude are formatted and sent to the OLED display. The OLED
updates every five seconds to provide continuous monitoring without
overwhelming the system or the user with rapid changes.
Step 4. Uploading the Code and Testing the System
After reviewing and ensuring the Arduino code compiles without errors, upload
it to the Arduino board using the Arduino IDE. Once uploaded, power on the system
and test its functionality. Begin by verifying the DHT22 sensor's response to changes
in temperature and humidity, observing the real-time data displayed on the OLED
and confirming its accuracy via the Serial Monitor. Next, test the BMP180 sensor by
measuring atmospheric pressure and altitude, ensuring the displayed sea-level
pressure values align with expectations. Simultaneously, confirm that the OLED
display updates all environmental parameters, including temperature, humidity,
pressure, and altitude, without delay or errors. If issues arise, check the wiring
connections, verify I2C addresses in the code, and ensure all components are
correctly powered. Debug the code for logical errors and perform repeated tests to
guarantee the system's reliability under different environmental conditions.

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();
}
}
}
}

delay(5000); // Wait before next loop


}

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.

The system demonstrated seamless functionality during testing, with environmental


data closely matching external reference sources. The integration of sensors with the
Arduino Uno microcontroller allowed for efficient data processing and display. However,
minor challenges, such as slight sensor drift and occasional inconsistencies due to
fluctuating environmental conditions, were noted. These issues were attributed to the
sensitivity of the sensors to prolonged use and variable environmental factors. Despite minor
limitations, the weather station provided reliable, user-friendly, and portable functionality,
aligning with the expected design and performance criteria.
Test no. Parameters Output Notes
Day 1 (Morning) Temperature (°C) 25.3 Works as expected
Humidity (%) 62.1 Works as expected
Pressure (hPa) 1012.5 Works as expected
Altitude (m) 200 Works as expected
Day 2 (Afternoon) Temperature (°C) 29.7 Works as expected
Humidity (%) 57 Works as expected
Pressure (hPa) 1011.9 Works as expected
Altitude (m) 195 Works as expected
Day 3 (Night) Temperature (°C) 24.1 Works as expected
Humidity (%) 67.3 Works as expected
Pressure (hPa) 1013.2 Works as expected
Altitude (m) 205 Works as expected

Table 2. Output During Testing

Discussions

The Arduino-Based Weather Station demonstrated its capability to accurately monitor


environmental parameters, including temperature, humidity, atmospheric pressure, and
altitude. The integration of the DHT22 and BMP180 sensors, coupled with an OLED display
for real-time visualization, effectively showcased the feasibility of constructing a portable and
cost-efficient weather monitoring system. Testing confirmed the system’s measurements
aligned closely with external weather data, validating its reliability and practical application.

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

Fig 3. Output on the


OLED
Conclusion
The Arduino-based weather station, equipped with DHT22 and BMP180 sensors and
an OLED display, successfully demonstrated its ability to measure and display real-time
environmental conditions such as temperature, humidity, atmospheric pressure, and altitude.
The system's accuracy was validated by cross-referencing its data with online weather
information, ensuring reliable measurements. While the system performed well, some
potential challenges were identified, such as sensor drift, which could affect the long-term
accuracy of measurements, and battery life limitations that may restrict continuous operation
in remote or off-grid locations. To address these issues, future improvements could include
the implementation of regular sensor calibration routines, the exploration of alternative power
sources like solar panels or rechargeable batteries, and the incorporation of more advanced
features, such as predictive weather modeling and seamless IoT integration for remote
monitoring. Moreover, adding wireless communication capabilities would enhance the
system's versatility and enable data sharing with other devices or cloud-based platforms.
Overall, this project not only underscores the potential of Arduino-based systems for
environmental monitoring but also offers a solid foundation for further development,
innovation, and the integration of more sophisticated technologies in the future.
References

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

Fig 5. Member configuring the system

Fig 5. Coding and testing of functionality

You might also like