Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented real calculated variables #153

Merged
merged 49 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
908a7d9
Beginning stages of calculated vars
SRGDamia1 May 22, 2018
6221d5b
Added a calculated variable to the single sensor example
SRGDamia1 May 22, 2018
3696e25
Arrays should now deal with calculated variables
SRGDamia1 May 22, 2018
f9a0a34
Fixed single_sensor for Travis
SRGDamia1 May 22, 2018
d2979c5
Made calculation in single_sensor less trivial
SRGDamia1 May 22, 2018
3a0fa59
debugging correction
SRGDamia1 May 22, 2018
1574b90
Added helper functions for parent sensors of variables
SRGDamia1 May 22, 2018
c6cbd3d
Debugging changes
SRGDamia1 May 22, 2018
bc67a87
baro/density correction example now uses calculated variables
SRGDamia1 May 22, 2018
eb68357
Updated ReadMe, bumped version
SRGDamia1 May 22, 2018
0f45d0e
Made sure calculations will return -9999 if inputs are -9999
SRGDamia1 May 22, 2018
5d6112a
Added sanity check to MS5803
SRGDamia1 May 22, 2018
e2465d0
Moved variable array init to constructor
SRGDamia1 May 22, 2018
e7958c3
Don't need so many print fxns in VariableArray
SRGDamia1 May 23, 2018
543c2dd
Renamed internal array and made public
SRGDamia1 May 23, 2018
cf2732f
A logger is NO LONGER a subclass of variable array
SRGDamia1 May 23, 2018
a33ed46
Changed order of logger constructor
SRGDamia1 May 23, 2018
18eec37
Updated examples
SRGDamia1 May 23, 2018
dcc0a5e
Fixed example
SRGDamia1 May 23, 2018
327467f
Removed unpopular "checkForTestingMode"
SRGDamia1 May 23, 2018
7c70c58
Some small clean-up
SRGDamia1 May 23, 2018
2ac9dc8
Fix for removed _sleep
SRGDamia1 May 23, 2018
9423113
Fixed multisensor_print
SRGDamia1 May 23, 2018
2734d32
Made testing mode part of a logger
SRGDamia1 May 23, 2018
4ae43cb
Restructured to allow data to be streamed to SD card
SRGDamia1 May 24, 2018
60ca9eb
Added missing new line in csv and EnviroDIY header
SRGDamia1 May 24, 2018
45e4048
stream header must be virtual
SRGDamia1 May 24, 2018
6d187da
Fixed some serial.print vs PRINTOUT
SRGDamia1 May 24, 2018
88bef71
Cleaned up some generate vs stream functions
SRGDamia1 May 24, 2018
f08b6fc
Update ReadMe, bumped version
SRGDamia1 May 24, 2018
b0ee96a
Minor example rearranging
SRGDamia1 May 24, 2018
7f7a47e
Updated platformio's
SRGDamia1 May 24, 2018
14f61a0
Fixed modem name typo
SRGDamia1 May 24, 2018
30ffbb8
Merge pull request #155 from EnviroDIY/killInit
SRGDamia1 May 24, 2018
a84934e
Cleaned up some messiness with creating a file name
SRGDamia1 May 24, 2018
7503016
Fixed if statement in example
SRGDamia1 May 31, 2018
559da6f
Changed some pointers to references
SRGDamia1 May 31, 2018
c5414ee
Fix broken example
SRGDamia1 May 31, 2018
1c73762
More pointers to refs
SRGDamia1 May 31, 2018
15df45f
Strings to character arrays
SRGDamia1 May 31, 2018
70846cb
Lots more string to char
SRGDamia1 May 31, 2018
de55912
Tweek examples
SRGDamia1 May 31, 2018
8723b1a
Missed loggermodem
SRGDamia1 May 31, 2018
5859ef3
Moved unknown into class to fix multiple declarations
SRGDamia1 Jun 1, 2018
af14248
Mostly updates to documentation
SRGDamia1 Jun 1, 2018
f68abed
Merge pull request #157 from EnviroDIY/pointerRef
SRGDamia1 Jun 1, 2018
d5b5efc
Slimmed modem on/off methods
SRGDamia1 Jun 4, 2018
4a10279
Not trying to register to network before asking for CSQ
SRGDamia1 Jun 4, 2018
6892a0f
Correct typos in code
aufdenkampe Sep 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ install:
- git rm library.json
- pip install -U platformio
- pio upgrade
- pio update
- pio lib -g install 2079 # DS3231
- pio lib -g install 311 # EnableInterrupt
- pio lib -g install 322 # SdFat
Expand All @@ -53,6 +52,6 @@ install:
- pio lib -g install https://github.com/PaulStoffregen/AltSoftSerial.git # #73, but need the git until Paul S. has a new release
- pio lib -g install https://github.com/EnviroDIY/SoftwaterSerial_ExternalInts.git
# - pio lib -g install https://github.com/todbot/SoftI2CMaster.git
- pio lib -g update
- pio update

