Design
I want to be able to monitor my bilge pump, nicely integrated into the NMEA 2000 and SignalK network I'm adding to Off Beat. But I couldn't find anything available off the shelf and decided to roll my own. Building it involved a deep dive into SignalK, which turned out to be a pleasant journey of its own.
Bis and pieces
- SignalK
- signalk-hour-meter by JoelKoz, credit where credit is due.
- kip -- Browser based instrument panel
- Raspberry Pi for on-boat server
- PICAN NMEA2000 HAT for RasPi
Design
Goals
Real time monitoring
These statistics are intended for display on a monitoring instrument, to convey quick at-a-glance info.
- Respond within seconds to pump changes
- Be able to report:
- Current status (running, not running or not reporting)
- Total run time
- Number of pump cycles
- (goal) length of current run, if pump is running
Pump (and the pump monitor) has a status:
- ON -- pump is running
- OFF -- Pump is reporting that it is not running
- OFFLINE -- monitor is not hearing status from pump sensor.
Monitor should assume pump continues in its last reported state for a (configurable) while, but if offline continues for longer than that, monitor will assumme pump has gone OFF and complete the cycle. [[this makes sense for a bilge pump with typically short duty cycle. Is it right for other kinds of pumps?]]
The monitor itself can also be OFFLINE, and raises the question of how to account for that in the history and calculations like alarms based on history.
Historical analysis
These statistics indended for display in some kind of evaluation setting, where user is reviewing or troubleshooting.
- Retain history over significant time: months to years.
- Persistent data.
- Be able to show:
- History of pump cycles over time
- Alerts for sudden (or even slower but persistent) changes in pump run time, for example gradual increase in run time over last few weeks, "short cycling" where it wasn't the norm, or pump not running at all for "too" long.
SignalK Alarms
Whether this is real-time in SignalK, or only calculated based on history is TBD. But I'd like to have warning and Alert threshholds for:
- Pump has not run for "too" long (based on history)
- Pump runtime is steadily increasing
Specs
Configuration
SignalK Deltas
Inputs
Pump Meter monitors a configured external path for on / off values
Outputs
- TotRunTime -- cumulative run time, origin to date
- TotCycleCount -- count of complete cycles, origin to date. A cycle is completed by an ON to OFF transition (after an OFF to ON transition). Both transitions should be "debounced" to avoid jitter.
- Status -- pump is ON, or OFF or OFFLINE (not reporting at all)
- CurrentRunTime -- Duration of current cycle, if pump is running. 0 Else.
- LastRunTime -- Duration of last complete cycle. Updated when a cycle completes.
- LastStart -- When the last complete cycle started. Value is number of seconds before the time of report, since SignalK doesn't have a date/time datatype.
To report these, meter is also tracking the following internal statistics: CurrentCycleStartTime -- a date/time LastCycleStartTime
History API
Note: need to think about date/time. Signal K server may not have a super reliable system clock and won't necesssarily have access to time sync over the internet. But for now, assuming we do have a reliable, accurate clock to report (UTC) date/time.
Raw history
History of completed cycles, possibly filterable by date or count
Request: RAW/ [ ?start="date/time" [ &end="date/time" ]]
Response: