Walrus
Class to interface with the Walrus submersible temperature and pressure sensor. More…
#include <Walrus_I2C.h>
Inherits from NW_Sensor
Public Types
| Name | |
|---|---|
| enum uint8_t | Component { MS5803 = 0x01, MCP9808 = 0x02, ALL = 0x03} Chip groups a reading can cover (the spec’s chip table: 0 MS5803, 1 MCP9808). |
Public Functions
| Name | |
|---|---|
| Walrus() Instantiate Walrus object. |
|
| bool | begin(uint8t Address =DEFAULT_ADDRESS) Begin communications with the Walrus using a prescribed address. |
| bool | updateMeasurements(uint8_t component =ALL) Take the configured number of readings of the selected chips and store them for the getters and the statistics. |
| bool | updatePressure() Take ONE reading of the MS5803 (pressure and its temperature) and append it to the readings. |
| bool | updateTemperature() Take ONE reading of the MCP9808 (external temperature) and append it to the readings. |
| uint16_t | setPressureReadings(uint16_t n) Set how many MS5803 readings updateMeasurements() takes (statistics are computed over them). Clamped to WALRUS_PRESSURE_CAPACITY. |
| uint16_t | setTemperatureReadings(uint16_t n) Set how many MCP9808 readings updateMeasurements() takes. Clamped to WALRUS_TEMPERATURE_CAPACITY. |
| void | setPressureStats(bool enable) Enable or disable pressure and MS5803-temperature std and sterr columns in getString()/getHeader(). |
| void | setTemperatureStats(bool enable) Enable or disable external-temperature std and sterr columns in getString()/getHeader(). |
| uint16_t | getPressureCount() Number of valid MS5803 readings stored by the last updateMeasurements(). |
| uint16_t | getTemperatureCount() Number of valid MCP9808 readings stored by the last updateMeasurements(). |
| float | getTemperature(uint8_t Location) Return calculated temperature from Walrus. |
| float | getTemperature() Return the MS5803 temperature (getTemperature(1)). |
| float | getPressure() Return calculated pressure from sensor [mBar]. |
| float | getPressureMean() Pressure mean [mBar] over the stored readings (NW_ERROR when none). |
| float | getPressureStd() Pressure standard deviation [mBar]. |
| float | getPressureSterr() Pressure standard error [mBar]. |
| float | getPressureMedian() Pressure median [mBar] (mean of the middle pair for even N). |
| float | getTemperatureMean(uint8_t Location) Temperature mean [C] over the stored readings; Location 0 = MCP9808, 1 = MS5803. |
| float | getTemperatureStd(uint8_t Location) Temperature standard deviation [C]; Location as getTemperature(). |
| float | getTemperatureSterr(uint8_t Location) Temperature standard error [C]; Location as getTemperature(). |
| float | getTemperatureMedian(uint8_t Location) Temperature median [C]; Location as getTemperature(). |
| String | getHeader() Return header. |
| String | getString() Take a reading (updateMeasurements()) and return it as a string. |
| size_t | printHeader(Print & out) Print the header matching printReading(): column names with units, each followed by a comma, for the chips selected by beginReadings(). No statistics columns: one reading has none. |
| size_t | printReading(Print & out) Print the stored reading of the selected chips, each value followed by a comma. Does not acquire: call updateMeasurements() first, or use logReading(). Writes: pressure [mBar], MS5803 temperature [C] for MS5803; external temperature [C] for MCP9808. |
| size_t | logReading(Print & out) Take ONE reading of the selected chips and print it: the one-reading primitive for collecting many readings to a file. |
| void | beginReadings(uint8_t component =ALL, uint16_t n =0) Begin a run of readings, selecting which chips they cover. |
| void | endReadings() End a run of readings. |
| bool | newData() Checks for updated data. Returns true if the device’s ready bit is set; otherwise returns false. |
| bool | ready() Status ready bit: the data registers hold a complete reading. |
| bool | newReading() The reading counter has advanced since the last request. |
| bool | requestReading() Trigger a reading of both chips without waiting for it. |
| bool | faulted(uint8_t chip) True if the given chip (0 = MS5803, 1 = MCP9808) was faulted in the last reading. |
| bool | anyFault() True if any chip was faulted in the last reading (status pan-fault bit). |
| uint8_t | reportChip() Chip index of the report (0 MS5803, 1 MCP9808, 7 the unit); meaningful when reportKind() != 0. |
| uint8_t | reportKind() Kind of the report, per the spec’s table (1 not answering, 6 restarted since configured, …). |
| size_t | printReport(Print & out) Print the report as text, e.g. “MS5803: not answering”; “none” when there is no fault. |
| String | reportNote() The report as one word for a note column: “MS5803NotAnswering”, “UnitRestarted”; “UnitNone” when none. |
| size_t | printStatus(Print & out, bool boot =false) override Print one status line for a logger’s status file: name, serial, versions, the last report, Pages 0-2 in hex; no newline, not answering. |
| const char * | name() const override |
| bool | reportIsFault() override |
| uint8_t | bootReportKind() override |
| void | clearBootReport() override |
| String | beginFailure() Why the last begin() refused, as one word: “NotAnswering”, “NotSchema1”, “WrongName”, “OldFirmware”; “None” after success. |
| uint8_t | getHardwareMajor() |
| uint8_t | getHardwareMinor() |
| uint8_t | getFirmwareVersion() |
Public Attributes
| Name | |
|---|---|
| constexpr uint8_t | DEFAULT_ADDRESS Default I2C address: NW-Device-Specification Schema 1 ‘W’ (0x57). |
Detailed Description
class Walrus;
Class to interface with the Walrus submersible temperature and pressure sensor.
The Walrus is an encapsulated submersible pressure and temperature sensor intended for water-level or barometric monitoring.
[](https://zenodo.org/badge/latestdoi/219609527) ```
## Public Types Documentation
### enum Component
| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| MS5803 | 0x01| pressure and the MS5803's own temperature |
| MCP9808 | 0x02| external (water) temperature |
| ALL | 0x03| |
Chip groups a reading can cover (the spec's chip table: 0 MS5803, 1 MCP9808).
## Public Functions Documentation
### function Walrus
```cpp
Walrus()
Instantiate Walrus object.
function begin
bool begin(
uint8_t Address_ =DEFAULT_ADDRESS
)
Begin communications with the Walrus using a prescribed address.
Parameters:
- Address_ I2C address of Walrus
Return: true if the device answered and passed the three gates
Refuses the device unless Page 0 says Schema 1, the name “Walrus”, and a firmware patch of at least WALRUS_FW_MIN_PATCH; beginFailure() says which gate refused.
function updateMeasurements
bool updateMeasurements(
uint8_t component =ALL
)
Take the configured number of readings of the selected chips and store them for the getters and the statistics.
Parameters:
- component Walrus::ALL (default), Walrus::MS5803 or Walrus::MCP9808.
Return: true if every selected chip gave at least one valid reading
Each reading triggers the device and waits for its reading counter to advance (NW-Device-Specification handshake); N > 1 is declared to the device as a batch first. The single-value getters return the mean of the readings taken; a chip the device reports faulted leaves its values at NW_ERROR (-9999). With one reading of ALL, both chips are read in a single transaction.
function updatePressure
bool updatePressure()
Take ONE reading of the MS5803 (pressure and its temperature) and append it to the readings.
function updateTemperature
bool updateTemperature()
Take ONE reading of the MCP9808 (external temperature) and append it to the readings.
function setPressureReadings
uint16_t setPressureReadings(
uint16_t n
)
Set how many MS5803 readings updateMeasurements() takes (statistics are computed over them). Clamped to WALRUS_PRESSURE_CAPACITY.
Return: The number actually set.
function setTemperatureReadings
uint16_t setTemperatureReadings(
uint16_t n
)
Set how many MCP9808 readings updateMeasurements() takes. Clamped to WALRUS_TEMPERATURE_CAPACITY.
function setPressureStats
void setPressureStats(
bool enable
)
Enable or disable pressure and MS5803-temperature std and sterr columns in getString()/getHeader().
function setTemperatureStats
void setTemperatureStats(
bool enable
)
Enable or disable external-temperature std and sterr columns in getString()/getHeader().
function getPressureCount
uint16_t getPressureCount()
Number of valid MS5803 readings stored by the last updateMeasurements().
function getTemperatureCount
uint16_t getTemperatureCount()
Number of valid MCP9808 readings stored by the last updateMeasurements().
function getTemperature
float getTemperature(
uint8_t Location
)
Return calculated temperature from Walrus.
Parameters:
- Location 0: Read dedicated temperature sensor. 1: Read temperature sensor within the MS5803.
This calculated temperature can be from either the MS5803 sensor, which primarily measures pressure, or from the dedicated MCP9808 sensor. Values are those stored by the last updateMeasurements() (NW_ERROR before the first).
function getTemperature
float getTemperature()
Return the MS5803 temperature (getTemperature(1)).
function getPressure
float getPressure()
Return calculated pressure from sensor [mBar].
This is the MS5803 sensor, which can come in a variety of different pressure ranges and sensitivities. The mean of the readings stored by the last updateMeasurements().
function getPressureMean
float getPressureMean()
Pressure mean [mBar] over the stored readings (NW_ERROR when none).
function getPressureStd
float getPressureStd()
Pressure standard deviation [mBar].
function getPressureSterr
float getPressureSterr()
Pressure standard error [mBar].
function getPressureMedian
float getPressureMedian()
Pressure median [mBar] (mean of the middle pair for even N).
function getTemperatureMean
float getTemperatureMean(
uint8_t Location
)
Temperature mean [C] over the stored readings; Location 0 = MCP9808, 1 = MS5803.
function getTemperatureStd
float getTemperatureStd(
uint8_t Location
)
Temperature standard deviation [C]; Location as getTemperature().
function getTemperatureSterr
float getTemperatureSterr(
uint8_t Location
)
Temperature standard error [C]; Location as getTemperature().
function getTemperatureMedian
float getTemperatureMedian(
uint8_t Location
)
Temperature median [C]; Location as getTemperature().
function getHeader
String getHeader()
Return header.
“Pressure [mBar],Temp DH [C],Temp DHt [C],” with std and sterr columns after a value when its statistics are enabled and more than one reading is configured.
function getString
String getString()
Take a reading (updateMeasurements()) and return it as a string.
String(getPressure()) + “,” + String(getTemperature(0))
- ”,” + String(getTemperature(1)) + “,”; statistics columns as getHeader() describes.
function printHeader
size_t printHeader(
Print & out
)
Print the header matching printReading(): column names with units, each followed by a comma, for the chips selected by beginReadings(). No statistics columns: one reading has none.
Parameters:
- out Any Print destination (SdFat File, Serial, …).
Return: Bytes written.
function printReading
size_t printReading(
Print & out
)
Print the stored reading of the selected chips, each value followed by a comma. Does not acquire: call updateMeasurements() first, or use logReading(). Writes: pressure [mBar], MS5803 temperature [C] for MS5803; external temperature [C] for MCP9808.
Return: Bytes written.
function logReading
size_t logReading(
Print & out
)
Take ONE reading of the selected chips and print it: the one-reading primitive for collecting many readings to a file.
Return: Bytes written.
function beginReadings
void beginReadings(
uint8_t component =ALL,
uint16_t n =0
)
Begin a run of readings, selecting which chips they cover.
Parameters:
- component Walrus::ALL, Walrus::MS5803 or Walrus::MCP9808.
- n How many readings the run will take (the number of logReading() calls to follow); with n > 1 the device is told in advance (readings-requested word). Nothing on Walrus is powered per batch, so the word only satisfies the protocol.
function endReadings
void endReadings()
End a run of readings.
function newData
bool newData()
Checks for updated data. Returns true if the device’s ready bit is set; otherwise returns false.
Deprecated:
Use ready(); the handshake is newReading() after requestReading().
function ready
bool ready()
Status ready bit: the data registers hold a complete reading.
function newReading
bool newReading()
The reading counter has advanced since the last request.
function requestReading
bool requestReading()
Trigger a reading of both chips without waiting for it.
function faulted
bool faulted(
uint8_t chip
)
True if the given chip (0 = MS5803, 1 = MCP9808) was faulted in the last reading.
function anyFault
bool anyFault()
True if any chip was faulted in the last reading (status pan-fault bit).
function reportChip
uint8_t reportChip()
Chip index of the report (0 MS5803, 1 MCP9808, 7 the unit); meaningful when reportKind() != 0.
function reportKind
uint8_t reportKind()
Kind of the report, per the spec’s table (1 not answering, 6 restarted since configured, …).
function printReport
size_t printReport(
Print & out
)
Print the report as text, e.g. “MS5803: not answering”; “none” when there is no fault.
function reportNote
String reportNote()
The report as one word for a note column: “MS5803NotAnswering”, “UnitRestarted”; “UnitNone” when none.
function printStatus
size_t printStatus(
Print & out,
bool boot =false
) override
Print one status line for a logger’s status file: name, serial, versions, the last report, Pages 0-2 in hex; no newline, not answering.
function name
inline const char * name() const override
function reportIsFault
bool reportIsFault() override
function bootReportKind
uint8_t bootReportKind() override
function clearBootReport
void clearBootReport() override
function beginFailure
String beginFailure()
Why the last begin() refused, as one word: “NotAnswering”, “NotSchema1”, “WrongName”, “OldFirmware”; “None” after success.
function getHardwareMajor
uint8_t getHardwareMajor()
function getHardwareMinor
uint8_t getHardwareMinor()
function getFirmwareVersion
uint8_t getFirmwareVersion()
Public Attributes Documentation
variable DEFAULT_ADDRESS
static constexpr uint8_t DEFAULT_ADDRESS = 0x57;
Default I2C address: NW-Device-Specification Schema 1 ‘W’ (0x57).
Updated on 2026-09-23 at 22:42:33 +0000