Skip to content

Commit a344b82

Browse files
author
Kenneth Kang
authored
Merge pull request #129 from OPEnSLab-OSU/RTC
Update SmartRock Workshop code
2 parents 5eac251 + f44aed6 commit a344b82

File tree

2 files changed

+86
-38
lines changed

2 files changed

+86
-38
lines changed

examples/Lab Examples/SmartRock_Workshop/SmartRock_Workshop.ino

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
///////////////////////////////////////////////////////////////////////////////
22

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
54

6-
// The Hypnos board includes
5+
// Includes
76
// - SD
87
// - 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
1013

1114
// Further details about the Hypnos board can be found here:
1215
// https://github.com/OPEnSLab-OSU/OPEnS-Lab-Home/wiki/Hypnos
@@ -75,19 +78,65 @@ void loop()
7578
{
7679
//re-enable pin upon wake up
7780
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:
7887

79-
/////////////////////////////////////////////
8088
//change interval depending the on position of pin
8189
//interval is the variable that gets passed to TimeSpan function below
8290
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
83103
int secs = 0;
84104
int mins = 0;
105+
int hours = 0;
106+
int days = 0;
107+
85108
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+
87123
}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+
//////////////////////////////////////////////////////////////////////////////////////////////
91140

92141
digitalWrite(5, LOW); // Disable 3.3V rail
93142
digitalWrite(6, HIGH); // Disable 5V rail
@@ -114,7 +163,7 @@ void loop()
114163
Loom.SDCARD().log();
115164

116165
// 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));
118167
Loom.InterruptManager().reconnect_interrupt(12);
119168

120169
digitalWrite(13, LOW);
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
"{\
2-
'general':\
3-
{\
4-
'name':'Device',\
5-
'instance':1\
6-
},\
7-
'components':[\
8-
{\
9-
'name':'Analog',\
10-
'params':[8,12,true,false,true,false,false,false,5,0,4,0,0,0]\
11-
},\
12-
{\
13-
'name':'SD',\
14-
'params': [true,1000,10,'data',true]\
15-
},\
16-
{\
17-
'name':'DS3231',\
18-
'params':[11, true, false]\
19-
20-
},\
21-
{\
22-
'name':'Interrupt_Manager',\
23-
'params':'default'\
24-
},\
25-
{\
26-
'name':'Sleep_Manager',\
27-
'params':[true,false,1]\
28-
},\
2+
'general':\
3+
{\
4+
'name':'Device',\
5+
'instance':1\
6+
},\
7+
'components':[\
8+
{\
9+
'name':'Analog',\
10+
'params':[8,12,true,false,true,false,false,false,5,0,4,0,0,0]\
11+
},\
12+
{\
13+
'name':'SD',\
14+
'params': [true,1000,10,'data',true]\
15+
},\
16+
{\
17+
'name':'DS3231',\
18+
'params':[11, true, true]\
19+
},\
20+
{\
21+
'name':'Interrupt_Manager',\
22+
'params':'default'\
23+
},\
24+
{\
25+
'name':'Sleep_Manager',\
26+
'params':[true,false,1]\
27+
},\
2928
{\
3029
'name':'MS5803',\
3130
'params':[119]\
3231
}\
33-
]\
32+
]\
3433
}"

0 commit comments

Comments
 (0)