Author Topic: R Pi pico interfacing with a HX711 load cell module  (Read 4291 times)

0 Members and 1 Guest are viewing this topic.

Offline Alex_BakerTopic starter

  • Frequent Contributor
  • **
  • Posts: 264
  • Country: us
R Pi pico interfacing with a HX711 load cell module
« on: November 18, 2022, 06:30:40 pm »
Hello Everybody.

I am working on a project that involves reading a load cell with a HX711 module, like the ones you can get on the jungle website for $6. I am using a raspberry pi pico to read the sensor, I have a schematic in the attachments, you can ignore everything except the Pi and the HX711.

My issue is with the programming, which is python in the thonny ide. I have done some playing around with the other modules in the schematic, But I am stuck on this one.
I been looking at this github: https://github.com/robert-hh/hx711  and played around with the code some but I just don't know how it works. In some of the examples, it is trying to import a python module called Hx711_pio, where is that module? I don't really know how modules work.

Any input would be appreciated!
 

Offline hubi

  • Regular Contributor
  • *
  • Posts: 57
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #1 on: November 18, 2022, 11:33:17 pm »
I have not used the python code you linked, but I have used the library at https://github.com/endail/hx711 and it works very well. It is PIO based and works very reliably at both the slow and fast speeds (11Hz and 80Hz, IIRC).
 

Offline Alex_BakerTopic starter

  • Frequent Contributor
  • **
  • Posts: 264
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #2 on: November 19, 2022, 07:15:02 pm »
Thank you so much, I will look into it!
 

Offline Alex_BakerTopic starter

  • Frequent Contributor
  • **
  • Posts: 264
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #3 on: November 19, 2022, 07:18:38 pm »
Oh, its a C++ library, I need to be able to run code for the HX711 along with python code for a couple of other modules, including a SD card module. I am not sure this would work.

Eventually I want to write data from the HX711 to the SD card.
 

Offline hubi

  • Regular Contributor
  • *
  • Posts: 57
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #4 on: November 20, 2022, 07:25:23 am »
Oops, I sent the wrong link earlier. This is the library I meant to link https://github.com/endail/hx711-pico-c

It is a C library for the RP2040, the previous link was a C++ library for the Raspberry Pi by the same author. It's not python, but the PIO code might be useful, it is well documented and works very reliably.
 

Offline Alex_BakerTopic starter

  • Frequent Contributor
  • **
  • Posts: 264
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #5 on: November 20, 2022, 08:10:47 pm »
Well now I have something that is working in python, the only problem is that it is returning the data in the form 0x-------, for example 0x23df, or 0xfb4511, which I think is hexadecimal? I need some way to get that into grams or kilograms.
 

Offline hubi

  • Regular Contributor
  • *
  • Posts: 57
  • Country: us
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #6 on: November 20, 2022, 09:41:20 pm »
That might just be the way you are printing it out? Can you post a link to the code?

You may have to convert the HX711 data using two's complement if the highest bit is 1, depending on whether the library you use does that for you or not.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
Re: R Pi pico interfacing with a HX711 load cell module
« Reply #7 on: November 22, 2022, 02:21:57 am »
The chip uses a bit unusual data protocol, but it's pretty simple. You send clock pulses to it, and it shifts out data. And apparently you've already figured that out. The main anomalies are that the amount of clock pulses you send determine what the chip does for it's next conversion, and you have to let it sleep a bit to make it predictable of when it does a conversion.

There is no way for the chip itself to convert it to a weight or force, because there is a wide range of load cells you can hook up to a chip like this. So the only solution is to calibrate it yourself and apply some math. The minimum would be to add / subtract a value to get to "zero", and then add some multiplication factor  so your measured value is converted to the value of your calibration weight. You can also measure some extra weights, and then use them to check linearity.
« Last Edit: November 22, 2022, 02:51:01 am by Doctorandus_P »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf