HX711 library SCALE & OFFSET error

Greetings Everyone!

Can anyone help me find the solution to my problem. Is the problem within the library of Load Amplifier itself? (Pardon my grammar :slight_smile: )

#include "HX711.h"

HX711 scale;

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

  Serial.println("Initializing the scale");
  // parameter "gain" is ommited; the default value 128 is used by the library
  // HX711.DOUT	- pin #A1
  // HX711.PD_SCK	- pin #A0
  scale.begin(A1, A0);

  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("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 (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();
}

Here's the error message:

In file included from HX711SerialBegin.cpp:1:
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:16: error: ISO C++ forbids initialization of member 'OFFSET'
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:16: error: making 'OFFSET' static
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:16: error: ISO C++ forbids in-class initialization of non-const static member 'OFFSET'
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:17: error: ISO C++ forbids initialization of member 'SCALE'
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:17: error: making 'SCALE' static
C:\Program Files (x86)\Arduino 1.0\libraries\HX711/HX711.h:17: error: ISO C++ forbids in-class initialization of non-const static member 'SCALE'

Any help will be much appreciated. Thank you! :slight_smile:

That does look like a problem inside the library. Where did you get it from? Did you change anything in the .h file yourself?

Maybe downloading a fresh copy of the library from a good source will fix it.