hx711_spi

This is a platform agnostic driver to interface with the HX711 load cell IC. It uses SPI instad of bit banging. This driver is built using embedded-hal traits.

Why did I write another HX711 driver?

In multi-user / multi-tasking environments bit banging is not reliable. SPI on the other hand handles the timing with hardware support and is not influenced by other processes.

What works

(tested on Raspberry Pi)

No scales functions (like tare weight and calibration) are implemented because I feel that's not part of a device driver.

TODO

Usage

Use an embedded-hal implementation (e. g. rppal) to get SPI. HX711 does not use CS and SCLK. Make sure that it is the only device on the bus. Connect the SDO to the PD_SCK and SDI to DOUT of the HX711. SPI clock frequency has to be between 20 kHz and 5 MHz.

```rust use rppal::spi::{Spi, Bus, SlaveSelect, Mode}; use hx711_spi::{Hx711, HX711Mode};

let spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 1000000, Mode::Mode0).unwrap();

// to create sensor with default configuration: let mut scale = Hx711(spi);

// start measurements let mut value = scale.readout().unwrap(); ```

References

License

Licensed under either of

at your option.