HX711_ADC - 'EEPROM' was not declared in this scope

Sorry for the sudden post. This is my first time working with electronics. I usually have a background in backend development. I urgently need to finish a project that involves measuring drag and lift in a wind tunnel using pressure sensors. Any help or advice would be greatly appreciated!

i try to use arduino Uno R4 wifi with HX711 and pressure sensor as in https://youtu.be/sxzoAGf1kOo?si=TmBgZxOGkHUOab_I.
library HX711_ADC library mentoned in the video .

however note , i m currently using a UNO R4 WiFi board . ( to me that the only signifigant diff with the video)

currently i recieve this error message below , do i miss a library EEPROM ?? i did try to find it :

C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino: In function 'void calibrate()':
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino:148:9: error: 'EEPROM' was not declared in this scope
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
^~~~~~
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino:148:9: note: suggested alternative: 'EIDRM'
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
^~~~~~
EIDRM
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino: In function 'void changeSavedCalFactor()':
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino:204:9: error: 'EEPROM' was not declared in this scope
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
^~~~~~
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-j85w7k.o89c\Calibration\Calibration.ino:204:9: note: suggested alternative: 'EIDRM'
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
^~~~~~
EIDRM

exit status 1

Compilation error: 'EEPROM' was not declared in this scope

Welcome to the forum

You started a topic in the Uncategorised category of the forum when its description explicitly tells you not to

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Please post your full sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

1 Like

Did you

#include <EEPROM.h>

?

The HX711_ADC library examples are not compatible with the UNO R4 line of boards, because the inclusion of EEPROM.h is conditional on the board using an ESP8266, ESP32, or AVR processor. Comment out the #if and #endif and the code should compile.

#include <HX711_ADC.h>
#if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#include <EEPROM.h>
#endif

that the start of the calibration code :

#include <HX711_ADC.h>
#if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#include <EEPROM.h>
#endif

//pins:
const int HX711_dout = 4; //mcu > HX711 dout pin
const int HX711_sck = 5; //mcu > HX711 sck pin

//HX711 constructor:
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
unsigned long t = 0;

void setup() {
Serial.begin(57600); delay(10);
Serial.println();
Serial.println("Starting...");

LoadCell.begin();
//LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) {
Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
while (1);
}
else {
LoadCell.setCalFactor(1.0); // user set calibration value (float), initial value 1.0 may be used for this sketch
Serial.println("Startup is complete");
}
while (!LoadCell.update());
calibrate(); //start calibration procedure
}

void loop() {
static boolean newDataReady = 0;
const int serialPrintInterval = 0; //increase value to slow down serial print activity

// check for new data/start next conversion:
if (LoadCell.update()) newDataReady = true;

// get smoothed value from the dataset:
if (newDataReady) {
if (millis() > t + serialPrintInterval) {
float i = LoadCell.getData();
Serial.print("Load_cell output val: ");
Serial.println(i);
newDataReady = 0;
t = millis();
}
}

// receive command from serial terminal
if (Serial.available() > 0) {
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay(); //tare
else if (inByte == 'r') calibrate(); //calibrate
else if (inByte == 'c') changeSavedCalFactor(); //edit calibration value manually
}

// check if last tare operation is complete
if (LoadCell.getTareStatus() == true) {
Serial.println("Tare complete");
}

}

void calibrate() {
Serial.println("***");
Serial.println("Start calibration:");
Serial.println("Place the load cell an a level stable surface.");
Serial.println("Remove any load applied to the load cell.");
Serial.println("Send 't' from serial monitor to set the tare offset.");

boolean _resume = false;
while (_resume == false) {
LoadCell.update();
if (Serial.available() > 0) {
if (Serial.available() > 0) {
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
}
if (LoadCell.getTareStatus() == true) {
Serial.println("Tare complete");
_resume = true;
}
}

Serial.println("Now, place your known mass on the loadcell.");
Serial.println("Then send the weight of this mass (i.e. 100.0) from serial monitor.");

float known_mass = 0;
_resume = false;
while (_resume == false) {
LoadCell.update();
if (Serial.available() > 0) {
known_mass = Serial.parseFloat();
if (known_mass != 0) {
Serial.print("Known mass is: ");
Serial.println(known_mass);
_resume = true;
}
}
}

LoadCell.refreshDataSet(); //refresh the dataset to be sure that the known mass is measured correct
float newCalibrationValue = LoadCell.getNewCalibration(known_mass); //get the new calibration value

Serial.print("New calibration value has been set to: ");
Serial.print(newCalibrationValue);
Serial.println(", use this as calibration value (calFactor) in your project sketch.");
Serial.print("Save this value to EEPROM adress ");
Serial.print(calVal_eepromAdress);
Serial.println("? y/n");

_resume = false;
while (_resume == false) {
if (Serial.available() > 0) {
char inByte = Serial.read();
if (inByte == 'y') {
#if defined(ESP8266)|| defined(ESP32)
EEPROM.begin(512);
#endif
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
#if defined(ESP8266)|| defined(ESP32)
EEPROM.commit();
#endif
EEPROM.get(calVal_eepromAdress, newCalibrationValue);
Serial.print("Value ");
Serial.print(newCalibrationValue);
Serial.print(" saved to EEPROM address: ");
Serial.println(calVal_eepromAdress);
_resume = true;

  }
  else if (inByte == 'n') {
    Serial.println("Value not saved to EEPROM");
    _resume = true;
  }
}

}

Serial.println("End calibration");
Serial.println("");
Serial.println("To re-calibrate, send 'r' from serial monitor.");
Serial.println("For manual edit of the calibration value, send 'c' from serial monitor.");
Serial.println("
");
}

void changeSavedCalFactor() {
float oldCalibrationValue = LoadCell.getCalFactor();
boolean _resume = false;
Serial.println("");
Serial.print("Current value is: ");
Serial.println(oldCalibrationValue);
Serial.println("Now, send the new value from serial monitor, i.e. 696.0");
float newCalibrationValue;
while (_resume == false) {
if (Serial.available() > 0) {
newCalibrationValue = Serial.parseFloat();
if (newCalibrationValue != 0) {
Serial.print("New calibration value is: ");
Serial.println(newCalibrationValue);
LoadCell.setCalFactor(newCalibrationValue);
_resume = true;
}
}
}
_resume = false;
Serial.print("Save this value to EEPROM adress ");
Serial.print(calVal_eepromAdress);
Serial.println("? y/n");
while (_resume == false) {
if (Serial.available() > 0) {
char inByte = Serial.read();
if (inByte == 'y') {
#if defined(ESP8266)|| defined(ESP32)
EEPROM.begin(512);
#endif
EEPROM.put(calVal_eepromAdress, newCalibrationValue);
#if defined(ESP8266)|| defined(ESP32)
EEPROM.commit();
#endif
EEPROM.get(calVal_eepromAdress, newCalibrationValue);
Serial.print("Value ");
Serial.print(newCalibrationValue);
Serial.print(" saved to EEPROM address: ");
Serial.println(calVal_eepromAdress);
_resume = true;
}
else if (inByte == 'n') {
Serial.println("Value not saved to EEPROM");
_resume = true;
}
}
}
Serial.println("End change calibration value");
Serial.println("
");
}

ok i ll try this

many thanks for your quick answer David !
i tried your suggestion (see below the error) and still another error

C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-1wp1cuv.ir38\Calibration\Calibration.ino:22:1: error: expected unqualified-id before 'if'
if defined(ESP8266)|| defined(ESP32) || defined(AVR)
^~
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-1wp1cuv.ir38\Calibration\Calibration.ino:24:1: error: 'endif' does not name a type
endif
^~~~~
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-1wp1cuv.ir38\Calibration\Calibration.ino:31:20: error: 'HX711_dout' was not declared in this scope
HX711_ADC LoadCell(HX711_dout, HX711_sck);
^~~~~~~~~~
C:\Users\chris\AppData\Local\Temp.arduinoIDE-unsaved2024912-20692-1wp1cuv.ir38\Calibration\Calibration.ino:31:20: note: suggested alternative: 'HX711_sck'
HX711_ADC LoadCell(HX711_dout, HX711_sck);
^~~~~~~~~~
HX711_sck

exit status 1

Compilation error: expected unqualified-id before 'if'

modified code :

#include <HX711_ADC.h>
if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#include <EEPROM.h>
endif
//pins:
const int HX711_dout = 4; //mcu > HX711 dout pin
const int HX711_sck = 5; //mcu > HX711 sck pin

Either comment the lines out, or just delete them completely.

#include <HX711_ADC.h>
//#if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#include <EEPROM.h>
//#endif

David if you know any other library with a youtube video i could follow to make 2 senors with HX711 and my UNOR4 works , that would also fix my issue i m trying to get the pressure measure on computer to confrim some aerodynamic models .
the libraryi usde is old from 2016 ...i think that the basic issue .

Please post your full sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help

Please edit your posts with code. Select all code in a post, click the <CODE/> button and next save the post. This will apply code tags that will make the code easier to read and easier to copy and the forum display will display it correctly (no italics, no bold, no odd blocks, ...).

You can do the same for error messages.