-
Notifications
You must be signed in to change notification settings - Fork 82
example.py problem (Attribute error) #43
Comments
Is the error saying that "hx" has no attribute? Is it saying there is something within the zero() function that doesn't have an attribute? The author of this repo is a bit inactive from what I can tell. If you want to give my sister repo with similar functionality and some improvements, you can check it out at: https://github.com/Morrious/hx711-multi |
The error says this: "AttributeError: 'HX711' has no attribute 'zero' I'm just trying to get raw data of the strain gauge's electrical resistance variation. |
I can't suggest which wheatstone bridge to use, I have been working with scales from China that already had the HX711 wired up. Your HX711 install must be bad, but it's strange that you're getting to the .zero() line instead of failing at the hx = HX711 line. This to me indicates you have a conflicting HX711 being imported? Here's an example indicating your error and if the class didn't exist: class TestClass:
def print_test(self):
print('test')
testclass = TestClass()
testclass.print_test()
testclass.print_test_bad() # this fails with "'TestClass' object has no attribute 'print_test_bad'"
testclassbad = TestClassDoesntExist() # this fails with "name 'TestClassDoesntExist' is not defined"
testclassbad.print_test() I'm not sure how else to help you debug. This is why I prefer a pip install as there's no question what you're importing. As mentioned above, you can try out my hx711-multi code which has all of the same functionality as this repo, and can be installed with |
You know what, you might not be importing the right thing. This repo doesn't have a pip install, so you have to clone the code locally and import it there. I bet you ran |
I actually used 'pip3 install HX711'. I didn't know it wasn't the right way. Tomorrow I will install your HX711_multi by pip and try to run. |
In the example I include in my readme, you can see the below line which includes raw values for your sensors after some averaging if you input a value greater than 1. I found that my sensors often fail to return data every time, and often return bad data. These samples are filtered based on their bit values and their deviation from median to get much cleaner data. The "raw" values are after this filtering and averaging. raw_vals = hx711.read_raw(readings_to_average=10) If you want the really really raw data, you can access that within the load_cell data after performing the read above: for lc in hx711._load_cells:
print(lc.raw_reads) # these are the 2's complemented values read bitwise from the hx711
print(lc.reads) # these are the raw values after being converted to signed integers |
Hi, Morris! Now, when i try to run the code with HX711_multi, the raspbi returns the error message: "ModuleNotFoundError: No module named 'hx711_multi'." I installed the library via pip3 install hx711_multi and i have a raspberry pi zero W. |
hmmm, I haven't worked with a Pi Zero, but it should work. What do you get when you run Please open an Issue on the hx711-multi repo so we aren't clogging up this issue over here. |
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.
The text was updated successfully, but these errors were encountered: