Skip to content

Command line interface

Lorenzo Pistone edited this page Mar 19, 2025 · 3 revisions

The scale sports a command line interface (CLI) that can be used over the USB cable.

Command format

The CLI parser expects a command on each full line of input. Command format is:

command [arg1 arg2 ...]

Spaces are trimmed left and right of every word. Backspace can be used for correction before sending a newline. The character \r (carriage return) is always stripped to help with cross linux/windows/osx compatibility.

The CLI can be accessed by opening the monitoring port of your Arduino device while attached to your PC. You can either use the VSCode PlatformIO plugin or the Arduino IDE. Alternatively, you can invoke the monitor program from the shell:

# in directory should be blastic-scale

# PlatformIO
pio monitor

# or arduino-cli

arduino-cli monitor --fqbn arduino:renesas_uno:unor4wifi --config baudrate=115200 -p $PORT

Running commands from the SD card

A rudimentary form of configuration by files on the SD card is supported. When the scale powers up, it looks for two files, and executes commands found within. The files are:

  • cmdboot: run every time it is found
  • cmdonce: run once, then deleted from the SD.

Use case: initial configuration without usb cable

Place these commands in the cmdonce file:

set config.wifi.ssid $your_network_name
set config.wifi.password $your_password
set config.submit.collectionPoint $place
set config.submit.collectorName $name
eeprom::save

If you also want to calibrate the scale, also append these lines to the same file:

sleep 10
scale::calibrate $weight

The 10 seconds delay allows you to place the calibration weight on the scale, after the scale boots and sets the initial tare as usual.

Use case: eeprom is fried

The eeprom has a limited number of erase operation. If for any reason you happen to observe faulty eeprom behavior (especially during the eeprom::save command), you can resort to this configuration method and avoid replacing the Arduino board: just place all the configuration commands into cmdboot.

Setting and getting variables

Many configuration knobs are simple variables that can be read and written to (if not read-only). You can manipulate these variables with the commands:

get $address
set $address $value

Commands reference

command defaults description
uptime uptime according to millis()
get, set Variables reference
tasks show FreeRTOS task information
sleep $seconds 0 interrupt the cli for $seconds
scale::tare tare the scale (median out of 16 weighings)
scale::calibrate $weight calibrate the scale (median out of 16 weighings) with the calibration $weight (kg)
scale::raw $width 1 get raw sensor value of the scale (median out of $width weighings)
scale::weight $width 1 read scale weight (median out of $width weighings)
wifi::status get the wifi status and firmware version
wifi::connect probe the wifi connection
wifi::tls $hostname $port $words... $port=443 connect to $hostname:$port (on TLS with certificate validation), send $words, and echo back the response NOTE: raw IP addresses do not work, if you need to test connectivity to an $ip use $ip.nip.io
submit::action $action send a button press, one of OK, PREVIOUS, NEXT, BACK
buttons::reload reinitialize the buttons (Renesas CTSU hardware for capacitive buttons) with the current configuration
eeprom::save write the current live configuration onto the eeprom
eeprom::blank erase the eeprom
sd::probe probe the SD card
ntp::epoch retrieve epoch, 0 if ntp has not succeeded yet
ntp::sync attempt an ntp sync

Clone this wiki locally