HX711 driver (based on WiringPi) for Raspberry Pi



Program depends on WiringPi library, which can be installed using the following command:

sudo apt intall wiringpi

Of course, you must have g++ and make tools.


Build process is pretty simple:

CFLAGS=-O2 make -j4

You’ll get hx711 executable file.



./hx711 <human_mode> <correction_factor> <offset> <alignment_string> <moving_average> <times> <dout> <sck> <deviation_factor> <deviation_value> <retries> <use_ta_filter> <use_kalman_filter> <kalman_q> <kalman_r> <kalman_f> <kalman_h> <temperature_filename> <temperature_factor> <base_temperature> <debug>
  • int human mode – 0 – Normal mode, 1 – Human mode (input and output all values as decimal except alignment string)
  • double (Human mode) string correction factor – correction factor, multiplies to a result value
  • int offset – result offset, appends to a result value
  • char * alignment_string – ascii-coded 16 bytes of double k and b factors from y = k * x + b
  • unsigned int moving average – moving average size
  • unsigned int times – count of consecutive measurements, which are used to reduce the value volatility
  • unsigned int doutdata out pin number (BCM)
  • unsigned int sckserial clock pin number (BCM)
  • int deviation factor – tolerance percentage
  • int deviation value – tolerance
  • unsigned int retries – count of retries before agree invalid values
  • int use TA filter – 0 – disable Tulpa Automatics filter, 1 – enable
  • int use Kalman filter – 0 – disable Kalman filter, 1 – enable
  • double (Human mode) string Kalman Q – the covariance of the process noise
  • double (Human mode) string Kalman R – the covariance of the observation noise
  • double (Human mode) string Kalman F – the state-transition model (set to 1)
  • double (Human mode) string Kalman H – the observation model (set to 1)
  • string temperature filename – a name of file contains temperature value
  • double (Human mode) string temperature factor – temperature compensation factor
  • int base temperature – reference temperature value (in thousandths of degrees Celsius)
  • int debug – 0 – disable debug, 1 – enable (debug messages outputs to stderr)

In Normal mode program writes an ascii-coded double values to stdout.




View Github