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

Pointer ref #157

Merged
merged 9 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.



Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -515,7 +517,7 @@ EnviroDIYLogger.setUUIDs(UUIDs[]);
modem.setupModem(modemStream, vcc33Pin, modemStatusPin, modemSleepRqPin, sleepType, APN);

// Attach the modem to the logger
EnviroDIYLogger.attachModem(&modem);
EnviroDIYLogger.attachModem(modem);

// Begin the logger;
EnviroDIYLogger.begin();
Expand Down
2 changes: 1 addition & 1 deletion examples/DRWI_CitSci/DRWI_CitSci.ino
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void setup()
modem.setupModem(&ModemSerial, modemVCCPin, modemStatusPin, modemSleepRqPin, ModemSleepMode, apn);

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

Expand Down
26 changes: 13 additions & 13 deletions examples/baro_rho_correction/baro_rho_correction.ino
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ float calculateWaterPressure(void)
return waterPressure;
}
// Properties of the calculated water pressure variable
String waterPresureVarName = "pressureGauge"; // This must be a value from http://vocabulary.odm2.org/variablename/
String waterPresureVarUnit = "millibar"; // This must be a value from http://vocabulary.odm2.org/units/
const char *waterPresureVarName = "pressureGauge"; // This must be a value from http://vocabulary.odm2.org/variablename/
const char *waterPresureVarUnit = "millibar"; // This must be a value from http://vocabulary.odm2.org/units/
int waterPresureVarResolution = 3;
String waterPressureUUID = "12345678-abcd-1234-efgh-1234567890ab";
String waterPresureVarCode = "CorrectedPressure";
const char *waterPressureUUID = "12345678-abcd-1234-efgh-1234567890ab";
const char *waterPresureVarCode = "CorrectedPressure";
// Create the calculated water pressure variable objects and return a variable pointer to it
Variable *calcWaterPress = new Variable(calculateWaterPressure, waterPresureVarName,
waterPresureVarUnit, waterPresureVarResolution,
Expand All @@ -216,11 +216,11 @@ float calculateWaterDepthRaw(void)
return waterDepth;
}
// Properties of the calculated water depth variable
String waterDepthVarName = "waterDepth"; // This must be a value from http://vocabulary.odm2.org/variablename/
String waterDepthVarUnit = "millimeter"; // This must be a value from http://vocabulary.odm2.org/units/
const char *waterDepthVarName = "waterDepth"; // This must be a value from http://vocabulary.odm2.org/variablename/
const char *waterDepthVarUnit = "millimeter"; // This must be a value from http://vocabulary.odm2.org/units/
int waterDepthVarResolution = 3;
String waterDepthUUID = "12345678-abcd-1234-efgh-1234567890ab";
String waterDepthVarCode = "CalcDepth";
const char *waterDepthUUID = "12345678-abcd-1234-efgh-1234567890ab";
const char *waterDepthVarCode = "CalcDepth";
// Create the calculated raw water depth variable objects and return a variable pointer to it
Variable *calcRawDepth = new Variable(calculateWaterDepthRaw, waterDepthVarName,
waterDepthVarUnit, waterDepthVarResolution,
Expand Down Expand Up @@ -252,11 +252,11 @@ float calculateWaterDepthTempCorrected(void)
return rhoDepth;
}
// Properties of the calculated temperature corrected water depth variable
String rhoDepthVarName = "waterDepth"; // This must be a value from http://vocabulary.odm2.org/variablename/
String rhoDepthVarUnit = "millimeter"; // This must be a value from http://vocabulary.odm2.org/units/
const char *rhoDepthVarName = "waterDepth"; // This must be a value from http://vocabulary.odm2.org/variablename/
const char *rhoDepthVarUnit = "millimeter"; // This must be a value from http://vocabulary.odm2.org/units/
int rhoDepthVarResolution = 3;
String rhoDepthUUID = "12345678-abcd-1234-efgh-1234567890ab";
String rhoDepthVarCode = "DensityDepth";
const char *rhoDepthUUID = "12345678-abcd-1234-efgh-1234567890ab";
const char *rhoDepthVarCode = "DensityDepth";
// Create the temperature corrected water depth variable objects and return a variable pointer to it
Variable *calcCorrDepth = new Variable(calculateWaterDepthTempCorrected, rhoDepthVarName,
rhoDepthVarUnit, rhoDepthVarResolution,
Expand Down Expand Up @@ -361,7 +361,7 @@ void setup()
#endif

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

Expand Down
6 changes: 3 additions & 3 deletions examples/data_saving/data_saving.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const int8_t sdCardPin = 12; // SD Card Chip Select/Slave Select Pin (must be d

// Create and return the processor "sensor"
const char *MFVersion = "v0.5";
ProcessorStats mayfly(MFVersion) ;
ProcessorStats mayfly(MFVersion);
// Create the battery voltage and free RAM variable objects for the Y504 and return variable-type pointers to them
Variable *mayflyBatt = new ProcessorStats_Batt(&mayfly, "12345678-abcd-1234-efgh-1234567890ab");
Variable *mayflyRAM = new ProcessorStats_FreeRam(&mayfly, "12345678-abcd-1234-efgh-1234567890ab");
Expand Down Expand Up @@ -320,8 +320,8 @@ void setup()
// Attach the same modem to both loggers
// It is only needed for the logger that will be sending out data, but
// attaching it to both allows either logger to control NIST synchronization
loggerComplete.attachModem(&modem);
loggerToGo.attachModem(&modem);
loggerComplete.attachModem(modem);
loggerToGo.attachModem(modem);
loggerComplete.setTestingModePin(buttonPin);
// There is no reason to call the setAlertPin() function, because we have to
// write the loop on our own.
Expand Down
2 changes: 1 addition & 1 deletion examples/logging_to_EnviroDIY/logging_to_EnviroDIY.ino
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void setup()
#endif

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void setup()
#endif

// Attach the modem and information pins to the logger
EnviroDIYLogger.attachModem(&modem);
EnviroDIYLogger.attachModem(modem);
EnviroDIYLogger.setAlertPin(greenLED);
// No button on the feather, so we're not attaching a testingMode pin

Expand Down
2 changes: 1 addition & 1 deletion sensor_tests/AnthonyTest2/AnthonyTest2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void setup()
#endif

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

Expand Down
2 changes: 1 addition & 1 deletion src/AOSongAM2315.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// The constructor - because this is I2C, only need the power pin
// This sensor has a set I2C address of 0XB8
AOSongAM2315::AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage)
: Sensor(F("AOSongAM2315"), AM2315_NUM_VARIABLES,
: Sensor("AOSongAM2315", AM2315_NUM_VARIABLES,
AM2315_WARM_UP_TIME_MS, AM2315_STABILIZATION_TIME_MS, AM2315_MEASUREMENT_TIME_MS,
powerPin, -1, measurementsToAverage)
{}
Expand Down
12 changes: 6 additions & 6 deletions src/AOSongAM2315.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class AOSongAM2315_Humidity : public Variable
{
public:
AOSongAM2315_Humidity(Sensor *parentSense,
String UUID = "", String customVarCode = "") :
const char *UUID = "", const char *customVarCode = "") :
Variable(parentSense, AM2315_HUMIDITY_VAR_NUM,
F("relativeHumidity"), F("percent"),
"relativeHumidity", "percent",
AM2315_HUMIDITY_RESOLUTION,
F("AM2315Humidity"), UUID, customVarCode)
"AM2315Humidity", UUID, customVarCode)
{}
};

Expand All @@ -79,11 +79,11 @@ class AOSongAM2315_Temp : public Variable
{
public:
AOSongAM2315_Temp(Sensor *parentSense,
String UUID = "", String customVarCode = "") :
const char *UUID = "", const char *customVarCode = "") :
Variable(parentSense, AM2315_TEMP_VAR_NUM,
F("temperature"), F("degreeCelsius"),
"temperature", "degreeCelsius",
AM2315_TEMP_RESOLUTION,
F("AM2315Temp"), UUID, customVarCode)
"AM2315Temp", UUID, customVarCode)
{}
};

Expand Down
2 changes: 1 addition & 1 deletion src/AOSongDHT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// The constructor - need the power pin, data pin, and type of DHT
AOSongDHT::AOSongDHT(int8_t powerPin, int8_t dataPin, DHTtype type, uint8_t measurementsToAverage)
: Sensor(F("AOSongDHT"), DHT_NUM_VARIABLES,
: Sensor("AOSongDHT", DHT_NUM_VARIABLES,
DHT_WARM_UP_TIME_MS, DHT_STABILIZATION_TIME_MS, DHT_MEASUREMENT_TIME_MS,
powerPin, dataPin, measurementsToAverage),
dht_internal(dataPin, type)
Expand Down
18 changes: 9 additions & 9 deletions src/AOSongDHT.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ class AOSongDHT_Humidity : public Variable
{
public:
AOSongDHT_Humidity(Sensor *parentSense,
String UUID = "", String customVarCode = "")
const char *UUID = "", const char *customVarCode = "")
: Variable(parentSense, DHT_HUMIDITY_VAR_NUM,
F("relativeHumidity"), F("percent"),
"relativeHumidity", "percent",
DHT_HUMIDITY_RESOLUTION,
F("DHTHumidity"), UUID, customVarCode)
"DHTHumidity", UUID, customVarCode)
{}
};

Expand All @@ -104,11 +104,11 @@ class AOSongDHT_Temp : public Variable
{
public:
AOSongDHT_Temp(Sensor *parentSense,
String UUID = "", String customVarCode = "")
const char *UUID = "", const char *customVarCode = "")
: Variable(parentSense, DHT_TEMP_VAR_NUM,
F("temperature"), F("degreeCelsius"),
"temperature", "degreeCelsius",
DHT_TEMP_RESOLUTION,
F("DHTTemp"), UUID, customVarCode)
"DHTTemp", UUID, customVarCode)
{}
};

Expand All @@ -118,11 +118,11 @@ class AOSongDHT_HI : public Variable
{
public:
AOSongDHT_HI(Sensor *parentSense,
String UUID = "", String customVarCode = "")
const char *UUID = "", const char *customVarCode = "")
: Variable(parentSense, DHT_HI_VAR_NUM,
F("heatIndex"), F("degreeCelsius"),
"heatIndex", "degreeCelsius",
DHT_HI_RESOLUTION,
F("DHTHI"), UUID, customVarCode)
"DHTHI", UUID, customVarCode)
{}
};

Expand Down
4 changes: 2 additions & 2 deletions src/ApogeeSQ212.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

// The constructor - need the power pin and the data pin
ApogeeSQ212::ApogeeSQ212(int8_t powerPin, int8_t dataPin, uint8_t i2cAddress, uint8_t measurementsToAverage)
: Sensor(F("ApogeeSQ212"), SQ212_NUM_VARIABLES,
: Sensor("ApogeeSQ212", SQ212_NUM_VARIABLES,
SQ212_WARM_UP_TIME_MS, SQ212_STABILIZATION_TIME_MS, SQ212_MEASUREMENT_TIME_MS,
powerPin, dataPin, measurementsToAverage)
{
Expand All @@ -48,7 +48,7 @@ String ApogeeSQ212::getSensorLocation(void)
{
String sensorLocation = F("ADS1115_0x");
sensorLocation += String(_i2cAddress, HEX);
sensorLocation += F("_Pin");
sensorLocation += F("_Pin");
sensorLocation += String(_dataPin);
return sensorLocation;
}
Expand Down
Loading