Monitoring Scope – Part 2

We monitor quite a bit of “stuff” in Molly. Maybe too much stuff. But once the monitoring infrastructure was put in place, it was just too easy to add extra sensors and monitor more things. So we did.

In Part 1, we produced a prototype to make sure things would work and select the best components and software for the job. In this part, we highlight the scope of the monitoring system and how we use the information. We also explore the data structure used to store the information.

For the nitty-gritty of each sensor used and details of its installation can be found in individual posts related to the what’s being monitored.

The grand vision is to quietly log everything, so we can recall these logs later when needed. Once all of the sensors are installed, it is practically free to continuously log.

Our logs fall into one of six main areas:

  • Location. Obviously latitude, longitude and altitude, but also other information about the quality of the GPS location fix and course and speed.
  • Truck. The truck gets us from A to B, and it is good idea to keep an eye on how it is performing. The Engine Control Unit (ECU) provides much of the statistics, with other measures like fuel level being derived.
  • Environment. The inside and outside temperatures, relatively humidity and barometric pressure.
  • Batteries. Mainly the house batteries, but also the truck batteries. This allows us to manage our power usage and charging strategy.
  • Solar. So we can make sure our generating capability is working.
  • Water. Fresh and waste water levels. Mainly to monitor water consumption.

Sometimes you wake up in the morning wondering what the overnight low temperature was? Or maybe at the end of a long day we are interested to know how many vertical meters we just drove? These and many more questions can be quickly answered.

Additionally, we can mix and match the information across these above six areas. For example, we log our energy consumption, and later we might want to see if it changes with outside temperature. And we can associate any measurement when it was made, but also where it was made, as we constantly record our location.

We also calculate some derived values and place them in the time-series database. For example, water consumption can be derived from the running hours of the water pump. And this is much more accurate than the ultrasonic water sensors.

To allow for these more complex queries, the information needs a little structure in our time-series database. Influxdb supports both fields and tags, which serve slightly different purposes. Fields are a good place to store values from the sensors, while tags are used to store metadata about the values, like what sensor produced the value or what source is associated with the field values. This is especially useful when you have two instances of the same thing, like two fresh water tanks, as the field key is the same in both cases, but the tag values will be different so each can be queried independently. And then there are measurements, which are like tables or groups of like fields with a retention policy. Enough about how data is stored in Influxdb.

In Molly the influx database will be stored on the computer. Ideally it would be stored on the Network Attached Storage (NAS) device because it has disk redundancy. And while Synology supports running Docker containers, it is not supported on our particular NAS model. Maybe we need the DS620slim?

In the meantime, the database can be backed up to the NAS with the followoing command, where the NAS is mounted in the home directory.

influxd backup -database Molly /home/stephen/mnt/mint/influxdb/backup-yyyy-mm-dd

Data Model (Illustrative)

The following data models provides a good summary of all the information that is logged.

Measurement
  |--- Field Keys [Field Value units]

Location
  |--- Latitude [Degrees]
  |--- Longitude [Degrees]
  |--- Altitude [meters]
  |--- Satellites in View [Number]
  |--- Horizontal Dilution of Precision [Relative]
  |--- Time of fix [hhmmss UTC]
  |--- Velocity Made Good [KPH]
  |--- True Course [Degrees]

Truck
  |--- Vehicle Speed [KPH]
  |--- Engine Speed [RPM]
  |--- Throttle Position [%]
  |--- Engine Coolant Temp [ºF]
  |--- Ignition Status [On/Off]
  |--- MIL Status [On/Off]
  |--- Fuel Rate [GPH]
  |--- Battery Voltage [V]
  |--- Misfire Monitor [On/Off]
  |--- Fuel System Monitor [On/Off]
  |--- Comprehensive Component Monitor [On/Off]
  |--- Catalyst Monitor [On/Off]
  |--- Heated Catalyst Monitor [On/Off]
  |--- Evaporative System Monitor [On/Off]
  |--- Secondary Air System Monitor [On/Off]
  |--- A/C System Refrigerant Monitor [On/Off]
  |--- Oxygen Sensor Monitor [On/Off]
  |--- Oxygen Sensor Heater Monitor [On/Off]
  |--- EGR System Monitor [On/Off]
  |--- Ambient Air Temperature  [ºC]
  |--- Trip Odometer [km]
  |--- Trip Fuel Consumption [gallons]
  |--- Fuel Efficiency [MPG]

Environment
  |--- Temperature [ºC]
  |--- Pressure [millibars]
  |--- Relative Humidity [TH%]
  |--- Heat Index [ºC]
  |--- Humindex [no units]
  |--- Dew Point [ºC]

Battery
  |--- Volts [V]
  |--- Amps [A]
  |--- State of Charge [%]
  |--- Time Remaining [hours]
  |--- Time Since Last Full Charge [seconds]
  |--- Depth of Last Discharge [mAh]
  |--- Depth of Average Discharge [mAh]

Solar
  |--- Charge State
  |--- Battery Potential [Volts]
  |--- Generating Current [Amps]

Water
  |--- Available [liters]
  |--- Consumed Water [liters]
  |--- Time since last Full/Empty Tank [mins]

Tags
  |--- Source
  |--- Sensor