sensor-hx711

CLI reference

glasgow run sensor-hx711

Measure voltage with AVIA Semiconductor HX711 wheatstone bridge analog-to-digital converter.

This applet can optionally provide a frequency source that can be connected to the XI pin. The provided frequency source is much more accurate than the internal oscillator of the HX711, and, depending on the state of the RATE pin, allows for a much wider sample rate range from approx. 1 Hz to approx. 144 Hz.

usage: glasgow run sensor-hx711 [-h] [-V SPEC] [--sck PIN] [--din PIN]
                                [--osc PIN] [-f FREQ] [-c CHAN] [-g GAIN]
                                OPERATION ...
-h, --help

show this help message and exit

-V <spec>, --voltage <spec>

configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)

--sck <pin>

bind the applet I/O line ‘sck’ to PIN (default: ‘A0’, required)

--din <pin>

bind the applet I/O line ‘din’ to PIN (default: ‘A1’, required)

--osc <pin>

bind the applet I/O line ‘osc’ to PIN (optional)

-f <freq>, --frequency <freq>

set reference oscillator frequency to FREQ MHz

-c {A,B}, --channel {A,B}

measure channel CHAN

-g {32,64,128}, --gain {32,64,128}

amplify GAIN times (64 or 128 for channel A, 32 for channel B)

glasgow run sensor-hx711 log

usage: glasgow run sensor-hx711 log [-h] DATA-LOGGER ...
-h, --help

show this help message and exit

glasgow run sensor-hx711 log csv

Log data to a comma-separated value (CSV) file.

usage: glasgow run sensor-hx711 log csv [-h] [--dialect DIALECT] CSV-FILE
csv-file

write data to CSV-FILE

-h, --help

show this help message and exit

--dialect {excel,excel-tab,unix}

format CSV file according to DIALECT

glasgow run sensor-hx711 log influxdb

Log data to an InfluxDB 1.x endpoint over HTTP(S).

usage: glasgow run sensor-hx711 log influxdb [-h] [-r POLICY] [-t TAG=VALUE]
                                             -p PRECISION
                                             [--batch-size BATCH-SIZE]
                                             ENDPOINT DATABASE SERIES
endpoint

write to endpoint URL //ENDPOINT/write

database

write to database DATABASE

series

write to measurement SERIES

-h, --help

show this help message and exit

-r <policy>, --retention-policy <policy>

write to retention policy POLICY

-t <tag=value>, --tag <tag=value>

attach TAG=VALUE to all data points

-p {ns,us,ms,s,m,h}, --precision {ns,us,ms,s,m,h}

set timestamp precision to PRECISION

--batch-size <batch-size>

submit data in groups of BATCH-SIZE points

glasgow run sensor-hx711 log influxdb2

Log data to an InfluxDB 2.x endpoint over HTTP(S).

usage: glasgow run sensor-hx711 log influxdb2 [-h] [-t TAG=VALUE] -p PRECISION
                                              [--batch-size BATCH-SIZE]
                                              --token TOKEN
                                              ENDPOINT ORGANIZATION BUCKET
                                              SERIES
endpoint

write to endpoint URL //ENDPOINT/api/v2/write

organization

write to Organization ORGANIZATION (can be either the name or the id)

bucket

write to bucket BUCKET

series

write to measurement SERIES

-h, --help

show this help message and exit

-t <tag=value>, --tag <tag=value>

attach TAG=VALUE to all data points

-p {ns,us,ms,s,m,h}, --precision {ns,us,ms,s,m,h}

set timestamp precision to PRECISION

--batch-size <batch-size>

submit data in groups of BATCH-SIZE points

--token <token>

set the Token to use for Authentication

glasgow run sensor-hx711 log stdout

Log data to standard output in a human-readable format.

usage: glasgow run sensor-hx711 log stdout [-h]
-h, --help

show this help message and exit

glasgow run sensor-hx711 measure

usage: glasgow run sensor-hx711 measure [-h]
-h, --help

show this help message and exit

API reference

exception glasgow.applet.sensor.hx711.HX711Error
class glasgow.applet.sensor.hx711.SensorHX711Interface(logger: Logger, assembly: AbstractAssembly, *, sck: GlasgowPin, din: GlasgowPin)
property sck_clock: ClockDivisor

Serial Clock (sck) clock divisor.

The recommended frequency is 1MHz, otherwise the valid range is 20kHz to 5MHz.

async sample(next_setting: HX711Setting) int

Read the current sample, and initiate the conversion of the next sample.

next_setting determines the channel and gain of the next sample.

Returns the sample as a signed 24 bit integer, which can be converted into the measured differential voltage with the formula: \(v = (sample/2^{23}) * (0.5AVDD/GAIN)\)