Reading both channels in one script
See original GitHub issueHey! 😃 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.

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 😉
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
I am going to give up on this chip. because I am trying to detect high-frequency objects. thank you for your reply.
Your red chip doesn’t have a label on it, but based on the circuit board it looks like the orientation of the HX711 is the same as in the picture supplied with this repository. That picture is here. You’ll note that an obvious matching pin is the DAT pin is connected to the 4th from the bottom right in both pictures.
Please let me know how it goes with the 80Hz, I’m curious what the actual rate ends up being when accounting for some bad returns. I don’t run this repository, but I made my own HX711 repository over here with an emphasis on sampling multiple HX711 sensors in parallel.