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 Adafriut 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
Construct a new Rain Counter I2C object using the primary hardware I2C instance. Construct a new Rain Counter I2C object using a secondary hardware I2C instance. Construct a new Rain Counter I2C object using a software I2C instance. Construct a new Rain Counter I2C object, also creating a SoftwareWire I2C instance for communication with that object.
RainCounterI2C::
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.
RainCounterI2C::
Parameters
theI2C
A TwoWire instance for I2C communication. Due to the limitations of the Arduino core, only a hardware I2C instance can be used. For an AVR board, there is only one I2C instance possible and this form of the constructor should not be used. For a SAMD board, this can be used if a secondary I2C port is created on one of the extra SERCOMs.
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.
RainCounterI2C::
Parameters
theI2C
A SoftwareWire instance for I2C communication.
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.
RainCounterI2C::
Parameters
dataPin
The pin on the mcu that will be used for I2C data (SDA). Must be a valid pin number.
clockPin
The pin on the mcu that will be used for the I2C clock (SCL). Must be a valid pin number.
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
Construct a new RainCounterI2C_
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.
Construct a new RainCounterI2C_
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".