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