HX711 only can be read from SDA/SCL on Mega2560

Hello, I have a problem with my Sparkfun HX711.
I can't read the correct data from it unless it's connected to a I2C Port (SDA, SCL, on my Mega 2560 Port 20/21). The documentation says:

"The example code has DAT and CLK hooked up to pin 3 and 2 respectively, but this is easily changed in the code. Any GPIO pin will work for either."

For me, this isn't true. The problem is, my I2C Ports are already in use. Normally I would be able to use multiple I2C devices connected in row, but the HX711 has no I2C address, because it's no I2C device.

What can I do, where is my failure? Here's my current code, which only works with SDA/SCL:

#include "HX711.h"
#define DOUT  20 //SDA
#define CLK  21 //SCL

HX711 scale;
float calibration_factor = 2130; 

void setup() {
 Serial.begin(9600);
 Serial.println("Remove all weight from scale");

 scale.begin(DOUT, CLK);
 scale.set_scale();
 scale.tare(); //Reset the scale to 0

 long zero_factor = scale.read_average(); //Get a baseline reading
 Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
 Serial.println(zero_factor);
}

void loop() {

 scale.set_scale(calibration_factor); //Adjust to this calibration factor

 Serial.print("Reading: ");
 Serial.print(scale.get_units(), 1);
 Serial.print(" g"); 
 delay(500);

}

Also, here's the working circuit to the code:

Is this your Fritzy picture?
A Sparkfun HX711 board has two power pins (VCC, VDD). You only have connected one.

You should not be using I2C pins for a HX711. Post a real picture of the setup with the board connected to different pins, and the sketch used for that.
Leo..

You were right! I just missed connecting Vdd to 5V.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.