Reading form several Load cells|(HX711) using I/O expander(SX1509)


I’m trying to read from several load cells using the Sprakfun HX711 board:

Because my arduino dosent have enoghf IO pins i disded to use Sparkfun’s IO expander board SX1509:

As i mentioned, my purpose is to read from several Load cells.

This is my hookup for 1 HX711 amplifier, SX1509 and arduino.
The connection is very simple:

SDA -----------SDA
GND---------- GND---------- GND
3.3V-----------3v3----------- VDD
----------------- 0------------- CLK
----------------- 1------------- DAT

For Start, from the HX711.cpp original library i took the read function, and placed it into arduino code, to see if this is the only function that i need to read RAW data from the HX711.
and it was all right and good.
After finding the calibration factor and the offset i could translate the RAW data to real force/weight.

Then i adjusted it a little bit and added my function to the SX1509.cpp original literary:
(of curse i declared on this function in the header file - SX1509.h):

long SX1509::read_my(byte DOUT, byte PD_SCK)

long SX1509::read_my(byte DOUT, byte PD_SCK) {
 // byte DOUT = 1;
 // byte PD_SCK = 0;
 byte GAIN = 1;

 unsigned long value = 0;
 uint8_t data[3] = { 0 };
 uint8_t filler = 0x00;

 // pulse the clock pin 24 times to read the data
 data[2] = shiftIn(DOUT, PD_SCK, MSBFIRST);
 data[1] = shiftIn(DOUT, PD_SCK, MSBFIRST);
 data[0] = shiftIn(DOUT, PD_SCK, MSBFIRST);

 // set the channel and the gain factor for the next reading using the clock pin
 for (unsigned int i = 0; i < GAIN; i++) {
 digitalWrite(PD_SCK, HIGH);
 digitalWrite(PD_SCK, LOW);

 // Replicate the most significant bit to pad out a 32-bit signed integer
 if (data[2] & 0x80) {
 filler = 0xFF;
 } else {
 filler = 0x00;

 // Construct a 32-bit signed integer
 value = ( static_cast<unsigned long>(filler) << 24
 | static_cast<unsigned long>(data[2]) << 16
 | static_cast<unsigned long>(data[1]) << 8
 | static_cast<unsigned long>(data[0]) );

 return static_cast<long>(value);

Then i tried to use it like that:

#include <Wire.h> // Include the I2C library (required)
#include <SparkFunSX1509.h> // Include SX1509 library
#define SX1509_Data 1
#define SX1509_CSK 0

const byte SX1509_ADDRESS = 0x3E;  // SX1509 I2C address
SX1509 io; // Create an SX1509 object to be used throughout

void setup(){
  if (!io.begin(SX1509_ADDRESS))
    Serial.println("Failed to communicate.");
    Serial.println("SX1509 Alive");
  io.pinMode(SX1509_Data, INPUT);
  io.pinMode(SX1509_CSK,  OUTPUT);

void loop() {
  Serial.print("Reading: ");
  long t1 = io.read_my(SX1509_Data, SX1509_CSK);

Unfortunately the result that i’m getting is very different form the first attempt. And the values are jumping from 1 value to another, and it seems to be constant no matter what force i apply on the load cell.

I would appreciate if you could help me with that

Moderator: Link Tags added

maybe the problem is with the SX1509 board, the way it reads the digital values ?