RobTillaart / HX711

Arduino library for HX711 24 bit ADC used for load cells and scales.
MIT License
86 stars 29 forks source link

calibrado con eeprom #15

Closed Albalate closed 2 years ago

Albalate commented 2 years ago

I have added an example to calibrate the scale and add the result in the eeprom memory of arduino UNO. regards

RobTillaart commented 2 years ago

Thanks, good example.

Some remarks:

No showstoppers, will merge the PR in coming days after you fixed the failing build-CI.

RobTillaart commented 2 years ago

The build fails on your new sketch with the eeprom code. It might be ESP specific.

Albalate commented 2 years ago

sorry, All of the following boards have an EEPROM: (https://docs.arduino.cc/learn/programming/eeprom-guide) Arduino UNO Rev.3 Arduino UNO WiFi Rev.2 Arduino Mega 2560 Rev.3 Arduino Nano Every Arduino Micro Arduino Leonardo Arduino Nano

EEPROM.h

RobTillaart commented 2 years ago

@Albalate

check - https://github.com/RobTillaart/HX711/runs/5526296592?check_suite_focus=true

line 580 and more shows the errors during compilation of your example

Last command:  $  /home/runner/arduino-cli --format json compile --fqbn arduino:avr:uno --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino: In function 'void StupEeprom()':
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:29:32: error: no matching function for call to 'EEPROMClass::begin(int)'
   if (!EEPROM.begin(EEPROM_SIZE))
                                ^
In file included from /home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:15:0:
/home/runner/.arduino15/packages/arduino/hardware/avr/1.8.5/libraries/EEPROM/src/EEPROM.h:125:11: note: candidate: EEPtr EEPROMClass::begin()
     EEPtr begin()                        { return 0x00; }
           ^~~~~
/home/runner/.arduino15/packages/arduino/hardware/avr/1.8.5/libraries/EEPROM/src/EEPROM.h:125:11: note:   candidate expects 0 arguments, 1 provided
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino: In function 'float SaveFloat(int, float)':
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:40:10: error: 'struct EEPROMClass' has no member named 'writeFloat'; did you mean 'write'?
   EEPROM.writeFloat(addr, param);//EEPROM.put(address, param);
          ^~~~~~~~~~
          write
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:41:10: error: 'struct EEPROMClass' has no member named 'commit'
   EEPROM.commit();
          ^~~~~~
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino: In function 'long int SaveLong(int, long int)':
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:44:10: error: 'struct EEPROMClass' has no member named 'writeFloat'; did you mean 'write'?
   EEPROM.writeFloat(addr, param);//EEPROM.put(address, param);
          ^~~~~~~~~~
          write
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:45:10: error: 'struct EEPROMClass' has no member named 'commit'
   EEPROM.commit();
          ^~~~~~
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino: In function 'void setup()':
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:123:12: error: 'struct EEPROMClass' has no member named 'commit'
     EEPROM.commit();
            ^~~~~~
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:125:5: error: 'ESP' was not declared in this scope
     ESP.restart();
     ^~~
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:125:5: note: suggested alternative: 'SP'
     ESP.restart();
     ^~~
     SP
Error during build: exit status 1
                       ✗
Compiling hHX_set_persistent.ino for adafruit:samd:adafruit_metro_m4... 
Last command:  $  /home/runner/arduino-cli --format json compile --fqbn adafruit:samd:adafruit_metro_m4 --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:15:10: fatal error: EEPROM.h: No such file or directory
   15 | #include "EEPROM.h"
      |          ^~~~~~~~~~
compilation terminated.
Error during build: exit status 1
       ✗

You can restrict the platforms to only those that compile by adding a file to the example folder called .arduino-ci.yml

the content should be like this, but only the platforms that compile

compile:
  # Choosing to run compilation tests on 2 different Arduino platforms
  platforms:
    # - uno
    # - due
    # - zero
    # - leonardo
    # - m4
    - esp32
    # - esp8266
    # - mega2560

esp8266 might work too

Finally you must rename the example so it is EXPLICIT that it is an ESP32 specific example.

RobTillaart commented 2 years ago

Other patched example does fail to build too

Discovered example sketch...                                  HX_delta_scale.ino
Wildcard architecture in library.properties, using configured platforms... 
    uno
    m4
    esp32
...Wildcard architecture in library.properties, using configured platforms      
Board package arduino:avr has a defined URL...                                 ✓
Installing board package arduino:avr...                                        ✓
Board package esp32:esp32 has a defined URL...                                 ✓
Installing board package esp32:esp32...                                        ✓
Board package adafruit:samd has a defined URL...                               ✓
Installing board package adafruit:samd...                                      ✓
Compiling HX_delta_scale.ino for arduino:avr:uno... 
Last command:  $  /home/runner/arduino-cli --format json compile --fqbn arduino:avr:uno --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino: In function 'void setup()':
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:15: error: 'dataPin' was not declared in this scope
   scale.begin(dataPin, clockPin);
               ^~~~~~~
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:15: note: suggested alternative: 'atan'
   scale.begin(dataPin, clockPin);
               ^~~~~~~
               atan
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:24: error: 'clockPin' was not declared in this scope
   scale.begin(dataPin, clockPin);
                        ^~~~~~~~
Error during build: exit status 1
                           ✗
Compiling HX_delta_scale.ino for adafruit:samd:adafruit_metro_m4... 
Last command:  $  /home/runner/arduino-cli --format json compile --fqbn adafruit:samd:adafruit_metro_m4 --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino: In function 'void setup()':
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:15: error: 'dataPin' was not declared in this scope; did you mean 'atan'?
   26 |   scale.begin(dataPin, clockPin);
      |               ^~~~~~~
      |               atan
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:24: error: 'clockPin' was not declared in this scope
   26 |   scale.begin(dataPin, clockPin);
      |                        ^~~~~~~~
Error during build: exit status 1
           ✗
Compiling HX_delta_scale.ino for esp32:esp32:featheresp32:FlashFreq=80... 
Last command:  $  /home/runner/arduino-cli --format json compile --fqbn esp32:esp32:featheresp32:FlashFreq=80 --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino: In function 'void setup()':
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:15: error: 'dataPin' was not declared in this scope
   scale.begin(dataPin, clockPin);
               ^~~~~~~
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:15: note: suggested alternative: 'atan'
   scale.begin(dataPin, clockPin);
               ^~~~~~~
               atan
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:24: error: 'clockPin' was not declared in this scope
   scale.begin(dataPin, clockPin);
                        ^~~~~~~~
/home/runner/Arduino/libraries/HX711/examples/HX_delta_scale/HX_delta_scale.ino:26:24: note: suggested alternative: 'clock_t'
   scale.begin(dataPin, clockPin);
                        ^~~~~~~~
                        clock_t
Error during build: exit status 1
     ✗

Missing declaration and initialization of the data and clock pin.

RobTillaart commented 2 years ago
Compiling hHX_set_persistent.ino for arduino:avr:uno...                        ✓
Compiling hHX_set_persistent.ino for adafruit:samd:adafruit_metro_m4... 
Last command:  $  /home/runner/arduino-cli --format json compile --fqbn adafruit:samd:adafruit_metro_m4 --warnings all --dry-run /home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino
/home/runner/Arduino/libraries/HX711/examples/hHX_set_persistent/hHX_set_persistent.ino:11:10: fatal error: EEPROM.h: No such file or directory
   11 | #include "EEPROM.h"
      |          ^~~~~~~~~~
compilation terminated.
Error during build: exit status 1
       ✗
Compiling hHX_set_persistent.ino for esp32:esp32:featheresp32:FlashFreq=80...  ✓
Albalate commented 2 years ago

now complia for arduino uno, when I finish the project that I have in hand, I will give it more love to make it compatible with other architectures esp32 and esp8266

RobTillaart commented 2 years ago

now complia for arduino uno, when I finish the project that I have in hand, I will give it more love to make it compatible with other architectures esp32 and esp8266

Thanks,

Albalate commented 2 years ago

the EEPROM.h library is included in the standard arduino libraries, I have compiled with Atom, Vsc, and the arduino ide v1 and v2, without any problem. the test is not correct. regards

RobTillaart commented 2 years ago

the EEPROM.h library is included in the standard arduino libraries, I have compiled with Atom, Vsc, and the arduino ide v1 and v2, without any problem. the test is not correct. regards

You need to add an .arduino-ci.yml file, I mentioned before

RobTillaart commented 2 years ago

@Albalate Check - https://github.com/RobTillaart/Cozir/tree/master/examples/Cozir_MEGA_3_channel_CO2 it has a .arduino-CI.yml to only allow a MEGA to run, the others platforms are commented.

You need to make a file that only allows UNO and ESP32 and comment the others.

Then it will compile and I can merge

Albalate commented 2 years ago

the EEPROM.h library is included in the standard arduino libraries, I have compiled with Atom, Vsc, and the arduino ide v1 and v2, without any problem. the test is not correct. regards

You need to add an .arduino-ci.yml file, I mentioned before

I already had the file with only UNO, ESP32 and M4. now I have tried only with, UNO

RobTillaart commented 2 years ago

And there is green light!

Can you please enable the ESP32 too in the .arduino-CI.yml file as that one compiled too.

RobTillaart commented 2 years ago

It looks perfect, will merge tomorrow