Page 2 of 8

Re: HX711 - which lib should I use?

Posted: Sun Feb 14, 2021 7:16 pm
by Roberthh
machine.idle() just serves the purpose of avoiding a busy loop. time.sleep_ms(1) works as well.

Edit: I see machine.idle(). May you should use the daily build firmware. It progresses fast at the moment.

Re: HX711 - which lib should I use?

Posted: Sun Feb 14, 2021 7:47 pm
by hgrbirchall
Thanks the latest update appears to have fixed that issue, I have it working now for the scales.py file, with GPIO 16 as the data pin and GPIO as the clock pin. when I tried to run your hxtest.py example I am getting the following terminal message:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/lib/hx711_spi.py", line 9, in __init__
TypeError: extra keyword arguments given
This is the only change I have made so far:

Code: Select all

from hx711_spi import *
hx = HX711(16, 18, 19)

Re: HX711 - which lib should I use?

Posted: Sun Feb 14, 2021 8:22 pm
by Roberthh
The driver uses the SPI call logic of pycom. You have to change that line in hx711_spi.py to:

self.spi = SPI(0, mode=SPI.MASTER, baudrate=1000000, polarity=0,
phase=0, sck=Pin(spi_clk), mosi=Pin(pd_sck), miso=Pin(dout))

Please note that the SPI clock will NOT be connected. The HX711 will be clocked by the mosi pin.

Re: HX711 - which lib should I use?

Posted: Sun Feb 14, 2021 10:37 pm
by hgrbirchall
Thank you Robert. I think I have it working now. I am using GPIO 16 as the data (miso) pin and GPIO 19 as the skc (mosi) pin.

Now to turn it into meaningful results! The plan is to make a data logger which I can use with load cells for work.

Re: HX711 - which lib should I use?

Posted: Sat Feb 27, 2021 8:17 pm
by sciortino
I'm working with a high school robotics team that want's to use the hx711 with a pico to design some "smart" exercise equipment.

Would you be willing to share some samples of your code?

Jeff

Re: HX711 - which lib should I use?

Posted: Sat Feb 27, 2021 9:09 pm
by Roberthh
The repository contains samples of the code. At the moment, the SPI version is the best to use. But I can also make a PIO version, which makes use of the PIO state machine and should perform better. Just give me a day or two for set-up.

Re: HX711 - which lib should I use?

Posted: Sun Feb 28, 2021 10:57 am
by Roberthh
There is a variant now of the driver using the RP2040's PIO at https://github.com/robert-hh/hx711
Like the GPIO version it uses two pins only, but unlike GPIO, once started the timing cannot be affected by interrupts.

Re: HX711 - which lib should I use?

Posted: Sat Feb 12, 2022 8:07 pm
by Josmagal
Hi there Robert!
I’m using the https://github.com/robert-hh/hx711-lopy library to measure the weight from a load cell connected to a HX711 board with a ESP32 board(Huzzah32 from Adafruit).
I’m using de SPI version. The code does not return any kind of errors, but the value returned varies a lot even from negative to positive values.
Can you give any advice?
Thanks in advance

Re: HX711 - which lib should I use?

Posted: Sat Feb 12, 2022 8:17 pm
by Roberthh
What is the range of the variation?
Did you connect the load cell properly?

Re: HX711 - which lib should I use?

Posted: Sat Feb 26, 2022 8:51 pm
by Josmagal
Thanks for you reply.
Changed to the GPIO version and all is good.
Will try the spi version soon
Thanks again
BTW do you think it possible and accurate (+-2g) to display weight variations per second?