tatobari / hx711py

HX711 Python Library for Raspberry Pi.
Apache License 2.0
215 stars 153 forks source link

Multiple instances gives AttributeError #22

Open penbob3 opened 5 years ago

penbob3 commented 5 years ago

I want to read the values from 3 separate load cells, each with its own HX711. I need the weight value to stay the same from each reading, or basically, I need to read the values from each load cell without tareing them. Is there a way to do this without having multiple HX711 instances?

(Example code only shows two instances)

from hx711 import HX711
hx1 = HX711(5, 6)
hx1.set_reading_format("MSB","MSB")
hx1.set_reference_unit(687)
hx1.tare()
hx1.power_down()
hx2 = HX711(7, 8)
hx2.set_reading_format("MSB","MSB")
hx2.set_reference_unit(687)
hx2.tare()
hx2.power_down()

if selectedlc == 1:
    hx1.power_up()
    intWeight = hx1.get_weight(5)
    hx1.power_down()
if selectedlc == 2:
    hx2.power_up()
    intWeight = hx2.get_weight(5)
    hx2.power_down()
tatobari commented 5 years ago

Could you please post the error you're getting? Thanks!

MrBudo commented 4 years ago

Annotation 2020-06-16 163430

I am getting this attribute error. Also I am getting super random values when I uncomment the 3 line it throws the error

NeonSpork commented 4 years ago

Those lines are commented out in the example, and when I look at the current hx711.py file I can't find those functions defined anywhere. Maybe that's a hold over from a older version? @tatobari maybe you remember? Comment those out or delete them and the AttributeError will go away at least.

MrBudo commented 4 years ago

Annotation 2020-06-16 172015

I am getting super random values. I have tried changing LSB and MSB. changed it to 3.3 V still no luck. I really trying hard to find a solution. Can you suggest me something that I can try.

I am using this sensor with hx711

MrBudo commented 4 years ago

https://www.ebay.com.au/itm/1x-Miniature-Load-Cell-Weighing-Sensor-Pull-Rod-Pressure-Tension-Sensor-0-100kg/293280015699?hash=item4448d9e553:m:m5ou6L29ZJbBRaHQp9x_SEw

NeonSpork commented 4 years ago

Wait hang on, is this a separate issue than the one in the first post?

Regarding the randomness of the readings maybe try setting a lower gain and recalibrating.

tatobari commented 8 months ago

@penbob3 Are you still interested on using this library and solving this issue?