Trinket Tipping Bucket topic
- Introduction
- Sensor Datasheet
- Build flags
- Sensor Constructors
- Example Code
- Reference
- Detailed Descriptions
Classes for the Trinket-based I2C tipping bucket rain counter
Introduction
This module is for use with a simple external I2C tipping bucket counter based on an Adafruit Trinket. This is NOT for direct counting of tips using an interrupt on the main processor. The construction and programming of the tipping bucket counter is documented on GitHub. It is assumed that the processor of the tip counter takes care of its own power management.
Sensor Datasheet
Build flags
-D MS_RAIN_SOFTWAREWIRE
switches from using hardware I2C to software I2C
Sensor Constructors
RainCounterI2C:: RainCounterI2C(uint8_t i2cAddressHex = 0x08,
float rainPerTip = 0.2) explicit
Construct a new Rain Counter I2C object using the primary hardware I2C instance.
Parameters | |
---|---|
i2cAddressHex | The I2C address of the Trinket; can be any number between 0x40 and 0x4F. The default value is 0x08. |
rainPerTip | The depth of rain from a single tip; most likely either 0.01" or 0.2mm, depending on your tipping bucket calibration. The default value is 0.2. |
Example Code
The Arduino-based I2C tipping bucket rain counter is used in the menu a la carte example.
Classes
- class RainCounterI2C
- The Sensor sub-class for the Arduino-based external tipping bucket counter.
- class RainCounterI2C_Tips
- The Variable sub-class used for the total tip count output from an Adafruit Trinket based I2C tipping bucket counter.
- class RainCounterI2C_Depth
- The Variable sub-class used for the depth of rain output from an Adafruit Trinket based I2C tipping bucket counter.
Sensor Variable Counts
The number of variables that can be returned by the tipping bucket counter
- #define BUCKET_NUM_VARIABLES = 2
- Sensor::
_numReturnedValues; the tipping bucket counter can report 2 values. - #define BUCKET_INC_CALC_VARIABLES = 1
- Sensor::
_incCalcValues; we calculate rain depth from the number of tips, assuming either English or metric calibration.
Sensor Timing
The sensor timing for a Trinket-based tipping bucket counter
- Readings transferred from the tipping bucket to the logger are from past tips, so there is no need to wait for stability or measuring.
- #define BUCKET_WARM_UP_TIME_MS = 0
- Sensor::
_warmUpTime_ms; the tipping bucket counter warms up in 0ms. - #define BUCKET_STABILIZATION_TIME_MS = 0
- Sensor::
_stabilizationTime_ms; the tipping bucket counter is stable after 0ms. - #define BUCKET_MEASUREMENT_TIME_MS = 0
- Sensor::
_measurementTime_ms; the tipping bucket counter takes 0ms to complete a measurement.
Rain Depth
The rain depth variable from a Trinket-based tipping bucket counter
- Range and accuracy depend on the tipping bucket used
RainCounterI2C_ Depth:: RainCounterI2C_Depth(RainCounterI2C* parentSense,
const char* uuid = "",
const char* varCode = "RainCounterI2CVol") explicit
Construct a new RainCounterI2C_
Parameters | |
---|---|
parentSense | The parent RainCounterI2C providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "RainCounterI2CVol". |
- #define BUCKET_RAIN_RESOLUTION = 2
- Decimals places in string representation; rain depth should have 2.
- #define BUCKET_RAIN_VAR_NUM = 0
- Sensor variable number; rain depth is stored in sensorValues[0].
- #define BUCKET_RAIN_VAR_NAME = "precipitation"
- Variable name in ODM2 controlled vocabulary; "precipitation".
- #define BUCKET_RAIN_UNIT_NAME = "millimeter"
- Variable unit name in ODM2 controlled vocabulary; "millimeter".
- #define BUCKET_RAIN_DEFAULT_CODE = "RainCounterI2CVol"
- Default variable short code; "RainCounterI2CVol".
Tip Count
Defines for tip count variable from a Trinket-based tipping bucket counter
- Range and accuracy depend on the tipping bucket used.
RainCounterI2C_ Tips:: RainCounterI2C_Tips(RainCounterI2C* parentSense,
const char* uuid = "",
const char* varCode = "RainCounterI2CTips") explicit
Construct a new RainCounterI2C_
Parameters | |
---|---|
parentSense | The parent RainCounterI2C providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "RainCounterI2CTips". |
- #define BUCKET_TIPS_RESOLUTION = 0
- Decimals places in string representation; the number of tips should have 0 - resolution is 1 tip.
- #define BUCKET_TIPS_VAR_NUM = 1
- Sensor variable number; the number of tips is stored in sensorValues[1].
- #define BUCKET_TIPS_VAR_NAME = "precipitation"
- Variable name in ODM2 controlled vocabulary; "precipitation".
- #define BUCKET_TIPS_UNIT_NAME = "event"
- Variable unit name in ODM2 controlled vocabulary; "event".
- #define BUCKET_TIPS_DEFAULT_CODE = "RainCounterI2CTips"
- Default variable short code; "RainCounterI2CTips".
Define documentation
#define BUCKET_NUM_VARIABLES = 2
#include <src/sensors/RainCounterI2C.h>
Sensor::
#define BUCKET_INC_CALC_VARIABLES = 1
#include <src/sensors/RainCounterI2C.h>
Sensor::
#define BUCKET_WARM_UP_TIME_MS = 0
#include <src/sensors/RainCounterI2C.h>
Sensor::
#define BUCKET_STABILIZATION_TIME_MS = 0
#include <src/sensors/RainCounterI2C.h>
Sensor::
#define BUCKET_MEASUREMENT_TIME_MS = 0
#include <src/sensors/RainCounterI2C.h>
Sensor::
#define BUCKET_RAIN_RESOLUTION = 2
#include <src/sensors/RainCounterI2C.h>
Decimals places in string representation; rain depth should have 2.
Resolution is typically either 0.01" or 0.2mm of rainfall, depending on if bucket is calibrated to English or metric units.
#define BUCKET_RAIN_VAR_NUM = 0
#include <src/sensors/RainCounterI2C.h>
Sensor variable number; rain depth is stored in sensorValues[0].
#define BUCKET_RAIN_VAR_NAME = "precipitation"
#include <src/sensors/RainCounterI2C.h>
Variable name in ODM2 controlled vocabulary; "precipitation".
#define BUCKET_RAIN_UNIT_NAME = "millimeter"
#include <src/sensors/RainCounterI2C.h>
Variable unit name in ODM2 controlled vocabulary; "millimeter".
#define BUCKET_RAIN_DEFAULT_CODE = "RainCounterI2CVol"
#include <src/sensors/RainCounterI2C.h>
Default variable short code; "RainCounterI2CVol".
#define BUCKET_TIPS_RESOLUTION = 0
#include <src/sensors/RainCounterI2C.h>
Decimals places in string representation; the number of tips should have 0 - resolution is 1 tip.
#define BUCKET_TIPS_VAR_NUM = 1
#include <src/sensors/RainCounterI2C.h>
Sensor variable number; the number of tips is stored in sensorValues[1].
#define BUCKET_TIPS_VAR_NAME = "precipitation"
#include <src/sensors/RainCounterI2C.h>
Variable name in ODM2 controlled vocabulary; "precipitation".
#define BUCKET_TIPS_UNIT_NAME = "event"
#include <src/sensors/RainCounterI2C.h>
Variable unit name in ODM2 controlled vocabulary; "event".
#define BUCKET_TIPS_DEFAULT_CODE = "RainCounterI2CTips"
#include <src/sensors/RainCounterI2C.h>
Default variable short code; "RainCounterI2CTips".