script: make travis-build
195 changes: 100 additions & 95 deletions README.md

Large diffs are not rendered by default.

47 changes: 16 additions & 31 deletions examples/DRWI_CitSci/DRWI_CitSci.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,24 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN.
#include <LoggerDreamHost.h>

// ==========================================================================
// Basic Logger Settings
// Data Logger Settings
// ==========================================================================
// The name of this file
const char *sketchName = "DWRI_CitSci.ino";

// Logger ID, also becomes the prefix for the name of the data file on SD card
const char *LoggerID = "XXXX";
const char *LoggerID = "XXXXX";
// How frequently (in minutes) to log data
const uint8_t loggingInterval = 5;
// Your logger's timezone.
const int8_t timeZone = -5;
// Create a new logger instance
LoggerDreamHost EnviroDIYLogger;


// ==========================================================================
// Primary Arduino-Based Board and Processor
// ==========================================================================
#include <ProcessorStats.h>

const long serialBaud = 57600; // Baud rate for the primary serial port for debugging
const long serialBaud = 115200; // Baud rate for the primary serial port for debugging
const int8_t greenLED = 8; // Pin for the green LED (-1 if unconnected)
const int8_t redLED = 9; // Pin for the red LED (-1 if unconnected)
const int8_t buttonPin = 21; // Pin for a button to use to enter debugging mode (-1 if unconnected)
Expand All @@ -59,7 +56,7 @@ const int8_t wakePin = A7; // Interrupt/Alarm pin to wake from sleep
// In a SAMD system where you are using the built-in rtc, set wakePin to 1
const int8_t sdCardPin = 12; // SD Card Chip Select/Slave Select Pin (must be defined!)

// Create the processor "sensor"
// Create and return the processor "sensor"
const char *MFVersion = "v0.5b";
ProcessorStats mayfly(MFVersion) ;

Expand Down Expand Up @@ -125,6 +122,8 @@ DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings);
// ==========================================================================
// The array that contains all variables to be logged
// ==========================================================================
// Create pointers for all of the variables from the sensors
// at the same time putting them into an array
Variable *variableList[] = {
new ProcessorStats_Batt(&mayfly, "12345678-abcd-1234-efgh-1234567890ab"),
new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"),
Expand All @@ -136,7 +135,12 @@ Variable *variableList[] = {
new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"),
new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"),
};
// Count up the number of pointers in the array
int variableCount = sizeof(variableList) / sizeof(variableList[0]);
// Create the VariableArray object
VariableArray varArray(variableCount, variableList);
// Create a new logger instance
LoggerDreamHost EnviroDIYLogger(LoggerID, loggingInterval, sdCardPin, wakePin, &varArray);


// ==========================================================================
Expand Down Expand Up @@ -195,18 +199,15 @@ void setup()
// Offset is the same as the time zone because the RTC is in UTC
Logger::setTZOffset(timeZone);

// Initialize the logger
EnviroDIYLogger.init(sdCardPin, wakePin, variableCount, variableList,
loggingInterval, LoggerID);
EnviroDIYLogger.setAlertPin(greenLED);

// Setup the logger modem
modem.setupModem(&ModemSerial, modemVCCPin, modemStatusPin, modemSleepRqPin, ModemSleepMode, apn);

// Attach the modem to the logger
EnviroDIYLogger.attachModem(&modem);
// Attach the modem and information pins to the logger
EnviroDIYLogger.attachModem(modem);
EnviroDIYLogger.setAlertPin(greenLED);
EnviroDIYLogger.setTestingModePin(buttonPin);

// Set up the connection with EnviroDIY
// Enter the tokens for the connection with EnviroDIY
EnviroDIYLogger.setToken(registrationToken);
EnviroDIYLogger.setSamplingFeatureUUID(samplingFeature);

Expand All @@ -215,22 +216,6 @@ void setup()

// Begin the logger
EnviroDIYLogger.begin();

// Hold up for 10-seconds to allow immediate entry into sensor testing mode
// EnviroDIYLogger.checkForTestingMode(buttonPin);

// Set up an interrupt on a pin to enter sensor testing mode at any time
pinMode(buttonPin, INPUT_PULLUP);
enableInterrupt(buttonPin, Logger::testingISR, CHANGE);
Serial.print(F("Push button on pin "));
Serial.print(buttonPin);
Serial.println(F(" at any time to enter sensor testing mode."));

// Blink the LEDs really fast to show start-up is done
greenredflash(6, 25);

// Sleep
EnviroDIYLogger.systemSleep();
}


