When more weight, the value goes down
Closed this issue · 9 comments
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 ?
Simple solution. Just turn the load cell by 180 degree in vertical axis. Sometimes the manufacturer puts the sticker other way around. This should help.
I'll do that if there is no software solution but the load cell is already fixed so it is not so easy to turn it around. Do you know a software solution ? Otherwise I'll do just that.
Thank you !
Sure, we can solve it in software. I'll look at it tomorrow.
Meanwhile, can you provide more info? Which function you want to use? is it get_weight_mean
? Do you "zero" (tare) the scale with hx.zero
method? I think that if you set the variable hx._scale_ratio_A_128 = - ratio
to negative ratio this should just work fine. Then do not use hx.set_scale_ratio(scale_ratio=ratio)
method to set the ratio. There is check if the ratio is negative it raises ValueError. You have to access the variable as described above. As I said I'll look at it tomorrow. Let me know if this worked.
I'll provide more info this afternoon!
I'll try your solution and tell you if it works
I think it is a problem of ratio
and offset
. I'm not sure to understand how to set them.
If you are using channel A and gain 128 try this and copy the output. If not working try debug mode.
Also, do not forget to change your dout_pin
and pd_sck_pin
to your pin numbers.
hx = HX711(dout_pin=21, pd_sck_pin=20)
result = hx.reset()
result = hx.zero(readings=20)
input('Put known weight on the scale and then press Enter')
data = hx.get_data_mean(readings=20)
if data != False:
known_weight_grams = input(
'Write how many grams it was and press Enter: ')
value = float(known_weight_grams)
print(str(value) + ' grams')
ratio = data / value # calculate the ratio for channel A and gain 128
print('data:', data)
print('known weight is:', value)
print('Ratio should be for you a negative number. It is:', ratio)
hx._scale_ratio_A_128 = ratio # in this case ratio should be negative number
else:
raise ValueError('Cannot calculate mean value. Try debug mode.')
while (True):
current_weight = hx.get_weight_mean(10)
print('Current weight on the scale is:', current_weight)
You can try to pull the latest changes from master branch. the example.py should work.
Sorry I didn't have much time to respond before.
Thank for the info. I did what you told me too and it worked like a charm. I then pulled your latest changes that did the exact same thing so it is great now. I'll be using your library a lot in the next few weeks so I'll come back if needed.
Thank you again, great work.