-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_saver.ino
52 lines (43 loc) · 1.14 KB
/
data_saver.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "weather_data.h"
WeatherData getCurrentWeatherData() {
String timestamp = getCurrentTime();
readFromDHT();
WeatherData weatherData = {
timestamp,
DHT.temperature,
DHT.humidity,
getBrightness(),
getNoise()
};
return weatherData;
}
String getWeatherCondition(WeatherData weatherData) {
String weatherCondition;
if (weatherData.temperature > 30) {
weatherCondition = "Hot";
} else if (weatherData.temperature > 20) {
weatherCondition = "Warm";
} else if (weatherData.temperature > 10) {
weatherCondition = "Cool";
} else {
weatherCondition = "Cold";
}
if (weatherData.humidity > 70) {
weatherCondition += " and Humid";
} else if (weatherData.humidity < 30) {
weatherCondition += " and Dry";
}
if (weatherData.humidity > 50 && weatherData.noise > 40) {
weatherCondition += " and Windy";
}
if (isDaytimeNow()) {
if (weatherData.brightness > 200) {
weatherCondition += " - Sunny";
} else if (weatherData.brightness < 20) {
weatherCondition += " - Cloudy";
} else {
weatherCondition += " - Partly Cloudy";
}
}
return weatherCondition;
}