Expand Down
2 changes: 1 addition & 1 deletion examples/DRWI_CitSci/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ framework = arduino
lib_ldf_mode = deep
lib_ignore = RTCZero
lib_deps =
EnviroDIY_ModularSensors@>=0.11.6
EnviroDIY_ModularSensors@>=0.12.2
https://github.com/PaulStoffregen/AltSoftSerial.git
https://github.com/EnviroDIY/SoftwaterSerial_ExternalInts.git
61 changes: 28 additions & 33 deletions examples/DRWI_NoCellular/DRWI_NoCellular.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN.
#include <EnableInterrupt.h> // for external and pin change interrupts
#include <LoggerBase.h>


// ==========================================================================
// Basic Logger Settings
// Data Logger Settings
// ==========================================================================
// The name of this file
const char *sketchName = "DRWI_NoCellular.ino";

// Logger ID, also becomes the prefix for the name of the data file on SD card
const char *LoggerID = "XXXX";
const char *LoggerID = "XXXXX";
// How frequently (in minutes) to log data
const uint8_t loggingInterval = 5;
// Your logger's timezone.
const int8_t timeZone = -5;
// Create a new logger instance
Logger logger;


// ==========================================================================
// Primary Arduino-Based Board and Processor
// ==========================================================================
#include <ProcessorStats.h>

const long serialBaud = 57600; // Baud rate for the primary serial port for debugging
const long serialBaud = 115200; // Baud rate for the primary serial port for debugging
const int8_t greenLED = 8; // Pin for the green LED (-1 if unconnected)
const int8_t redLED = 9; // Pin for the red LED (-1 if unconnected)
const int8_t buttonPin = 21; // Pin for a button to use to enter debugging mode (-1 if unconnected)
Expand All @@ -51,7 +49,7 @@ const int8_t wakePin = A7; // Interrupt/Alarm pin to wake from sleep
// In a SAMD system where you are using the built-in rtc, set wakePin to 1
const int8_t sdCardPin = 12; // SD Card Chip Select/Slave Select Pin (must be defined!)

// Create the processor "sensor"
// Create and return the processor "sensor"
const char *MFVersion = "v0.5b";
ProcessorStats mayfly(MFVersion) ;

Expand Down Expand Up @@ -102,16 +100,30 @@ DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings);
// ==========================================================================
// The array that contains all variables to be logged
// ==========================================================================
// Create pointers for all of the variables from the sensors
// at the same time putting them into an array
Variable *variableList[] = {
new ProcessorStats_Batt(&mayfly),
new MaximDS3231_Temp(&ds3231),
new DecagonCTD_Cond(&ctd),
new DecagonCTD_Temp(&ctd),
new DecagonCTD_Depth(&ctd),
new CampbellOBS3_Turbidity(&osb3low, "", "TurbLow"),
new CampbellOBS3_Turbidity(&osb3high, "", "TurbHigh"),
new ProcessorStats_Batt(&mayfly, "12345678-abcd-1234-efgh-1234567890ab"),
new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"),
new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"),
new DecagonCTD_Temp(&ctd, "12345678-abcd-1234-efgh-1234567890ab"),
new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-efgh-1234567890ab"),
new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab", "TurbLow"),
new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab", "TurbHigh")
};
// Count up the number of pointers in the array
int variableCount = sizeof(variableList) / sizeof(variableList[0]);
// Create the VariableArray object
VariableArray varArray(variableCount, variableList);
// Create a new logger instance
Logger logger(LoggerID, loggingInterval, sdCardPin, wakePin, &varArray);

