add a HX711
Closed this issue · 1 comments
maelisen commented
Hi,
I would like to know if it is possible to modify the code to add a second HX711?
thank you in advance
gandalf15 commented
Hi maelisen,
of course it is. you just have to create a second (third, fourth,...) variable where you are going to store it.
For example:
#!/usr/bin/env python3
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
my_hx_1 = HX711(dout_pin=21, pd_sck_pin=20) # create a first hx
my_hx_2 = HX711(dout_pin=23, pd_sck_pin=24) # create a second hx
my_hx_3 = HX711(dout_pin=25, pd_sck_pin=26) # create a third hx
print(my_hx_1.get_raw_data_mean()) # get raw data reading from hx711 number 1
print(my_hx_2.get_raw_data_mean()) # get raw data reading from hx711 number 2
print(my_hx_3.get_raw_data_mean()) # get raw data reading from hx711 number 3
GPIO.cleanup()
Just change the pin numbers in the code for appropriate based on your wiring.
Any issues pls let me know.