TallyCounterI2C class

The Sensor sub-class for the Tally Counter I2C.

Base classes

class Sensor
The "Sensor" class is used for all sensor-level operations - waking, sleeping, and taking measurements.

Constructors, destructors, conversion operators

TallyCounterI2C(int8_t powerPin = -1, uint8_t i2cAddressHex = 0x33)
Construct a new Tally Counter I2C object using the primary hardware I2C instance.
~TallyCounterI2C()
Destroy the Tally Counter object.

Public functions

bool setup(void) -> bool override
Do any one-time preparations needed before the sensor will be able to take readings.
String getSensorLocation(void) -> String override
Get the pin or connection location between the mcu and the sensor.
bool addSingleMeasurementResult(void) -> bool override
Get the results from a single measurement.

Function documentation

TallyCounterI2C::TallyCounterI2C(int8_t powerPin = -1, uint8_t i2cAddressHex = 0x33)

Construct a new Tally Counter I2C object using the primary hardware I2C instance.

Parameters
powerPin

The pin on the mcu controlling power to TallyCounterI2C.

  • The default is to use -1 for continuous power because a counting device must always be on. However, the Tally also has a super capacitor that will keep it running even while powered down while the logger is in sleep during the interval between measurements.
  • The Tally Counter I2C can use either a 3.3V or 5V power source.
i2cAddressHex The I2C address of the Tally Counter I2C is 0x33 by default.

bool TallyCounterI2C::setup(void) override

Do any one-time preparations needed before the sensor will be able to take readings.

Returns bool True if the setup was successful.

This begins the Wire library (sets pin modes for I2C) and updates the _sensorStatus. It also engages sleep mode on the Tally counter and clears the counter memory. The Tally must be powered for setup.


String TallyCounterI2C::getSensorLocation(void) override

Get the pin or connection location between the mcu and the sensor.

Returns String Text describing how the sensor is attached to the mcu.

bool TallyCounterI2C::addSingleMeasurementResult(void) override

Get the results from a single measurement.

Returns bool True if the function completed successfully.

This asks the sensor for a new result, verifies that it passes sanity range checks, and then adds the value to the result array.

This also un-sets the _millisMeasurementRequested timestamp (sets _millisMeasurementRequested to 0) and updates the _sensorStatus.