// ==========================================================================
// Device registration and sampling feature information
// This should be obtained after registration at http://data.envirodiy.org
// ==========================================================================
const char *registrationToken = "12345678-abcd-1234-efgh-1234567890ab"; // Device registration token
const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sampling feature UUID


// ==========================================================================
Expand Down Expand Up @@ -159,29 +171,12 @@ void setup()
// Offset is the same as the time zone because the RTC is in UTC
Logger::setTZOffset(timeZone);

// Initialize the logger
logger.init(sdCardPin, wakePin, variableCount, variableList,
loggingInterval, LoggerID);
// Set pins for alerts and entering testing mode
logger.setAlertPin(greenLED);
logger.setTestingModePin(buttonPin);

// Begin the logger
logger.begin();

// Hold up for 10-seconds to allow immediate entry into sensor testing mode
// EnviroDIYLogger.checkForTestingMode(buttonPin);

// Set up an interrupt on a pin to enter sensor testing mode at any time
pinMode(buttonPin, INPUT_PULLUP);
enableInterrupt(buttonPin, Logger::testingISR, CHANGE);
Serial.print(F("Push button on pin "));
Serial.print(buttonPin);
Serial.println(F(" at any time to enter sensor testing mode."));

// Blink the LEDs really fast to show start-up is done
greenredflash(6, 25);

// Sleep
EnviroDIYLogger.systemSleep();
}


Expand Down
2 changes: 1 addition & 1 deletion examples/DRWI_NoCellular/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ framework = arduino
lib_ldf_mode = deep
lib_ignore = RTCZero
lib_deps =
EnviroDIY_ModularSensors@>=0.11.6
EnviroDIY_ModularSensors@>=0.12.2
https://github.com/PaulStoffregen/AltSoftSerial.git
https://github.com/EnviroDIY/SoftwaterSerial_ExternalInts.git
8 changes: 4 additions & 4 deletions examples/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To adjust any of these to work with your own sensor arrangements:
14. Program your board!

### single_sensor.ino
This shows making use of the unified set of commands to print data from a MaxBotix ultrasonic range finder to the serial port.
This shows making use of the unified set of commands to print data from a MaxBotix ultrasonic range finder to the serial port. It also shows creating a calculated variable which is the water depth.

### multisensor_print.ino
This shows using an array of sensors to easily update all of them and print all results to the serial port. This example calls on at least one of every single sensor available in this library.
Expand All @@ -39,11 +39,11 @@ This is a simplified version of logging_to_EnviroDIY.ino using just the sensors
### DWRI_NoCellular.ino
This is uses just the sensors and equipment standard to the DWRI Citizen Science grant for circumstances where there is no cellular signal.

### baro_rho_correction.ino
This example demonstrates how to work with calculated variables.

### double_logger.ino
This is a more complicated example using two different logger instances to log data at two different intervals, in this case, an AM3215 logging every minute, while checking the battery voltage only every 5 minutes. This showcases both how to use two different logging instances and how to use some of the functions to set up your own logging loop rather than using the log() function.

### baro_rho_correction.ino
Like the double_logger example, this showcases how to set up your own logging loop rather than using the log() function. In this case, though, there is only a single logger, but we are adding some extra calculated variables to the final output.

### data_saving.ino
This is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to the EnviroDIY data portal.
2 changes: 1 addition & 1 deletion examples/baro_rho_correction/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Example using the Modular Sensors Library to Calculate Results based on Measured Values and Send Both Measured and Calculated Values to the EnviroDIY Data Portal

Like the double_logger example, this showcases how to set up your own logging loop rather than using the log() function. In this case, though, there is only a single logger, but we are adding some extra calculated variables to the final output.
This example demonstrates how to work with calculated variables.
Loading