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

Develop to Master for next release #160

Merged
merged 58 commits into from
Sep 7, 2018
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
dffd0ea
Fixed missed end() in sdi-12, updated maxbotix solo example
SRGDamia1 May 18, 2018
51332bf
Moved system sleep out of begin
SRGDamia1 May 18, 2018
e1e3ecc
Checking if SDI12 object is active before re-beginning
SRGDamia1 May 18, 2018
8026328
Added a bit of extra debugging
SRGDamia1 May 22, 2018
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
27e3cb5
BME280 stabilization time update
aufdenkampe 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
67955c4
Tiny edit for clarity of the unassigned sensor option for DS18
fisherba Jul 30, 2018
6892a0f
Correct typos in code
aufdenkampe Sep 6, 2018
9e8100e
Merge pull request #153 from EnviroDIY/calcVar
aufdenkampe Sep 6, 2018
c1af080
Fix to unknown maxim in EnviroDIY examples
SRGDamia1 Sep 7, 2018
6c7c646
Merge branch 'master' into develop
SRGDamia1 Sep 7, 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
Prev Previous commit
Next Next commit
Mostly updates to documentation
SRGDamia1 committed Jun 1, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit af1424812a4f0002b4070e753f30abc383bfb933
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
@@ -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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -61,7 +61,9 @@ To use a sensor and variable in your sketch, you must separately include xxx.h f

Each sensor is implemented as a subclass of the "Sensor" class contained in "SensorBase.h". Each variable is separately implemented as a subclass of the "Variable" class contained in "VariableBase.h". The variables are tied to the sensor using an "[Observer](https://en.wikipedia.org/wiki/Observer_pattern)" software pattern.

The "VariableArray" class contained in "VariableArray.h" defines the logic for iterating through many variable objects. The various "Logger" classes are all sub-classes of variable arrays and add functionality for sleeping the processor, writing to an SD card, and communicating with the internet.
The "VariableArray" class contained in "VariableArray.h" defines the logic for iterating through many variable objects. The VariableArray class takes advantage of various time stamps within the Sensor class to optimize the timing of communcations with many sensors.

The "Logger" class defines functions for sleeping the processor and writing to an SD card. The logger subclasses add functionality for communicating with the internet and sending data to particular data receivers.



