HX711 ADC sending zero values

Hi all,

I am using a sparkfun hx711 ADC to take readings from a loadcell.
Please see link for more details:
https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide

I am attempting to use the code which was given in the example:

#include "HX711.h"

// HX711.DOUT  - pin #A1   (I am using 19)
// HX711.PD_SCK - pin #A0    (I am using 18)

HX711 scale(19, 18);    // parameter "gain" is ommited; the default value 128 is used by the library

void setup() {
  Serial.begin(38400);
  Serial.println("HX711 Demo");

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());     // print a raw reading from the ADC
  Serial.print("time 0");
Serial.println(millis());
  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(10));   // print the average of 20 readings from the ADC
  Serial.print("time 1");
Serial.println(millis());
  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);  // print the average of 5 readings from the ADC minus tare weight (not set) divided 
            // by the SCALE parameter (not set yet)  

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();               // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight, set with tare()

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided 
            // by the SCALE parameter set with set_scale

  Serial.println("Readings:");
}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);

  scale.power_down();             // put the ADC in sleep mode
  delay(5000);
  scale.power_up();
}

The first time I uploaded this code the whole lot ran perfectly, but when I uploaded it again, all the readings went to “0”. ( as if no data was being sent at all).
The strange thing is:
If I change DOUT and PD_SCK to something else (other than 18, 19), upload this code, then change them back to 18 and 19, the code will work for 1 upload.
Attached is a picture of my “0” output.

This has my head wrecked. Any ideas?

Thanks in advance,

Micheal.

hx711_01.PNG

Frankly, I can not understand putting the scales to sleep and waking them up when you can not get good data from them. Leave that crap for when you ARE getting good data.

Pointing to some set up guide without proving any proof that you followed the steps exactly is a waste of effort.

The example code uses pins 2 and 3. I would use those same pins, too, until I know that the circuit was working correctly.

Hi,
I have done as recommended.

Please see my code below:

#include "HX711.h"

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

float calibration_factor = -3450; //-3450 worked for my 93kg max scale setup
const int YBUT = 6;
int count = 0;

void setup() {
  Serial.begin(9600);
  delay(10);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");
  delay(10);
  

  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(" kg"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();
  delay(100);

}

My problem persists.

I have noted a few things:
When the program is running correctly, and I press the reset button, everything will resume running correctly.
When the program is running correctly, and I unplug the arduino and plug in again, sometimes it will not run correctly and I will get a static reading.

Could this be a fault with the arduino, as I moved to the HX711 instead of using a INA125p which the arduinos ADC was not reading correctly?

Any suggestions on how to diagnose this issue would be greatly appreciated.

Thanks, MIcheal