1
1
// /////////////////////////////////////////////////////////////////////////////
2
2
3
- // This is a basic example that demonstrates usage of the Hypnos board
4
- // Deep sleep functionality.
3
+ // This code is for the OPEnS Lab Smart Rock and Smart Rock Beta Group
5
4
6
- // The Hypnos board includes
5
+ // Includes
7
6
// - SD
8
7
// - DS3231 RTC
9
- // - Ability to power of peripherals
8
+ // - Deep Sleep functionality thanks to Hypnos (link below for more information)
9
+ // - EC
10
+ // - Turbidity
11
+ // - Pressure
12
+ // - Temp
10
13
11
14
// Further details about the Hypnos board can be found here:
12
15
// https://github.com/OPEnSLab-OSU/OPEnS-Lab-Home/wiki/Hypnos
@@ -75,19 +78,65 @@ void loop()
75
78
{
76
79
// re-enable pin upon wake up
77
80
pinMode (switchPin, INPUT);
81
+
82
+ // ///////////////////////////////////////////////////////////////////////////////////////////
83
+ // ///////////////////////////////////////////////////////////////////////////////////////////
84
+ // Start of loop that prevents Smart Rock from going to sleep
85
+ // for calibration mode, where continuous data is logged to SD
86
+ NO_SLEEP:
78
87
79
- // ///////////////////////////////////////////
80
88
// change interval depending the on position of pin
81
89
// interval is the variable that gets passed to TimeSpan function below
82
90
switchPos = digitalRead (switchPin);
91
+
92
+
93
+ // delay(1000) function further down in the sketch takes 1000 miliseconds (or 1 second) to
94
+ // ensure SD card has enough time to wake up before next data log
95
+ // minus 1 second from your desired interval time below to gaurantee actual desired inteval
96
+ // Example:
97
+ // 1199 seconds == 19 minutes 59 seconds
98
+ // 1199 seconds + delay() function = 1200 seconds
99
+ // 1200 seconds == 20 minutes
100
+
101
+ // sets all values to 0 upon start of loop
102
+ // do not modify these
83
103
int secs = 0 ;
84
104
int mins = 0 ;
105
+ int hours = 0 ;
106
+ int days = 0 ;
107
+
85
108
if (switchPos == HIGH) {
86
- mins = 1200 ;
109
+
110
+ // modifiable
111
+ // set desired seconds
112
+ secs = 1199 ;
113
+
114
+ // set desired minutes
115
+ mins = 0 ;
116
+
117
+ // set desired hours
118
+ hours = 0 ;
119
+
120
+ // set desired days
121
+ days = 0 ;
122
+
87
123
}else {
88
- secs = 1 ;
89
- }
90
- // ///////////////////////////////////////////
124
+
125
+ Loom.measure ();
126
+ Loom.package ();
127
+ Loom.display_data ();
128
+
129
+ // Log using default filename as provided in configuration
130
+ // in this case, 'datafile.csv'
131
+ Loom.SDCARD ().log ();
132
+
133
+ Loom.pause ();
134
+
135
+ // goes to the beginning of NO_SLEEP loop only if this else block is entered
136
+ goto NO_SLEEP;
137
+ }
138
+ // ////////////////////////////////////////////////////////////////////////////////////////////
139
+ // ////////////////////////////////////////////////////////////////////////////////////////////
91
140
92
141
digitalWrite (5 , LOW); // Disable 3.3V rail
93
142
digitalWrite (6 , HIGH); // Disable 5V rail
@@ -114,7 +163,7 @@ void loop()
114
163
Loom.SDCARD ().log ();
115
164
116
165
// set the RTC alarm to a duration of 10 seconds with TimeSpan
117
- Loom.InterruptManager ().RTC_alarm_duration (TimeSpan (0 , 0 ,mins,secs));
166
+ Loom.InterruptManager ().RTC_alarm_duration (TimeSpan (days,hours ,mins,secs));
118
167
Loom.InterruptManager ().reconnect_interrupt (12 );
119
168
120
169
digitalWrite (13 , LOW);
0 commit comments