Sources

Sources are the locations of your sensor data. Most of the time this comes in two forms: IoT streaming data or large CSV files that a sensor has written to your disk. Many of the major sensor suppliers offer a way to store the logs to your desktop. These directories would be considered a source.

We need to let sparky know about these sources so that it can relay that data to aquaponic cloud dashboard. You can see what sources are supported when you run sparky source --help.

Creating a Source

You can create as many sources as you would like. These sources are stored by sparky and will update the cloud accordingly.

CSV

CSV is the most common log format and will probably be your go-to for setting up sparky.

To get started with a CSV source type the following command:

sparky source create-csv --directory ./relative/path/to/logs
1

This will walk you through the steps of setting up your directory and ask you the following

  • Selecting the Date Column which is the timestamp of the actual record. It should have year, month, day, hours, minutes and seconds.
  • It will also ask you for the column of the Metric you're trying to track. Sometimes a sensor records multiple readings so you can select the actual reading you're wanting to watch.
  • It will also ask you to name this source. We recommend using a name like "Company Sensor (pH)" and making sure you can distinguish it from other sources.

You can then verify the creation of your source by running sparky source list

MQTT

MQTT sources are endpoints that you can subscribe to using a MQTT client. sparky has a built-in MQTT listener that will forward the data to your aquaponic cloud dashboard.

sparky source create-mqtt
1

Formatting Options

MQTT endpoints from various suppliers can be quite unstandardized. sparky supports a wide variety of formats between JSONopen in new window payload and numeric payload support.

By default, when creating a MQTT source, sparky treats the received payload as a number and the timestamp is automatically the current time on the machine.

27.243
1

If your integrating with a more complex setup you can use dot notation to identify the data in the payload:

{
    "data": {
        "timestamp": "21/10/2020 15:12",
        "value": 27.43
    }
}
1
2
3
4
5
6

In this example the reading value would use data.value and the timestamp would be data.timestamp. You may also notice that the timestamp is in a custom format so we must account for the format as well. This payload can be processed by the following configuration:

sparky source create-mqtt \
    --endpoint xxx.xxxx.com:4000 \
    --topic topicname/subtopic \
    --date-format "02/01/2006 15:04" \
    --timezone Pacific/Auckland \
    --date-path data.timestamp \
    --value-path data.value
1
2
3
4
5
6
7

For a list of all the configuration options run:

sparky source create-mqtt --help
1

Supported Hardware

Fortunately, you don't have to memorize these configurations for common suppliers. We've included helpers for the most common suppliers. You can use these commands to import the CSV files from the respective supplier.

Hanna Instruments

GroLine Monitor

sparky source create-csv --device hanna.groline \
    --directory ./path/to/groline/ \
    --value-index <NUMBER>
1
2
3

The groline monitor has the following index mapping. Replace <NUMBER> in the command above with the number below to import that value.

  • Minimum pH 2
  • Maximum pH 4
  • Average pH 6
  • Minimum EC 8
  • Maximum EC 10
  • Average EC 12
  • Minimum Temperature 14
  • Maximum Temperature 16
  • Average Temperature 18

Bluelab

Bluelab Guardian

sparky source create-csv --device bluelab.guardian \
    --directory ./path/to/bluelab/ \
    --value-index <NUMBER>
1
2
3

The Bluelab Guardian has the following index mapping. Replace <NUMBER> in the command above with the number below to import that value.

  • EC 3
  • pH 4
  • Temperature 5
Last Updated: 10/23/2022, 1:45:24 PM
Contributors: Jonathan Reyes