crjeder / hx711_spi Goto Github PK
View Code? Open in Web Editor NEWThis is a library for the hx711 chip. It uses SPI instead of bit banging for more reliability.
License: MIT License
This is a library for the hx711 chip. It uses SPI instead of bit banging for more reliability.
License: MIT License
## TODO
Line 40 in 1516748
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Hey! I've tried connecting it to an stm32f103 ("blue pill") board and ran into a couple of issues that this patch seems to address.
First ChAGain128
seemed to be missing a 0
, noticed only because initially I tried with SPI mode 0
where the MOSI (used here as a clock driver) pin was going "high" in between bytes, resulting in an extra 1/0 transition.
That said running SPI in the mode 1 seems closer to the original intention of the code (not sure about rpi though).
This PR seems to fix it for me.
See a couple of screenshots below:
I wrote a test example for your library: https://github.com/pronvis/drawer-robot/blob/master/crates/companion/src/bin/hx711_spi_read.rs
And it reads absolutely noise:
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #26: DYMH-06 data: -221.92485
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #31: DYMH-06 data: -0.000035274
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #35: DYMH-06 data: -221.92485
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #40: DYMH-06 data: -0.000035274
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #44: DYMH-06 data: 184.93732
└─ hx711_spi_read::app::hx711_read @ src/bin/hx711_spi_read.rs:135
DEBUG #49: DYMH-06 data: 258.91226
but non-spi reader that is used here: https://github.com/pronvis/drawer-robot/blob/master/crates/companion/src/bin/hx711_read.rs
works fine. What could be wrong?
All the difference in pin connections is:
with spi:
PB13 <-> SCK
PB14 <-> DT
with non-spi:
PA7 <-> SCK
PA6 <-> DT
HX711 have two channels: A & B.
Is it possible to connect two measurment devices simultaneously and use your library?
Is your feature request related to a problem? Please describe.
I was trying to utilize the crate on ESP32-C3. The block!(hx711.read())
will always block. After digging around, I found the SDO of ESP32-C3 is always idle at HIGH and I haven't find a way to change the behavior. So I decided to use a MOSFET to hold the SDO at LOW when no data is transfered. However, the CS on ESP32-C3 is disabled after SDO pulled itself HIGH, the value I got is not correct.
Later I tried to invert the polarity of SDO with the MOSFET and change the code, it looks better now.
Describe the solution you'd like
Introduce a new feature invert-sdo
, and enable it will invert the signal on SDO, allowing external inverter. For example
#[cfg(not(feature = "invert-sdo"))]
let value = 0x00;
#[cfg(feature = "invert-sdo")]
let value = 0xFF;
Describe alternatives you've considered
Maybe there's a way to fix it on ESP32-C3's side.
Additional context
MOSFET model 1N60C, an additional 1kΩ resistor is used when inverting the SDO. SPI speed is 1MHz.
Edit: wrong resistor value
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.