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.
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.
(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.
[no_std]
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 // embedded_hal implementation use rppal::{spi::{Spi, Bus, SlaveSelect, Mode, Error},hal::Delay};
use hx711_spi::Hx711; use nb::block;
// minimal example fn main() -> Result<(), Error> { let spi = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 1000000, Mode::Mode0)?; let mut hx711 = Hx711::new(spi, Delay::new());
hx711.reset()?;
let v = block!(hx711.read())?;
println!("value = {}", v);
Ok(())
}
```
All kind of feedback is welcome. If you have questions or problems, please post them on the issue tracker This is literally the first code I ever wrote in rust. I am still learning. So please be patient, it might take me some time to fix a bug. I may have to break my knowledge sound-barrier. If you have tested on another platform I'd like to hear about that, too!
Licensed under either of
at your option.