0

I have successfully read a load sensor with an HX711 on the Pi with an online hX711 python library (similar to this). However, I am attempting to do the same on an 32 I/O Expander (specifically a Raspberry Pi HAT - 32 I/O Port Expander - MCP23017 - I2C) and I am not receiving data properly.

I have noticed the HX711 code reads by bit banging 24 bits through the GPIO pins. I have attempted to get it to work with the expander by connecting the clock and data read wires to the expander and adapting the python code: using a new library(using specifically the IO class) and replacing all GPIO commands with I2C commands. For Example,

I would replace "GPIO.output(self.PD_SCK, True)" with "self.iobus.write_pin(self.WRITE_PIN, 1)"

I was hoping I could bit bang the same way on the expander, but I don't get the same data. I seem to be getting 1111111111111111111111 instead of meaningful data. If I were to guess it seems that the timing through the expander (which i think uses i2c communication) is different than what the HX711 expects.

What I tried to fix the problem:

  • using a GPIO clock and read data from the expander, but I seem to be getting jumbled data that is only accurate 25% of the time with a lot of random numbers.
  • adding delays in the clock high and lows in an attempt to match the timing, but it doesn't seem to change anything.

Any help or suggestions would be greatly appreciated!

EDIT: spelling errors

bumped to the homepage by Community 2 days ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

The HX711 will reset if the clock line is asserted for more than 60µs (according to the datasheet).

You can't ensure a toggle within 60µs with Python talking directly to the GPIO (unless you use my pigpio or similar).

The chances of reliably keeping the toggle to less than 60µs over an I2C bus are much lower.

I would try increasing the I2C bus rate (see /boot/overlays/README for details).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.