Skip to content

Commit

Permalink
Merge pull request #89 from OPEnSLab-OSU/main-failed-to-close
Browse files Browse the repository at this point in the history
Stability improvement patch
  • Loading branch information
WL-Richards authored Oct 2, 2023
2 parents 4599733 + 2d3d18f commit 7779fc4
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 79 deletions.
5 changes: 3 additions & 2 deletions examples/Hypnos/Adalogger_Sleep/Adalogger_Sleep.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void setup() {
}

void loop() {
// Set the RTC interrupt alarm to wake the device in 10 seconds, done at top so evenly spaced sample periods
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));

// Measure and package data
manager.measure();
Expand All @@ -47,8 +49,7 @@ void loop() {
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));


// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();
Expand Down
6 changes: 4 additions & 2 deletions examples/Hypnos/Hypnos_SD_Sleep/Hypnos_SD_Sleep.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ void setup() {

void loop() {

// Set the RTC interrupt alarm to wake the device in 10 seconds, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));

// Measure and package data
manager.measure();
manager.package();
Expand All @@ -48,8 +51,7 @@ void loop() {
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));


// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ void setup() {
}

void loop() {

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(sleepInterval);

// Print the current JSON packet
manager.display_data();

// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(sleepInterval);

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
6 changes: 4 additions & 2 deletions examples/Internet/Logging/LTEBatch/LTEBatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ void setup() {
}

void loop() {
// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));

// Package data
manager.package();

Expand All @@ -58,8 +61,7 @@ void loop() {
// Pass batch SD along to the MQTT module
mqtt.publish(batchSD);

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 10));


// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();
Expand Down
7 changes: 4 additions & 3 deletions examples/Lab Examples/Evaporometer/Evaporometer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ void setup(){
}

void loop(){

// Set the RTC interrupt alarm to wake the device in 30 seconds, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 30));

// Measure and package the data from the sensors
manager.measure();
manager.package();
Expand All @@ -46,9 +50,6 @@ void loop(){
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 30 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 30));

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
7 changes: 4 additions & 3 deletions examples/Lab Examples/FloDar/FloDar.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ void setup() {

void loop() {

// Set the RTC interrupt alarm to wake the device in 10 seconds, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Measure and package data
manager.measure();
manager.package();
Expand All @@ -51,9 +54,7 @@ void loop() {
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));


// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
40 changes: 18 additions & 22 deletions examples/Lab Examples/MultipleInterrupts/MultipleInterrupts.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,15 @@ void wakeTrigger(){
}

void tipTrigger() {
tip_time = millis();

// Check if the time of the last tip is more than 250 ms to debounce the switch
if(tip_time - last_tip_time > 250){
counter++;
tipFlag = true;
detachInterrupt(INT_PIN);
}
hypnos.shouldPowerUp = false;
tipFlag = true;
detachInterrupt(INT_PIN);
}

void setup() {

// Set the interrupt pin to pullup
pinMode(INT_PIN, INPUT_PULLUP);
// Set the interrupt pin to INPUT
pinMode(INT_PIN, INPUT);

// Wait 20 seconds for the serial console to open
manager.beginSerial();
Expand All @@ -62,36 +57,37 @@ void setup() {

void loop() {

// If we are waking up normally then we should sample data
if(sampleFlag) {
if(sampleFlag){
// Set the RTC interrupt alarm to wake the device in 15 min, this should be done as soon as the device enters sampling mode for consistant sleep cycles
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Measure and package the data
manager.measure();
manager.package();
manager.addData("Switch", "Status", counter);

// Print the current JSON packet
manager.display_data();

// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device every 30 seconds
hypnos.setInterruptDuration(TimeSpan(0, 0, 0, 30));

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

sampleFlag = false; // Do not do this process unless ISR sets the flag
attachInterrupt(INT_PIN, tipTrigger, FALLING);
attachInterrupt(INT_PIN, tipTrigger, FALLING);
sampleFlag = false;
}

// Check if Tipping Bucket event
if(tipFlag) {
if(tipFlag){
digitalWrite(LED_BUILTIN, HIGH);
delay(20);
bucket.incrementCount();
tipFlag = false;
Serial.println(counter);
attachInterrupt(INT_PIN, tipTrigger, FALLING);
attachInterrupt(INT_PIN, tipTrigger, FALLING);
digitalWrite(LED_BUILTIN, LOW);
}

// Put the device into a deep sleep
// Put the device into a deep sleep, operation HALTS here until the interrupt is triggered
hypnos.sleep();
}
6 changes: 3 additions & 3 deletions examples/Lab Examples/SmartRock/SmartRock/SmartRock.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void setup() {

void loop() {

// Set the RTC interrupt alarm to wake the device in 10 seconds, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(sleepInterval);

// Measure and package the data
manager.measure();
manager.package();
Expand All @@ -58,9 +61,6 @@ void loop() {
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(sleepInterval);

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
5 changes: 3 additions & 2 deletions examples/Lab Examples/SmartRock/SmartRock2.5/SmartRock2.5.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ void setup() {
}

void loop() {

// Set the RTC interrupt alarm to wake the device in 10 seconds, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(sleepInterval);

// Measure and package the data
manager.measure();
Expand All @@ -55,8 +58,6 @@ void loop() {
// Log the data to the SD card
hypnos.logToSD();

// Set the RTC interrupt alarm to wake the device in 10 seconds
hypnos.setInterruptDuration(sleepInterval);

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();
Expand Down
5 changes: 4 additions & 1 deletion examples/Lab Examples/Wattson/Wattson.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
Manager manager("Device", 1);
//Loom_WIFI wifi(manager, CommunicationMode::AP); // For AP
Loom_WIFI wifi(manager, CommunicationMode::CLIENT, SECRET_SSID, SECRET_PASS); // For Client

// Create a new instance of max this takes in the WiFi object so we can communicate with the computer in addition to adding a controllable neopixel
Loom_Max maxMsp(manager, wifi, new Loom_Neopixel());

Loom_MPU6050 mpu(manager);
// Read the battery voltage and A0 and A1
Loom_Analog analog(manager, A0, A1);

// Reads the button on pin 10
Loom_Digital digital(manager, 10);
Loom_Digital digital(manager, INPUT_PULLUP, 10);

void setup() {

Expand Down
2 changes: 2 additions & 0 deletions examples/Lab Examples/Wattson/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define SECRET_SSID ""
#define SECRET_PASS ""
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ void setup() {

void loop() {

// Set the RTC interrupt alarm to wake the device in 15 min, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Measure and package the data
manager.measure();
manager.package();
Expand All @@ -95,9 +98,6 @@ void loop() {
// Publish the collected data to MQTT
mqtt.publish();

// Set the RTC interrupt alarm to wake the device in 15 min
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void setup() {
ENABLE_FUNC_SUMMARIES;

// Set the interrupt pin to pullup
pinMode(INT_PIN, INPUT_PULLUP);
pinMode(INT_PIN, INPUT);

// Wait 20 seconds for the serial console to open
manager.beginSerial();
Expand All @@ -101,6 +101,9 @@ void setup() {
void loop() {

if(sampleFlag){
// Set the RTC interrupt alarm to wake the device in 15 min, this should be done as soon as the device enters sampling mode for consistant sleep cycles
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Measure and package the data
manager.measure();
manager.package();
Expand All @@ -117,9 +120,6 @@ void loop() {
// Publish the collected data to MQTT
mqtt.publish();

// Set the RTC interrupt alarm to wake the device in 15 min
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();
attachInterrupt(INT_PIN, tipTrigger, FALLING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void loop() {
// Publish the collected data to MQTT
mqtt.publish();

// Set the RTC interrupt alarm to wake the device in 15 min
// Set the RTC interrupt alarm to wake the device in 15 min, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ void setup() {

void loop() {

// Set the RTC interrupt alarm to wake the device in 15 min, at the top to schedule next interrupt asap
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));

// Measure and package the data
manager.measure();
manager.package();
Expand All @@ -95,9 +98,7 @@ void loop() {
// Publish the collected data to MQTT
mqtt.publish();

// Set the RTC interrupt alarm to wake the device in 15 min
hypnos.setInterruptDuration(TimeSpan(0, 0, 15, 0));


// Reattach to the interrupt after we have set the alarm so we can have repeat triggers
hypnos.reattachRTCInterrupt();

Expand Down
5 changes: 2 additions & 3 deletions examples/Sensors/Digital/Digital.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

Manager manager("Device", 1);

// Reads the battery voltage
Loom_Digital digital(manager, 12, 11);
// Sets the pinMode of pin 12 and 11 to INPUT_PULLUP and then reads values from the pins
Loom_Digital digital(manager, INPUT_PULLUP, 12, 11);

void setup() {

Expand All @@ -25,7 +25,6 @@ void setup() {
}

void loop() {
// put your main code here, to run repeatedly:

// Measure the data from the sensors
manager.measure();
Expand Down
Loading

0 comments on commit 7779fc4

Please sign in to comment.