Crate hx711_spi[][src]

Expand description

HX711 embedded-hal SPI driver crate

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

Usage

Use an embedded-hal implementation to get SPI and Delay. 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.

Examples

// 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, 1_000_000, Mode::Mode0)?;
    let mut hx711 = Hx711::new(spi, Delay::new());

	hx711.reset()?;
    let v = block!(hx711.read())?;
	println!("value = {}", v);

    Ok(())
}

References

Structs

Represents an instance of a HX711 device

Enums

The HX711 has two chanels: A for the load cell and B for AD conversion of other signals. Channel A supports gains of 128 (default) and 64, B has a fixed gain of 32.