1
- /*
2
- Sketch generated by the Arduino IoT Cloud Thing "bnb"
3
- https://create.arduino.cc/cloud/things/d4947908-6129-40cb-83b8-4b0a58358ad9
1
+ /*
2
+ Sketch generated by the Arduino IoT Cloud Thing
4
3
5
4
Arduino IoT Cloud Properties description
6
5
16
15
*/
17
16
#include < Adafruit_Sensor.h> // for sensor
18
17
#include < DHT.h> // for sensor
19
- #include < DHT_U.h>
18
+ #include < DHT_U.h>
20
19
21
20
#include " thingProperties.h"
22
21
@@ -30,55 +29,52 @@ void setup() {
30
29
// Initialize serial and wait for port to open:
31
30
Serial.begin (9600 );
32
31
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
33
- delay (1500 );
32
+ delay (1500 );
34
33
35
34
// Defined in thingProperties.h
36
35
initProperties ();
37
36
38
37
// Connect to Arduino IoT Cloud
39
- ArduinoCloud.begin (ArduinoIoTPreferredConnection);
40
-
38
+ ArduinoCloud.begin (ArduinoIoTPreferredConnection); // initializes Arduino Cloud
39
+
41
40
/*
42
41
The following function allows you to obtain more information
43
42
related to the state of network and IoT Cloud connection and errors
44
43
the higher number the more granular information you’ll get.
45
44
The default is 0 (only errors).
46
45
Maximum is 4
47
- */
46
+ */
48
47
setDebugMessageLevel (2 );
49
48
ArduinoCloud.printDebugInfo ();
50
- pinMode (ledPin , OUTPUT);
51
- dht.begin ();
52
-
49
+ pinMode (LEDPIN , OUTPUT);
50
+ dht.begin (); // initializes DHT sensor
51
+
53
52
}
54
53
55
54
void loop () {
56
- ArduinoCloud.update ();
57
-
55
+ ArduinoCloud.update (); // updates Arduino Cloud to check for values
58
56
onTemperatureChange ();
59
57
onHumidityChange ();
60
-
61
58
62
59
}
63
60
64
61
65
- void onLightChange ()
62
+ void onLightChange ()
66
63
{
67
64
68
- analogWrite (LEDPIN, light);
65
+ analogWrite (LEDPIN, light); // writes the value of 'light' chosen by widget
69
66
}
70
67
71
68
72
69
void onTemperatureChange ()
73
70
{
74
-
75
- temperature = dht.readTemperature ();
71
+
72
+ temperature = dht.readTemperature (); // reads the temperature from sensor
73
+ // the variable 'temperature' is automatically generated and declared by the cloud
76
74
}
77
75
78
76
void onHumidityChange ()
79
77
{
80
- humidity = dht.readHumidity ();
78
+ humidity = dht.readHumidity (); // reads humidity from sensor
79
+ // the variable 'temperature' is automatically generated and declared by the cloud
81
80
}
82
-
83
-
84
-
0 commit comments