@@ -99,12 +101,12 @@ This library is designed for wireless, solar-powered environmental data logging
In order to support multiple functions and sensors, there are quite a lot of sub-libraries that this library is dependent on. _Even if you do not use the modules, you must have all of the dependencies installed for the library itself to properly compile._ Please check the [library.json](https://github.com/EnviroDIY/ModularSensors/blob/master/library.json) file for more details on the versions required of each library. If you are using [PlatformIO](https://platformio.org), you can list "EnviroDIY_ModularSensors" in the ```lib_deps``` section of your platformio.ini file and all of these libraries will be installed automatically. If using the "standard" Arduino IDE, you must install each of these libraries individually, or in a bundle from the [EnviroDIY Libraries](https://github.com/EnviroDIY/Libraries) meta-repository.

- [EnableInterrupt](https://github.com/GreyGnome/EnableInterrupt) - Administrates and handles pin change interrupts, allowing the logger to sleep and save battery. This also controls the interrupts for the versions of SoftwareSerial and SDI-12 linked below that have been stripped of interrupt control. Because we use this library, _you must always add the line ```#include <EnableInterrupt.h>``` to the top of your sketch._
- AVR sleep library - This is for low power sleeping for AVR processors. (This library is built in to the Arduino IDE.)
- AVR sleep library - This is for low power sleeping for AVR processors. (This library is built in to the Arduino and PlatformIO IDEs.)
- [EnviroDIY DS-3231](https://github.com/EnviroDIY/Sodaq_DS3231) - For real time clock control
- [RTCZero library](https://github.com/arduino-libraries/RTCZero) - This real time clock control and low power sleeping on SAMD processors. (This library may be built in to the Arduino IDE.) NOTE: If using an AVR board, you must explicitly _ignore_ this library when compiling with PlatformIO or you will have compiler errors.
- [SdFat library](https://github.com/greiman/SdFat) - This enables communication with the SD card.
- [EnviroDIY version of the TinyGSM library](https://github.com/EnviroDIY/TinyGSM) - This provides internet (TCP/IP) connectivity.
- [Adafruit ADS1X15 library](https://github.com/soligen2010/Adafruit_ADS1X15/) - For high-resolution analog to digital conversion. Note that this is soligen2010's fork of the original Adafruit library; it corrects many problems in the Adafruit library such as a bug which gives the same output on all four inputs regardless of their values. Do NOT use the original Adafruit version!
- [Adafruit ADS1X15 library](https://github.com/soligen2010/Adafruit_ADS1X15/) - For high-resolution analog to digital conversion. Note that this is soligen2010's fork of the original Adafruit library; it corrects many problems in the Adafruit library such as a bug which gives the same output on all four inputs regardless of their values. Do _NOT_ use the original Adafruit version!
- [EnviroDIY Arduino SDI-12 library](https://github.com/EnviroDIY/Arduino-SDI-12/tree/ExtInts) - For control of SDI-12 based sensors. This modified version is needed so there are no pin change interrupt conflicts with the SoftwareSerial library or the software pin change interrupt library used to wake the processor.
- [SensorModbusMaster](https://github.com/EnviroDIY/SensorModbusMaster) - for easy communication with Modbus devices.
- [OneWire](https://github.com/PaulStoffregen/OneWire) - This enables communication with Maxim/Dallas OneWire devices.
@@ -125,7 +127,7 @@ Generally useful functions:
- **Constructor** - Each sensor has a unique constructor, the exact format of which is dependent on the individual sensor.
- **getSensorName()** - This gets the name of the sensor and returns it as a string.
- **getSensorLocation()** - This returns the Arduino pin sending and receiving data or other sensor installation information as a string. This is the location where the sensor is connected to the data logger, NOT the position of the sensor in the environment. Generally this value is set in the constructor for the sensor.
- **setNumberMeasurementsToAverage(int nReadings)** - Sets the number of readings for the sensor to take. This value can also be set by the constructor.
- **setNumberMeasurementsToAverage(int nReadings)** - Sets the number of readings for the sensor to take. This value can also be set by the constructor. NOTE: This will beome the number of readings actually taken by a sensor prior to data averaging. Any "bad" (-9999) values returned by the sensor will not be included in the final averaging. This the actual number of "good" values that are averaged may be less than what is set by setNumberMeasurementsToAverage or in the sensor constructor.
- **getNumberMeasurementsToAverage()** - Returns an unsigned 8-bit integer with the number of readings the sensor will be taking before averaging and giving a final result.
- **getStatus()** - This returns the 8-bit code for the current status of the sensor:
- Bit 0 - 0=Not powered, 1=Powered
@@ -162,7 +164,7 @@ These functions are also available for each sensor, but should be used with caut

### Functions for Each Variable
- **Constructor** - There are two forms of the constructor, one for measured variables (ie, ones whose values come directly from a senor) and another for calculated variables (ie, ones whose values are calculated from other vales).
- For _measured_ variables, the base variable constructor should not be used, but instead the constructor for the specific type of variable tied to a sensor should be used. (That is, use the constructor for the MaxBotixSonar_Range variable sub-object, not the raw variable constructor.) The sensor-measured variable constructors require a pointer to its parent sensor as the first argument of the constructor. There are also two optional string entries, for a universally unique identifier (UUID or GUID) and a custom variable code. _The UUID must always be listed first!_ In cases where you would like a custom variable code, but do not have a UUID, you **must** enter '""' as your UUID.
- For _measured_ variables, the base variable constructor should not be used, but instead the constructor for the specific type of variable tied to a sensor should be used. (That is, use the constructor for the MaxBotixSonar_Range variable sub-object, not the raw variable constructor.) Each sensor-measured variable constructor requires a pointer to its parent sensor as the first argument of the constructor. There are also two optional string entries, for a universally unique identifier (UUID or GUID) and a custom variable code. _The UUID must always be listed first!_ In cases where you would like a custom variable code, but do not have a UUID, you **must** enter '""' as your UUID.
- For _calculated_ variables, you use the base variable object constructor. The constructor requires a function which returns a float as its first argument, followed by Strings from the variable's name and unit. Both of these strings should be values from the [ODM2 controlled vocabularies](http://vocabulary.odm2.org/). Next an integer variable resolution is required. Then two Strings for the variable UUID and variable code. _All arguments are required in the calculated variable constructor!_
- **getVarName()** - This returns the variable's name, using http://vocabulary.odm2.org/variablename/, as a String.
- **getVarUnit()** - This returns the variable's unit, using http://vocabulary.odm2.org/units/, as a String.
2 changes: 1 addition & 1 deletion src/LoggerBase.cpp
Original file line number Diff line number Diff line change
@@ -676,7 +676,7 @@ void Logger::setFileTimestamp(File fileToStamp, uint8_t stampFlag)

// Private helper function - This opens or creates a file, converting a string
// file name to a character file name
bool Logger::openFile(String filename, bool createFile, bool writeDefaultHeader)
bool Logger::openFile(String& filename, bool createFile, bool writeDefaultHeader)
{
// Initialise the SD card
// skip everything else if there's no SD card, otherwise it might hang
20 changes: 12 additions & 8 deletions src/LoggerBase.h
Original file line number Diff line number Diff line change
@@ -29,9 +29,11 @@
// Bring in the library to commuinicate with an external high-precision real time clock
// This also implements a needed date/time class
#include <Sodaq_DS3231.h>
#define EPOCH_TIME_OFF 946684800 // This is 2000-jan-01 00:00:00 in epoch time
// Need this b/c the date/time class in Sodaq_DS3231 treats a 32-bit long timestamp
// as time from 2000-jan-01 00:00:00 instead of the standard epoch of 1970-jan-01 00:00:00
#define EPOCH_TIME_OFF 946684800
// This is 2000-jan-01 00:00:00 in "epoch" time
// Need this b/c the date/time class in Sodaq_DS3231 treats a 32-bit long
// timestamp as time from 2000-jan-01 00:00:00 instead of the standard (unix)
// epoch beginning 1970-jan-01 00:00:00.

#include <SdFat.h> // To communicate with the SD card

@@ -198,8 +200,8 @@ class Logger
static uint32_t markedEpochTime;

// These are flag fariables noting the current state (logging/testing)
// NOTE: if the logger isn't currently logging or testing or in the middle of set-up,
// it's probably sleeping
// NOTE: if the logger isn't currently logging or testing or in the middle
// of set-up, it's probably sleeping
// Setting these as volatile because the flags can be changed in ISR's
static volatile bool isLoggingNow;
static volatile bool isTestingNow;
@@ -238,18 +240,20 @@ class Logger
int8_t _buttonPin;

// This checks if the SD card is available and ready
// We run this check before every communication with the SD card to prevent
// hanging.
bool initializeSDCard(void);

// This generates a file name from the logger id and the current date
// NOTE: This cannot be called until the set-up after the RTC is started
// NOTE: This cannot be called until *after* the RTC is started
void generateAutoFileName(void);

// This sets a timestamp on a file
void setFileTimestamp(File fileToStamp, uint8_t stampFlag);

// This opens or creates a file, converting a string file name to a
// characterd file name
bool openFile(String filename, bool createFile, bool writeDefaultHeader);
// character file name
bool openFile(String& filename, bool createFile, bool writeDefaultHeader);
};

#endif
11 changes: 7 additions & 4 deletions src/SensorBase.h
Original file line number Diff line number Diff line change
@@ -61,9 +61,9 @@ class Sensor
virtual bool setup(void);

// This updates the sensor's values
// This includes clears the values array, starts and averages as many
// measurement readings as requested, and then notifies the registerd
// variables of the new resutls.
// This clears the values array, starts and averages as many measurement
// readings as requested, and then notifies the registered variables
// of the new results. All possible waits are included in this function!
virtual bool update(void);

// This turns on the sensor power, if applicable
@@ -76,6 +76,7 @@ class Sensor
// This wakes the sensor up, if necessary - that is, does whatever it takes to
// get a sensor in the proper state to begin a measurement after the power is on.
// This *may* require a waitForWarmUp() before wake commands can be sent.
// The wait is NOT included in this function!
// This also sets the _millisSensorActivated timestamp.
// By default, verifies the power is on and returns true
virtual bool wake(void);
@@ -88,20 +89,22 @@ class Sensor
// This also sets the _millisMeasurementRequested timestamp.
// This *may* require a waitForWarmUp() before measurement commands can be sent.
// This *may* also require a waitForStability() before returned measurements will be any good.
// The waits are NOT included in this function!
virtual bool startSingleMeasurement(void);

// This next function must be implemented for ever sensor!!
// This actually gets the results from a single measurement
// This also un-sets the _millisMeasurementRequested timestamp.
// This *may* also require a waitForStability() before returned measurements will be any good.
// This will often require a waitForMeasurementCompletion() to ensure a measurement is done.
// The waits are NOT included in this function!
virtual bool addSingleMeasurementResult(void) = 0;

// This is the array of result values for each sensor
float sensorValues[MAX_NUMBER_VARS];
// Clears the values array
void clearValues();
// This verifies that a measurement is OK before adding it to the array
// This verifies that a measurement is OK (ie, not -9999) before adding it to the array
void verifyAndAddMeasurementResult(int resultNumber, float resultValue);
void verifyAndAddMeasurementResult(int resultNumber, int resultValue);
void averageMeasurements(void);