Skip to content

Commit

Permalink
Merge pull request #240 from EnviroDIY/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SRGDamia1 authored Mar 6, 2019
2 parents cbf64a6 + eea2a85 commit ff900f9
Show file tree
Hide file tree
Showing 103 changed files with 5,184 additions and 1,893 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ include/readme.txt
.vscode

# Other
sensor_tests/
compile_tests/
logger_test/
logger_test*/
YosemitechDO/
LongTermLogger/
barometric_correction/
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ Although this library was written primarily for the [EnviroDIY Mayfly data logge
- [Apogee SQ-212: quantum light sensor, via TI ADS1115](https://github.com/EnviroDIY/ModularSensors/wiki/Apogee-SQ212)
- [AOSong AM2315: humidity & temperature](https://github.com/EnviroDIY/ModularSensors/wiki/AOSong-AM2315)
- [AOSong DHT: humidity & temperature](https://github.com/EnviroDIY/ModularSensors/wiki/AOSong-DHT)
- [Atlas Scientific EZO Sensors](https://github.com/EnviroDIY/ModularSensors/wiki/Atlas-Sensors)
- EZO-CO2: Carbon Dioxide and Temperature
- EZO-DO: Dissolved Oxygen
- EZO-EC: Conductivity, Total Dissolved Solids, Salinity, and Specific Gravity
- EZO-ORP: Oxidation/Reduction Potential
- EZO-pH: pH
- EZO-RTD: Temperature
- [Bosch BME280: barometric pressure, humidity & temperature](https://github.com/EnviroDIY/ModularSensors/wiki/Bosch-BME280)
- [Campbell Scientific OBS-3+: turbidity, via TI ADS1115](https://github.com/EnviroDIY/ModularSensors/wiki/Campbell-OBS3)
- [Meter Environmental ECH2O 5TM (formerly Decagon Devices 5TM): soil moisture](https://github.com/EnviroDIY/ModularSensors/wiki/Meter-ECH2O-5TM)
Expand Down
Binary file added doc/AtlasScientific_DO_EZO_Datasheet.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_DO_probe.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EC_EZO_Datasheet.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EC_K_0.1_probe.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EC_K_1.0_probe.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EC_K_10_probe.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EZO_CO2_Datasheet.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_EZO_RTD_Datasheet.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_ORP_EZO_datasheet.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_PT-1000-probe.pdf
Binary file not shown.
Binary file added doc/AtlasScientific_pH_EZO_Datasheet.pdf
Binary file not shown.
102 changes: 59 additions & 43 deletions examples/DRWI_CitSci/DRWI_CitSci.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Software License: BSD-3.
Copyright (c) 2017, Stroud Water Research Center (SWRC)
and the EnviroDIY Development Team
This example sketch is written for ModularSensors library version 0.19.6
This example sketch is written for ModularSensors library version 0.21.0
This sketch is an example of logging data to an SD card and sending the data to
both the EnviroDIY data portal as should be used by groups involved with
Expand All @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN.
// Data Logger Settings
// ==========================================================================
// The library version this example was written for
const char *libraryVersion = "0.19.6";
const char *libraryVersion = "0.21.0";
// 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
Expand All @@ -52,10 +52,11 @@ const int8_t buttonPin = 21; // MCU pin for a button to use to enter debugg
const int8_t wakePin = A7; // MCU interrupt/alarm pin to wake from sleep
// Set the wake pin to -1 if you do not want the main processor to sleep.
// In a SAMD system where you are using the built-in rtc, set wakePin to 1
const int8_t sdCardPin = 12; // MCU SD card chip select/slave select pin (must be given!)
const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable)
const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable)
const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!)
const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable)

// Create and return the main processor chip "sensor" - for general metadata
// Create the main processor chip "sensor" - for general metadata
const char *mcuBoardVersion = "v0.5b";
ProcessorStats mcuBoard(mcuBoardVersion);

Expand Down Expand Up @@ -92,7 +93,7 @@ HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible
// Create a new TinyGSM modem to run on that serial port and return a pointer to it
TinyGsm *tinyModem = new TinyGsm(modemSerial);

// Create a new TCP client on that modem and return a pointer to it
// Create a TCP client on that modem
TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem);


Expand All @@ -102,25 +103,24 @@ TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem);

// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!!
// Describe the physical pin connection of your modem to your board
const long ModemBaud = 9600; // Communication speed of the modem
const long modemBaud = 9600; // Communication speed of the modem
const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW)

// Create the wake and sleep methods for the modem
// These can be functions of any type and must return a boolean
bool modemSleepFxn(void)
{
digitalWrite(modemSleepRqPin, LOW);
digitalWrite(redLED, LOW);
return true;
}
bool modemWakeFxn(void)
{
digitalWrite(modemSleepRqPin, HIGH);
digitalWrite(redLED, HIGH); // A light just for show
return true;
}


bool modemSleepFxn(void)
{
digitalWrite(modemSleepRqPin, LOW);
digitalWrite(redLED, LOW);
return true;
}
void extraModemSetup(void){}
// ==========================================================================
// Network Information and LoggerModem Object
// ==========================================================================
Expand All @@ -140,7 +140,7 @@ loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, m
// ==========================================================================
#include <sensors/MaximDS3231.h>

// Create and return the DS3231 sensor object
// Create a DS3231 sensor object
MaximDS3231 ds3231(1);


Expand All @@ -157,7 +157,8 @@ const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output
const float OBSLow_A = 0.000E+00; // The "A" value (X^2) from the low range calibration
const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calibration
const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration
// Create and return the Campbell OBS3+ LOW RANGE sensor object

// Create a Campbell OBS3+ LOW RANGE sensor object
CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings);


