Giter Site home page Giter Site logo

hx711's Introduction

HX711 class for Rasperry Pi Zero, 2 and 3 written in Python 3.

I dropped support for Python 2 and changed the implementation in Python 3. Therefore, it is not backward compatible. The implementation in C is not completely finished but can be considered as beta version.

I decided to write my own python class simply because all what I found was not enough good for my purpose.

So what is the difference?

  • Raspberry Pi sometimes reads invalid data because the pin pd_sck is high for 60 micro seconds or longer. To eliminate this problem I implemented simple filter which solves this problem. Therefore it provides better and more precise readings.
  • It does not require additional libraries only Python 3.6 or higher.
  • If data is invalid (Max and Min values of HX711) it detects it.
  • It can quickly switch between channels and gains.
  • It raises exceptions if wrong input provided.
  • It has debug mode.
  • It has separate offset and scale ratio for each channel and gain.
  • It remembers last valid raw data for each channel and gain.
  • It detects if pin pd_sck is high for longer than 60 micro seconds and therefore evalueates reading as Faulty. (only for Python 3 class)(60 us is important. Read Datasheet for more info.)

I recommend to connect pin 15(RATE) of HX711 to VCC (+3.3V) in order to get 80 samples per second. By default it is only 10. If you have a cheap green breakout board as I have, you have to desolder and bend the pin 15(RATE) upwards. Then soldeer short wire to VCC.

Great explanation of strain gauges: https://www.allaboutcircuits.com/textbook/direct-current/chpt-9/strain-gauges/

Install

The python class HX711 is can be installed with the following command:

pip3 install 'git+https://github.com/gandalf15/HX711.git#egg=HX711&subdirectory=HX711_Python3'

Once installed instantiate a HX711 object with the following:

  import RPi.GPIO as GPIO                # import GPIO
  from hx711 import HX711                # import the class HX711
  
  GPIO.setmode(GPIO.BCM)                 # set GPIO pin mode to BCM numbering
  hx = HX711(dout_pin=5, pd_sck_pin=6)

hx711's People

Contributors

bytedisciple avatar gandalf15 avatar heme2 avatar james-e-morris avatar nakai-omer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hx711's Issues

how to fix "Tare unsuccessful" error

My hx711 is giving me this error. It was working. I haven't used it for a long time.

Binary value as received: 0b111111000000101000110100
Converted 2's complement value: -259532
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
Binary value as received: 0b111111111111111111111111
Converted 2's complement value: -1
From method "zero()".
get_raw_data_mean(readings) returned False.

Traceback (most recent call last):
  File "/home/pi/Downloads/0.1-OnionBot-API/utils/weigh_scale/scale_calibra.py", line 14, in <module>
    raise ValueError('Tare is unsuccessful.')
ValueError: Tare is unsuccessful.

I did tried to reinstalled it.

./.local/lib/python3.9/site-packages/hx711.py
./.local/lib/python3.9/site-packages/HX711-1.0.0.dist-info
./.local/lib/python3.9/site-packages/__pycache__/hx711.cpython-39.pyc

[QUESTIONS] Using more than one HX711 board simultaneously

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?

Getting Random values

Hey,
I want to messure the weight of a glass with water to know its waterlevel for a project at school.
As first step I tried to use example.py from HX711_Python3 to get the sensor running. Because there are other sensors connected at the same time, but not running at the same time, i changed GPIO Pins to 5 and 6. I opend the file in Python 3 using a Raspberry 3. I changed the GPIO Pins in the Code as I connected them. My problem is, that the Values printed out are more or less random. I've used a weight of 529g to calibrate the sensor. Still using this weight, the values vary between 480g and 520g, which is pretty ok, but if i take of the weight, the values vary between 250 and 400g which isn't that ok. It's pretty curious because It sometimes varys even more. At school we had everything working just fine. As we came back from the storeroom the values were between -30000000g and 2900000g. With an weight of exactly 1kg.We exchanged the sensor already, but it's still the same problem. Seems to be a problem with the code.
If you need more information just ask, i would be very thankful for help.
Greetings from Germany and sorry for my bad english 😄
IMG_20190601_010625 1

