-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersonalWeatherStation.c
120 lines (98 loc) · 3.36 KB
/
personalWeatherStation.c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Sketch generated by the Arduino IoT Cloud Thing "Personal Weather Station"
https://create.arduino.cc/cloud/things/7c565e14-287a-443d-b0e2-0b58133ea1b3
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
String weather_report;
float humidity;
float pressure;
float temperature;
int light;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
while(ArduinoCloud.connected() != 1) {
ArduinoCloud.update();
delay(500);
}
delay(500);
CARRIER_CASE = false;
carrier.begin();
carrier.display.setRotation(0);
delay(1500);
}
void loop() {
ArduinoCloud.update();
carrier.Buttons.update();
while(!carrier.Light.colorAvailable()){
delay(5);
}
int none;
carrier.Light.readColor(none, none, none, light);
temperature = carrier.Env.readTemperature();
humidity = carrier.Env.readHumidity();
pressure = carrier.Pressure.readPressure();
if(carrier.Buttons.onTouchDown(TOUCH0)) {
carrier.display.fillScreen(ST77XX_WHITE);
carrier.display.setTextColor(ST77XX_RED);
carrier.display.setTextSize(2);
carrier.display.setCursor(30, 110);
carrier.display.print("Temp: ");
carrier.display.print(temperature);
carrier.display.print(" C");
}
if(carrier.Buttons.onTouchDown(TOUCH1)) {
carrier.display.fillScreen(ST77XX_WHITE);
carrier.display.setTextColor(ST77XX_RED);
carrier.display.setTextSize(2);
carrier.display.setCursor(30, 110);
carrier.display.print("Humi: ");
carrier.display.print(humidity);
carrier.display.print(" %");
}
if(carrier.Buttons.onTouchDown(TOUCH2)) {
carrier.display.fillScreen(ST77XX_WHITE);
carrier.display.setTextColor(ST77XX_RED);
carrier.display.setTextSize(2);
carrier.display.setCursor(30, 110);
carrier.display.print("Light: ");
carrier.display.print(light);
}
if(carrier.Buttons.onTouchDown(TOUCH3)) {
carrier.display.fillScreen(ST77XX_WHITE);
carrier.display.setTextColor(ST77XX_RED);
carrier.display.setTextSize(2);
carrier.display.setCursor(30, 110);
carrier.display.print("Pressure: ");
carrier.display.print(pressure);
}
if (humidity >= 60 && temperature >= 15) {
weather_report = "It is very humid outside";
} else if (temperature >= 15 && light >=700) {
weather_report = "Warm and sunny outside";
} else {
weather_report = "Weather is normal";
}
}