Introduction
This experiment demonstrates how to build a weather station using sensors for temperature, humidity, pressure, and other environmental parameters.
Components Needed
- Temperature Sensor (e.g., DHT22)
- Pressure Sensor (e.g., BMP180)
- Humidity Sensor
- Arduino
- Jumper Wires
Circuit Setup
- Connect all sensors to the Arduino according to the datasheets provided for each sensor.
Code for Weather Station
Upload the following code to your Arduino to collect data from the weather sensors:
#include
#include
#include
Adafruit_BME280 bme;
void setup() {
Serial.begin(9600);
if (!bme.begin()) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C");
Serial.print(" Humidity: ");
Serial.print(humidity);
Serial.print(" %");
Serial.print(" Pressure: ");
Serial.print(pressure);
Serial.println(" hPa");
delay(2000);
}
Explanation
The weather station uses sensors to read environmental data, such as temperature, humidity, and air pressure. The data is then displayed on the Serial Monitor.
Troubleshooting
- If the sensors are not reading data, check the wiring and ensure the sensor addresses are correctly configured.
- If the data looks incorrect, try calibrating the sensors.