Expand All @@ -166,7 +167,8 @@ const int8_t OBSHighADSChannel = 1; // The ADS channel for the high range outpu
const float OBSHigh_A = 0.000E+00; // The "A" value (X^2) from the high range calibration
const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range calibration
const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration
// Create and return the Campbell OBS3+ HIGH RANGE sensor object

// Create a Campbell OBS3+ HIGH RANGE sensor object
CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings);


Expand All @@ -180,7 +182,7 @@ const uint8_t CTDnumberReadings = 6; // The number of readings to average
const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected)
const int8_t SDI12Data = 7; // The SDI12 data pin

// Create and return the Decagon CTD sensor object
// Create a Decagon CTD sensor object
DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings);


Expand All @@ -189,8 +191,6 @@ DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings);
// ==========================================================================
#include <VariableArray.h>

// FORM1: Create pointers for all of the variables from the sensors,
// at the same time putting them into an array
Variable *variableList[] = {
new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"),
new DecagonCTD_Temp(&ctd, "12345678-abcd-1234-efgh-1234567890ab"),
Expand All @@ -215,7 +215,7 @@ VariableArray varArray(variableCount, variableList);
#include <LoggerBase.h>

// Create a new logger instance
Logger dataLogger(LoggerID, loggingInterval, sdCardPin, wakePin, &varArray);
Logger dataLogger(LoggerID, loggingInterval, &varArray);


// ==========================================================================
Expand Down Expand Up @@ -282,7 +282,7 @@ void setup()
"WARNING: THIS EXAMPLE WAS WRITTEN FOR A DIFFERENT VERSION OF MODULAR SENSORS!!"));

// Start the serial connection with the modem
modemSerial.begin(ModemBaud);
modemSerial.begin(modemBaud);

// Set up pins for the LED's
pinMode(greenLED, OUTPUT);
Expand Down Expand Up @@ -319,37 +319,53 @@ void setup()

// Attach the modem and information pins to the logger
dataLogger.attachModem(modem);
dataLogger.setAlertPin(greenLED);
dataLogger.setTestingModePin(buttonPin);
dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED);

// Begin the logger
dataLogger.begin();

// Note: Please change these battery voltages to match your battery
// Check that the battery is OK before powering the modem
if (getBatteryVoltage()> 3.7)
if (getBatteryVoltage() > 3.7)
{
modem.modemPowerUp();
}
// At lowest battery level, skip sensor set-up
if (getBatteryVoltage()< 3.4)
{
dataLogger.begin(true);
}
else // set up file and sensors
{
dataLogger.begin();
modem.wake();

// At very good battery voltage, or with suspicious time stamp, sync the clock
// Note: Please change these battery voltages to match your battery
if (getBatteryVoltage() > 3.8 ||
dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/
dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/
{
// Synchronize the RTC with NIST
Serial.println(F("Attempting to synchronize RTC with NIST"));
if (modem.connectInternet(120000L))
{
dataLogger.setRTClock(modem.getNISTTime());
}
}
}

// At very good battery voltage, or with suspicious time stamp, sync the clock
// Note: Please change these battery voltages to match your battery
if (getBatteryVoltage() > 3.8 ||
dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/
dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/
// Set up the sensors, except at lowest battery level
if (getBatteryVoltage() > 3.4)
{
dataLogger.syncRTC(); // There's a sleepPowerDown at the end of this
Serial.println(F("Setting up sensors..."));
varArray.setupSensors();
}
else

// Power down the modem
modem.modemSleepPowerDown();

// Create the log file, adding the default header to it
// Do this last so we have the best chance of getting the time correct and
// all sensor names correct
// Writing to the SD card can be power intensive, so if we're skipping
// the sensor setup we'll skip this too.
if (getBatteryVoltage() > 3.4)
{
modem.modemSleepPowerDown();
dataLogger.turnOnSDcard(true); // true = wait for card to settle after power up
dataLogger.createLogFile(true); // true = write a new header
dataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write
}

// Call the processor sleep
Expand Down
Loading

0 comments on commit ff900f9

Please sign in to comment.