gandalf15/HX711

[QUESTIONS] Using more than one HX711 board simultaneously

rafaellehmkuhl opened this issue · 7 comments

Hi! I have a project that uses 5 HX711 boards (each one reading one load cell) running simultaneously. I'm currently using an Arduino (with this library) to read from the boards, and them I send the data through serial to a RaspberryPy running python code, but I would rather do all the aquisition and processing on the RaspberryPi, without an Arduino in the middle.

Have you tested your library with more than one HX711 board simultaneously?

HeMe2 commented

I have no experience with the usage of more than one hx711. Since the used pins are set in the constructor of the HX711 object, it should work fine with more than one device. Given that you use different pins for each.

Hi, I am using only two hx711 connected to a single Raspberry Pi2. There is no problem. You just have to read them consecutively. That means using a single process that is trying access GPIOs. However you mentioned RaspberryPi and no specific version. Currently, I am working with Pi Zero W where I am having troubles to read correct output. So, I would recommend using Pi2 or Pi3 for now. Soon, I'll create a new dev branch with the latest updates.

Nice, that was why I asked. The HX711 chip needs a good timed aquisition, so I thought that was the problem why it is easy to make many work on an Arduino but not on a Raspberry. Timing is the issue (more specifically the way they shutdown if you let the SCK pin high for too much time).

Do you know why are you having trouble with the Zero W? Maybe it is not aquisiting fast enough? My goal was to eventually change my project from a RaspberryPi3 + Arduino + HX711s to a RaspberryPi Zero W + RPiZW shield.

I just guess that it is because Pi Zero has single core while Pi2 is quad-core. So, I think that sometimes my process is preempted while reading... You know the rest of the story.
I am working on resolving this issue. The solution may be increase niceness of the process with nice. However, I did not test it yet. I'll let you know my progress within a few days (2 - 5). Meanwhile, look at this repo: https://github.com/ggurov/hx711
He is using C. I can say that this works on Pi Zero perfectly.
Note: In his code you will see 4 x increment useless variable as b++. Do not touch it it is important for right timing.

Hey @gandalf15, did you resolve the reading issue with a RPi Zero ? I'm using one right now and I found out that my readings were less precise than the other Pi.

Hi,
previously he reading on RPi zero did not work (too many false readings). Right now it works, but as you noticed it is not as precise as it should be. The reason is that it is still getting too many false reading, but I implemented a new filter:

def outliers_filter(data_list):

that is doing a very good job. Hence, it is usable but not as good as I would like to.
The ultimate goal is to write a Python wrapper for the C code I have. Unfortunately, I did not have time to do it (more important was the filter because it affects also python3 implementation.). If you know C I would recommend using: https://github.com/gandalf15/HX711/tree/master/HX711_C
Look here how it can be used: https://github.com/gandalf15/HX711/blob/master/HX711_C/read_scale.c
to compile just run command $ make
to use it just run ./read_scale
If you don't know C (you should learn it 😄 ) than you have to wait.
However, I am not expecting to do anything until Jun 2019 because I am doing my final year at Uni + 2 part-time jobs...
If you feel like it, you can try to implement the python 3 wrapper and then just create pull request.
Thank you.

Ahah I know C but unfortunately I don't have time to implement it in C.
I will look into it in my free time after this project! Thank you!