struct WeatherStation {
float temperature;
float humidity;
float pressure;
};
// Use typedef to create a shorter alias for the struct
typedef struct WeatherStation WeatherData;
void setup() {
// Serial communication for debugging purposes
Serial.begin(11520);
}
void loop() {
// Read weather station data
WeatherData currentWeather = readWeatherStation();
// Display the weather station data
displayWeatherData(currentWeather);
// Wait for some time before the next reading
delay(5000);
}
// Function to read weather station data (simulated for this example)
WeatherData readWeatherStation() {
// Simulated weather station data
WeatherData data;
data.temperature = random(18, 28); // Random temperature between 18 and 28 degrees Celsius
data.humidity = random(30, 70); // Random humidity between 30% and 70%
data.pressure = random(980, 1020); // Random pressure between 980 and 1020 hPa
return data;
}
// Function to display weather station data
void displayWeatherData(WeatherData data) {
Serial.print("Temperature: ");
Serial.print(data.temperature);
Serial.print(" °C, Humidity: ");
Serial.print(data.humidity);
Serial.print("%, Pressure: ");
Serial.print(data.pressure);
Serial.println(" hPa");
}