ModularSensors > Classes > Sensor > TallyCounterI2C
ModularSensors > Modules > Tally Counter I2C > TallyCounterI2C


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 = TALLY_ADDRESS_BASE)
Construct a new Tally Counter I2C object using the primary hardware I2C instance.
~TallyCounterI2C()
Destroy the Tally Counter object.

Public functions

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

Function documentation

TallyCounterI2C(int8_t powerPin = -1, uint8_t i2cAddressHex = TALLY_ADDRESS_BASE)

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.

boolsetup(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.


StringgetSensorLocation(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.

booladdSingleMeasurementResult(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.