ModularSensors > Classes > Sensor > MeaSpecMS5803
ModularSensors > Modules > Measurement Specialties MS5803 > MeaSpecMS5803


MeaSpecMS5803 class

The Sensor sub-class for the Measurement Specialties MS5803 sensor.

Base classes

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

Constructors, destructors, conversion operators

MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex = 0x76, int16_t maxPressure = 14, uint8_t measurementsToAverage = 1) explicit
Construct a new MeaSpecMS5803 object.
~MeaSpecMS5803()
Destroy the MeaSpecMS5803 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

MeaSpecMS5803(int8_t powerPin, uint8_t i2cAddressHex = 0x76, int16_t maxPressure = 14, uint8_t measurementsToAverage = 1) explicit

Construct a new MeaSpecMS5803 object.

Parameters
powerPin

The pin on the mcu controlling power to the MS5803 Use -1 if it is continuously powered.

  • The MS5803 requires a 1.7 - 3.6V power source
i2cAddressHex The I2C address of the MS5803; must be either 0x76 or 0x77. The default value is 0x76.
maxPressure The maximum pressure of the specific MS5803 in bar. The sensors are maufactured with maximum pressures of 1.1 bar, 1.3 bar, 5 bar, 7 bar, 14 bar, and 30 bar.
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.

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 sets the pin modes for _powerPin and I2C, reads coefficients from the MS5803, and updates the _sensorStatus. The MS5803 must be powered for setup. The wrapped function reading the coefficients doesn't return anything to indicate failure or success, we just have to hope it succeeded.


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.