Picture shows output without weight after calibrating with 529g.

BUG HX711.select_channel - sleep time does not match comments

select_channel

# after changing channel or gain it has to wait 50 ms to allow adjustment.
# the data before is garbage and cannot be used.
self._read()
time.sleep(0.5)

I noticed that the comment says 50ms, but the time.sleep indicates 500ms.
I think that this is a likely an error that will significantly slow down the rate at which multiple channels are read.

The same conflict in documentation vs implementation appears in set_gain_A

[QUESTION] How to install without a setup.py file

Hi there,

Thanks very much for writing such a nice python 3 library for the HX711! I am very new to python 3, so I was wondering how I would actually install your library after it has been cloned. I am used to being able to run a command such as "sudo python setup.py install", but in this case there is no setup file.

So my question is, how do I actually install the library rather than just clone it.

Please let me know if you need clarification, sometimes when you're new to things (like I am) you're not good at asking good questions.

Cheers,

Cohen

HX711 in C not giving any data

Hi
Im trying to use the library on C
I already connected everything and run this line: sudo ./read_scale 22 23 10
The problem is this one:
Zero the scale... When ready press return key.

Zero scale is done!
Put a single item on the scale. When ready press return key.

Single_item_weight: 0.000000

Set up is done.

1 - Print number of items on the scale.
2 - Print raw mean value.
3 - Zero the scale.
4 - Set new item.
4
Put a single item on the scale. When ready press return key.

Single_item_weight: 0.000000

Set up is done.

1 - Print number of items on the scale.
2 - Print raw mean value.
3 - Zero the scale.
4 - Set new item.
1

Data mean: 0

Current number of items on the scale: 0
1 - Print number of items on the scale.
2 - Print raw mean value.
3 - Zero the scale.
4 - Set new item.
2

Raw data: 0
1 - Print number of items on the scale.
2 - Print raw mean value.
3 - Zero the scale.
4 - Set new item.
3
Zero the scale... When ready press return key.

Zero scale is done!
1 - Print number of items on the scale.
2 - Print raw mean value.
3 - Zero the scale.
4 - Set new item.
4
Put a single item on the scale. When ready press return key.

Single_item_weight: 0.000000

Set up is done.

As you can see, I got no weight at all, even when I stand on top of the scale.
Im using the BCM numbering and I got the WiringPi library.
Any idea of why I got no weight at all?
Thanks for your help

No module named statistics

sudo python example.py
Traceback (most recent call last):
File "example.py", line 3, in
from hx711 import HX711 # import the class HX711
File "/home/pi/git/HX711/HX711_Python3/hx711.py", line 6, in
import statistics as stat
ImportError: No module named statistics

fresh pi install

Write Wiki page for this project

If there is anybody interested to write a nice wiki page that explains how to use this library more in details. Including pictures.

Crashing after 10s

Dear Gandalf,

I have a problem that the example.py will crash after about 10 seconds. I think it is not reading enough samples and the datalist
runs out of numbers and cant calculate the median anymore.

I am using a Raspberry pi Zero. HX711 has been modified to 80SPS.
I am using GPIO 5 as Dout and GPIO 6 as SCK. I also have to write 5 and 6 in the example.py instead of 29 and 31 as per BCM numbering, which I find strange. Can you explain this also?
I really want to use your code since it has the most stable readings compared to others.

Can you help me out?

20201223_013248

Reading both channels in one script

Hey! :)
I'm working with HX711 module in my master degree in mechatronics and I've noticed that there is some 'bug' in your library.

When initialising an object HX711 like: hx = HX711(dout_pin=5, pd_sck_pin=6)
u got this at first :
def __init__(self, dout_pin, pd_sck_pin, gain_channel_A=128, select_channel='A'):
and than

self.select_channel(select_channel)

this method makes:

if (channel == 'A'):
self._wanted_channel = 'A'
elif (channel == 'B'):
self._wanted_channel = 'B'`

in result, when I create 4 objects like

hx = HX711(dout_pin=5, pd_sck_pin=6)
hxb= HX711(dout_pin=5, pd_sck_pin=6)
hxc= HX711(dout_pin=13, pd_sck_pin=19)
hxd= HX711(dout_pin=13, pd_sck_pin=19)
hxd.select_channel(channel='B')
hxb.select_channel(channel='B')

and two of them set to channel B , and try to read one after another in order
ch A, ch B, ch A, ch B the frequency of reading samples is like 3Hz despite i got my hx711 module set to 80Hz mode.

Why is that?
Because !
if (channel == 'A'): self._wanted_channel = 'A' elif (channel == 'B'): self._wanted_channel = 'B'
this library expects that the next reading channel will be the same as currently read.
And because of that, requirement of additional pulses after reading 24 bits are not satisified.
88059173_2596746330606984_7389469049261916160_n

I think that makes the module reset all the time, and wait to turn on and set again.

I think, that i case like that (reading channels in order ABAB) its enough to do fix like this:(line 383)
if self._wanted_channel == 'A' and self._gain_channel_A == 128:
if not self._set_channel_gain(2): # send only one bit which is 1
return False # return False because channel was not set properly
else:
self._current_channel = 'A' # else set current channel variable
self._gain_channel_A = 128 # and gain
elif self._wanted_channel == 'A' and self._gain_channel_A == 64:
if not self._set_channel_gain(3): # send three ones
return False # return False because channel was not set properly
else:
self._current_channel = 'A' # else set current channel variable
self._gain_channel_A = 64
else:
if not self._set_channel_gain(1): # send two ones
return False # return False because channel was not set properly
else:
self._current_channel = 'B' # else set current channel variable

I hope that it will be helpfull for somebody ;)

Reading linearly increases/decreases

Hi, recently I ran into a problem where after starting and input the calibration weight, the first output reading was the closest to the actual value but then gradually increases/decreases over time. I spotted a linear relationship between each reading but have no idea what was going on and how to fix this. Can anyone help?

Not getting past warning message

Hi there, and thanks for writing this library!

Just a little background about my setup: I have four load cells hooked up to a combinator which again is connected to an hx711 board from sparkfun, which in turn is connected to my Raspberry Pi 3 Model B+. I have connected VDD to 3.3V, VCC to 5V, the data and clock to each their own GPIO pin (5 and 6), as well as GND to GND. I have checked the GPIO with gpiotest (without anything connected to any pins) and monitored with piscope.

When I try to run the example, I only get a long stream of the following message, without any sensor readings:

...
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00007870
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00011641
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00010000
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00006052
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00008302
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00008745
...

I will attach three screenshots from piscope showing the following:

  • 20.47.10 - "normal" state, before starting the script:
    Screenshot 2020-05-21 at 20 47 10

  • 20.48.30 - starting the script, you can see activity starting on pin 6, on pin 5 seems to change as well (?). I'm not sure what's going on with 18 and 24 here, but they seem to be usually going off randomly even without the script going.
    Screenshot 2020-05-21 at 20 48 30

  • 20.49.21 - killing the script, you can see activity stopping on pin 6 (pin 5 doesn't change when the script is killed):
    Screenshot 2020-05-21 at 20 49 21

Would you be able to point me in the direction I should start troubleshooting this? I don't have a lot of experience with electronics, I'm more a software guy, so I'm a bit unsure where the trouble could be. The wiring seems to be correct, but I'm also not sure how to verify the wiring correctly. Any help at all would be greatly appreciated.

Example works fine but no output to terminal when I run "python3 hx711.py"

Marcel,

Much appreciate you sharing the code. I have a my HX711 hooked-up to Rpi3. I am using a Dietpi image.
I am not a python programmer, but understand the basics.

When I run the "sudo python3 example.py" all works as planned. Just needed to mod my dout & sck pins.

Alas when I run "sudo python3 hx711.py" from the Terminal (ssh into headless setup) I get no output.
I checked the code and do see a number of print statements but no output.

How to I setup my 'dout_pin' and 'pd_sck_pin' In the hx711.py script. I using pin 9 and 11.
Do I need to take the information that I gathered after running the example.py script and insert that into the hxx711.py script.

Thanks in advance for sharing your work. Much appreciated.

example.py problem (Attribute error)

Hi guys! I'm a beginner in python and raspberry pi, so first i'm sorry for the dumb question. haha

When i run the code, on line 12 appears an attribute error (has no attribute for [err = hx.zero()] ). What might have happened when I installed the HX711 class?

I installed the library normally and the cables are connected correctly. The python version is: 3.7.3.

Please help this poor programming beginner.

SyntaxError: unexpected EOF while parsing

I try HX711_Python2.7 and got:
not ready
invalid data
invalid data
Put known weight on the scale and then press Enter
Traceback (most recent call last):
File "./example.py", line 51, in
input('Put known weight on the scale and then press Enter')
File "", line 0

^

SyntaxError: unexpected EOF while parsing

Example program not working

So I tried to run the example.py program (Python3 version) and I got this for an output:
not ready
invalid data
invalid data
Put known weight on the scale and then press Enter
Traceback (most recent call last):
File "example.py", line 73, in
raise ValueError('Cannot calculate mean value. Try debug mode.")
ValueError: Cannot calculate mean value. Try debug mode.

So I slapped "hx.set_debug_mode(flag=True)" on line 12
Debug mode gave me:
Debugmode ENABLED
Binary value as it has come: 0b0

Converted 2's complement value: 0

Binary value as it has come: 0b0

Converted 2's complement value: 0

Not enough fast while reading data
Time elapsed: 0.00012099...

not ready
Not enough fast while reading data
Time elapsed: 6.099...e-05
Binary value as it has come: 0b0
...
invalid data
<another binary/convered 2's stuff being 0b0/0>

<more "Not enough fast"x3>
<keeps jumping back and forth between Binary/Converted 2's being 0b0/0 and Not enough fast with really small values>

invalid data

Put known weight on the scale and then press Enter
<more familiar stuff, no changes>
Traceback...

Edit: picture of my wiring if that helps any...
photo on 12-3-18 at 1 16 pm 2

example_save_state problem :(

Hi, when i use the example.py file everything works just fine, but i don't want to calibrate each time i turn on raspberry or simply each time i use the scale, i just want to calibrate once and for all, i tried using the example_save_state.py file but i get only errors
Please help
IMG_20200923_145543

How to get 80sps

Hi,
i soldered the rate pin to 3.3v but the rate i can get values in a loop stays the same. How do i get up to 80sps? (I am using a rpi zero)

Thank you

New idea to detect missing weight

Hello everyone,
I have this little project using the Raspberry scale, it consists of weighing a product (a bag of flour for example), if the original bag weighed 1kg and i decide to take 200g from it and put it back on the scale, and get a message that 200g are missing from the product weighed.
I would like to ask if someone could help me implement this solution or give me an idea on how should i proceed? does this have to be part of the files in the python3 folder or does this has to be done in a different file or even in a different language?
i wanted also to include a simple lcd screen to display the weigh at all times (should be connected to raspberry pi of course).
Any help is welcome thank you so much.

Returning false readings

hoping you can help me out.
I'm trying to run this code:

import RPi.GPIO as GPIO
from hx711 import HX711
from time import sleep

GPIO.setmode(GPIO.BCM)
hx = HX711(dout_pin=6, pd_sck_pin=5)

while True:
    reading = hx.get_raw_data_mean()
    print(reading)
    sleep(3)

It only returns the readings
"False"

after that and its ran again it still returns False but has this warning as well.

home/dpi/.local/lib/python3.9/site-packages/hx711.py:60:
RuntimeWarning: This channel is already in use, continuing anyway.
Use GPIO.setwarnings(False) to disable warnings.
  GPIO.setup(self._pd_sck, GPIO.OUT)  # pin _pd_sck is output only

False

Raspberry Pi 3B
VCC - 5V
GRD (20)
DOUT - GPIO6 (6)
SCK - GPIO5 (18)
(none of the other things in the box are hoked up. that's part of a different project)

any advice?
IMG_6142
IMG_6143
IMG_6146
IMG_6147

How to install?

Hi Gandalf15,

I'm relatively new to Python and RPi so this question is not really an issue but more of a questions. On your readme page there is nothing on how to install your HX711 on a RPi. Could you update it with some simple instructions on how to install? And can we install using PIP? I am using Docker Template on a Balena platform so the ultimate would be to get install instructions that could work in a docker build.

Thanks so much,

Greg

When more weight, the value goes down

When I put more weight on the scale, the value goes down in the negatives. Maybe the offset is not well calibrated, but the value should go up when I put more weight.
Does someone know why ?

Readme has installation instruction of a fork

Hello,

As part of the last PR merged, installation instructions points to the fork's url instead of this repo's url.
AKA, it points to: https://github.com/bytedisciple/HX711#egg=HX711&subdirectory=HX711_Python3

add a HX711

Hi,
I would like to know if it is possible to modify the code to add a second HX711?
thank you in advance

Python2.7 example has Python 3 hashbang

Hello. I'm starting to use your library, and the first thing I ran into was that the Python 2.7 example has the Python 3 hashbang at the start:
#!/usr/bin/env python3

Yes, I should just convert myself to Python 3, especially for a new project... :-) I thought it was worth mentioning, though.

AttributeError: 'HX711' object has no attribute 'zero'

Hi community,

My goal is to get through the code step by step. So I want to see what each line does when running, to get better understanding.
From the example.py code there was a command hx.zero().
Tried to run it but could not succeed. Just got the error AttributeError: 'HX711' object has no attribute 'zero'
I know there is an open issue with the same problem, but still no solution so I considered to try again.

The pins are correctly connected to the raspberry 3 and the library also got installed like described. The problem also occurs to other commands like hx.get_raw_data_mean() and hx.get_data_mean()
Seems like the installation failed somewhere...

Appreciate any help!

How to Declare Pins in Raspberry Pi

How to declare the I2C pins for the HX711 in the Raspberry Pi 3 B+? I'm very new to programming raspberry pi and arduino and I want to know where and how can I set pin # 29 and # 31 as data and clock pins and set the read samples.

Thank you for your help.

Help me please

results.txt
I am trying to create a weight scale using hx711 along a raspberry pi. I can confirm that both HX711 and the load censor are fully functional. Yet all I am getting are either false or random values. The results range from

Ready to use
invalid data
invalid data

to

Ready to use
invalid data
Data subtracted by offset but still not converted to any unit: -0.19999999999999998
Put known weight on the scale and then press Enter
Traceback (most recent call last):
File "example.py", line 77, in
raise ValueError('Cannot calculate mean value. Try debug mode.')
ValueError: Cannot calculate mean value. Try debug mode.

As well as the contents of the attached txt.

Any idea what i might be doing wrong? I'm also attaching pictures of my setup. I have experimented with various pin places but nothing changed

Thank you.

pi1
pi2

"module '8' has no attribute 'select_channel'"

So I'm trying to make a quick code that just prints out what the chip is reading and it's giving me weird errors. My current code (relevant parts anyway) are as follows:
import hx711 as HX

HX.init('8', '10')
sleep(1)
print('test')
HX.select_channel('A')
print(HX.zero())
while(true):
if(HX._ready()):
print(HX._read())

and it's currently giving me:
"test
Traceback...
...
HX.select_channel('A')
AttributeError: module '8' has no attribute 'select_channel'
"

And I have no idea why it's not using HX but instead this mysterious '8' (I'm guessing it's getting 8 from the init(8,10) bit)

Any idea if it's my code or not?

Edit: Using the Python3 version, a zeroW with Python3 on it

Edit 2: Should really have looked at the example before trying to get it to work myself.

Got it working

Tare is unsuccessful ERROR

Hi, I Have problem with running example.py as it is giving me thiss error:

/home/klaudia/.local/lib/python3.9/site-packages/hx711.py:60: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(self._pd_sck, GPIO.OUT) # pin _pd_sck is output only
True
Traceback (most recent call last):
File "/home/klaudia/Desktop/kb/HX711/python_examples/example.py", line 16, in
raise ValueError('Tare is unsuccessful.')
ValueError: Tare is unsuccessful.

Does anyone have an idea why this is happening ?

Write Python 3 wrapper around the C code

Implementation in Python is too slow. Especially for Raspberry Pi Zero. Therefore, it would be good idea to use the C code and write only a wrapper in python code. It needs to have the same methods as Python implementation. It should be interchangeable with the pure python implementation.

HX711 Jetson nano

hello
I am a novice in the issue of Jetson nano (!)
i tried to work with the HX711 lib by KEMPEI but it does not work straight from the file.
i encounter many issues like missing libs, the import does not work and so on. the code tries to import GPIO lib while the readme say to use LIBGPIOD and so on, pther many issues that reject the program.
does anybody have worked with HX711 on Jetson nano and is willing to help me out.
thank you

Problem with initialization of HC711 in C

Hello, I have been tried to deal with this HX711, but I have no success. I am new in Raspberry and I want to know how to do that, How to use the "initHX711" (I have been created variables for clock_pin and data_pin, because I have been used a function that gets some parameters in)
I tried to use "read_sacel.c", but it has so much errors of compilation. I tried to run the debug, but no success again, because hasn't compiled and built. I tried to create the "hx" struct, but again no success. I don't know what is wrong with my code, I don't know which is the syntax error. All older issues are starting from who inits with success, what isn't my case. I already downloaded all libraries as needed and all libraries are included in code. Hx711.h, hx711.c and read_scale.c are opened in another pages for verification of syntax.

This is the function that can't compile:

void init_weight(char gpio_clock, char gpio_data)
{
HX711 hx;

int err = initHX711(&hx, gpio_clock, gpio_data);
if (err)
{
	printf("\n!!! Failed to init HX711 struct !!!\n");
}

}

My Raspberry version: Raspberry 4B
Linux Version: Raspbian GNU/Linux 10 (buster)

last known weight lost on power reset

I use HX711 Python library which at every hour write down in sqlite3 weight and time.
INSERT INTO loadcellSample (weight, comment, sampleDateTime)
The problem is when there is a power reset and weight is still present on the scale the output goes back to 0.I have to remove the weight from the load cell,power reset and place the weight back on the scale.Problem is that my weight is 100Kgs and it is not practical to remove weight.
So i'm looking for a solution when there is a constant load on the cell and after power failure to restore last known weight?

Error

after running the Example.py, I received below message:
Traceback (most recent call last):
File "/home/pi/Desktop/HX711/HX711_Python3/example.py", line 12, in
err = hx.zero()
File "/home/pi/Desktop/HX711/HX711_Python3/hx711.py", line 125, in zero
result = self.get_raw_data_mean(readings)
File "/home/pi/Desktop/HX711/HX711_Python3/hx711.py", line 446, in get_raw_data_mean
filtered_data = self._data_filter(data_list)
File "/home/pi/Desktop/HX711/HX711_Python3/hx711.py", line 680, in outliers_filter
data_median = stat.median(data)
File "/usr/lib/python3.5/statistics.py", line 353, in median
raise StatisticsError("no median for empty data")
statistics.StatisticsError: no median for empty data

(small) issue with _read internal method

Hi gandalf15, thanks much for your code. It's very neat and well documented. Very convenient to dig into. I have detected a small issue in _read() code of your HX711 class. You test 40 times is the chip is ready but if it if not, the error message is not displayed and the code continues because you test if the ready counter is equal to 50 (instead of 40).
Again, thanks much for the good work !

Do I need to calibrate each time ?

This is more a question than an issue.
Do I need to calibrate each time I'm using it ? I would like to use my program on a cron tab to get a weight and send it to my database. But I can't calibrate with a known weight each time (the purpose would be to use it at night for example).

Thank you !

Will it work on NVIDIA Jetson Nano?

Hey @gandalf15, I have implemented your library on Raspberry Pi 4 and it works really good. But i have a doubt of it working on a NVIDIA Jetson Nano as i have tried it recently and it only shows the error of no median for empty data.

Is there any method to make it work on this board?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.