ModularSensors > Modules > Supported Sensors > Measurement Specialties MS5803

Measurement Specialties MS5803 module

Classes for the Measurement Specialties MS5803 digital preassure sensor.

Introduction

The Measurement Specialties MS5803 is a miniature digital pressure sensor. It comes in several different pressure ranges, with 14 bar being one of the most common. Although this sensor has the option of either I2C or SPI communication, this library only supports I2C. The sensor's I2C address is determined the voltage level of the CSB pin; it will be either 0x76 or 0x77. Breakout boards purchased from Sparkfun are set to 0x76 while those from Northern Widget are variable depending on the model as outlined in their library. To connect two of these sensors to your system, you must ensure they are soldered so as to have different I2C addresses. No more than two can be attached. These sensors should be attached to a 1.7-3.6V power source and the power supply to the sensor can be stopped between measurements.

The lower level communication between the mcu and the MS5803 is handled by the Northern Widget MS5803 library.

Sensor Datasheet

Documentation for the sensor can be found at: https://www.sparkfun.com/products/12909 and https://cdn.sparkfun.com/datasheets/Sensors/Weather/sensor_ms5803_14ba.pdf

The datasheet is also available here: https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Measurement-Specialities-MS5803-14ba-Pressure-Sensor.pdf

Sensor Constructor

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.


Example Code

The Measurement Specialties MS5803 is used in the menu a la carte example.

#include <sensors/MeaSpecMS5803.h>

// NOTE: Use -1 for any pins that don't apply or aren't being used.
const int8_t  MS5803Power = sensorPowerPin;  // Power pin
const uint8_t MS5803i2c_addr =
    0x76;  // The MS5803 can be addressed either as 0x76 (default) or 0x77
const int16_t MS5803maxPressure =
    14;  // The maximum pressure measurable by the specific MS5803 model
const uint8_t MS5803ReadingsToAvg = 1;

// Create a MeaSpec MS5803 pressure and temperature sensor object
MeaSpecMS5803 ms5803(MS5803Power, MS5803i2c_addr, MS5803maxPressure,
                     MS5803ReadingsToAvg);

// Create pressure and temperature variable pointers for the MS5803
Variable* ms5803Press =
    new MeaSpecMS5803_Pressure(&ms5803, "12345678-abcd-1234-ef00-1234567890ab");
Variable* ms5803Temp =
    new MeaSpecMS5803_Temp(&ms5803, "12345678-abcd-1234-ef00-1234567890ab");

Classes

class MeaSpecMS5803
The Sensor sub-class for the Measurement Specialties MS5803 sensor.
class MeaSpecMS5803_Temp
The Variable sub-class used for the temperature output from a Measurement Specialties MS5803 digital pressure sensor.
class MeaSpecMS5803_Pressure
The Variable sub-class used for the pressure output from a Measurement Specialties MS5803 digital pressure sensor.

Defines

#define MS5803_NUM_VARIABLES = 2
Sensor::_numReturnedValues; the MS5803 can report 2 values.
#define MS5803_INC_CALC_VARIABLES = 0
Sensor::_incCalcValues; we don't calculate any additional values.

Sensor Timing

The sensor timing for a Measurement Specialties MS5803

#define MS5803_WARM_UP_TIME_MS = 10
Sensor::_warmUpTime_ms; the MS5803 warms up in 10ms.
#define MS5803_STABILIZATION_TIME_MS = 0
Sensor::_stabilizationTime_ms; the MS5803 is stable as soon as it warms up (0ms stabilization).
#define MS5803_MEASUREMENT_TIME_MS = 10
Sensor::_measurementTime_ms; the MS5803 takes 10ms to complete a measurement.
  • Sensor takes about 0.5 / 1.1 / 2.1 / 4.1 / 8.22 ms to respond at oversampling ratios: 256 / 512 / 1024 / 2048 / 4096, respectively.

Temperature

The temperature variable from a Measurement Specialties MS5803

  • Range is -40°C to +85°C
  • Accuracy is ±0.8°C

MeaSpecMS5803_Temp(MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_TEMP_DEFAULT_CODE) explicit

Construct a new MeaSpecMS5803_Temp object.

Parameters
parentSense The parent MeaSpecMS5803 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 "MeaSpecMS5803Temp".

#define MS5803_TEMP_RESOLUTION = 2
Decimals places in string representation; temperature should have 2 - resolution is <0.01°C.
#define MS5803_TEMP_VAR_NUM = 0
Sensor variable number; temperature is stored in sensorValues[0].
#define MS5803_TEMP_VAR_NAME = "temperature"
Variable name in ODM2 controlled vocabulary; "temperature".
#define MS5803_TEMP_UNIT_NAME = "degreeCelsius"
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define MS5803_TEMP_DEFAULT_CODE = "MeaSpecMS5803Temp"
Default variable short code; "MeaSpecMS5803Temp".

Pressure

The pressure variable from a Measurement Specialties MS5803

  • Range is 0 to 14 bar
  • Accuracy between 0 and +40°C is:
    • 14ba: ±20mbar
    • 2ba: ±1.5mbar
    • 1ba: ±1.5mbar
  • Long term stability is:
    • 14ba: -20 mbar/yr
    • 2ba: -1 mbar/yr
  • Resolution is: (at oversampling ratios: 256 / 512 / 1024 / 2048 / 4096, respectively))
    • 14ba: 1 / 0.6 / 0.4 / 0.3 / 0.2 mbar (where 1 mbar = 100 pascals)
    • 2ba: 0.13 / 0.084 / 0.054 / 0.036 / 0.024
    • 1ba: 0.065 / 0.042 / 0.027 / 0.018 / 0.012
    • MS5803_PRESSURE_RESOLUTION = 3

MeaSpecMS5803_Pressure(MeaSpecMS5803* parentSense, const char* uuid = "", const char* varCode = MS5803_PRESSURE_DEFAULT_CODE) explicit

Construct a new MeaSpecMS5803_Pressure object.

Parameters
parentSense The parent MeaSpecMS5803 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 th a default value of MeaSpecMS5803Pressure

#define MS5803_PRESSURE_RESOLUTION = 3
Decimals places in string representation; pressure should have 3.
#define MS5803_PRESSURE_VAR_NUM = 1
Sensor variable number; pressure is stored in sensorValues[1].
#define MS5803_PRESSURE_VAR_NAME = "barometricPressure"
Variable name in ODM2 controlled vocabulary; "barometricPressure".
#define MS5803_PRESSURE_UNIT_NAME = "millibar"
Variable unit name in ODM2 controlled vocabulary; "millibar".
#define MS5803_PRESSURE_DEFAULT_CODE = "MeaSpecMS5803Pressure"
Default variable short code; "MeaSpecMS5803Pressure".