Skip to content

Device configuration

Configuration commands

Interactive mode

For simplicity, in interactive mode all commands are 1 character long, (plus the Enter,line-feed, '\n', ASCII 0x0D). In case the command is sent through the CLI: $ printf 'C\n' > /dev/ttyACM0

JSON mode

The user should ensure that the string to send is a valid json object (programatically or you could use a linter, like https://jsonlint.com for instance).

The commands can also be combined in one JSON object. For example: {"led":true,"reportingPeriod":30,"format":"CSV"}

NOTE: For both modes. A status report is always returned after a command. This helps to ensure that the command was received properly.

Reporting format

Interactive

Command Format
J JSON
C CSV
M HUMAN

JSON

Command Format
{"format":"json"} JSON
{"format":"csv"} CSV
{"format":"human"} HUMAN

Reporting period

In some cases, like when performing data collection for long periods of time (weeks, months), it's convenient to reduce the reporting frequency, and avoid overloading the database with too much data if the smaller granularity is not needed.

Interactive

Command Reporting period
1 1 second (default)
2 10 seconds
3 30 seconds
4 1 minute
5 10 minutes
6 30 minutes
7 1 hour

JSON

Command Reporting period
{"reportingPeriod":integer} in seconds (min. 1, max. 3600)

LEDs On/Off

Interactive

Command State
E Enabled
D Disabled

JSON

Command State
{"led":boolean} true / false (Enabled / disabled)

Calibrate

Interactive

This command triggers the calibration procedure. It's only available for the Interactive mode, check here for more details.

Command State
K Start calibration

Save configuration

This command is only available for the JSON mode, and it saves the configuration in permanent storage (it's maintained after reconnecting the device):

Command Detail
{"saveConfig": true} Store the configuration in Flash memory

Status

Interactive

Command Detail
S Retrieves the device, firmware, serial number, configuration, calibration parameters and uptime (in ms)

Status response:

--------------------------------------------------------
***  Device: *"uThing::iPH rev.A"* -- Status:
 Reporing period: 1 sec, Format: CSV, Uptime: 370283 ms, Serial #: 7F8D2D3F608B7E54, FW: v0.1.0, Calibration: Slope 1.00, Offset 0.02
--------------------------------------------------------

JSON

Command State
{"status":true} Retrieves the configuration, calibration parameters and uptime (in ms)

Status response:

{
    "status": {
        "reportingPeriod": 1,
        "format": "JSON",
        "slopeCalib":1.01,
        "offsetCalib":0.02,
        "upTime": 1802065
    }
}

Info

This is available only in JSON since the same information is already returned for the status command in interactive mode:

Command State
{"info":true} Retrieves the device information (HW, FW and Serial number)

Response:

{
    "info": {
        "device": "uThing::iPH rev.A",
        "serial": "7F8D2D3F608B7E54",
        "firmware": "1.0.0"
    }
}

Commands summary

The table below summarizes the commands available in FW v1.0.0:

Command Interactive JSON Description
Format [J, C, M] {"format":"string"} Change reporting format (JSON, CSV, HUMAN)
Period [1-7] {"reportingPeriod":integer} Change reporting period
LEDs [E, D] {"led":boolean} Enable / Disable LEDs
Calibrate [K] not-available Start calibration procedure
SaveConfig not-available {"saveConfig":true} Save configuration parameters
Status [S] {"status":true} Show actual configuration
DeviceInfo [S] {"info":true} Show device info

The following response will also be printed when an invalid character is sent (the letter 'h' for example):

-------------------------------------------------------
***  Invalid option.
 Use:              [m] Human readable, [j] JSON, [c] CSV, [s] status, [e/d] enable/disable LED, [k] Start calibration
 Reporting period: [1] 1 sec, [2] 10 sec, [3] 30 sec, [4] 1 min, [5] 10 min, [6] 30 min, [7] 1 hour.
--------------------------------------------------------