Code Monkey home page Code Monkey logo

arduino-eepromex's Introduction

Arduino EEPROMEx library

Build Status License: LGPL v21

The EEPROMex library is an extension of the standard Arduino EEPROM library. It extends the functionality of the original Arduino EEPROM library with:

  • Reading, writing to basic types. This includes bytes, longs, ints, floats and doubles.
  • Reading, writing to single bits. This helps efficient usage of the limited EEPROM memory.
  • Reading, writing of any data format. This can be for example structs, strings, etc.
  • Reading, writing of arrays of any format. By storing, for example, arrays of structs one can create a database like structure.
  • Update functions. The function similar to write functions, but only update changed bytes. If structures have only changed partly, updating instead of writing can save a lot EEPROM wear and significantly increase speed.
  • Basic memory allocation functionality. This is basically a counter of the first unallocated byte, and helps giving unique addresses to variables.
  • Enabling write limitation: In theory one can burn out a memory cell in a few minutes: a write/erase cycle takes approximately 4 ms, so writing 100.000 times to a single cell takes 6 1/2 min. Limiting the number of writes during the debug phase helps prevent this.
  • Debugging of writing out of memory range.

And find detailed explanation and samples of the functionality here: http://thijs.elenbaas.net/2012/07/extended-eeprom-library-for-arduino

Downloading

This package can be downloaded in different manners

  1. Go to https://github.com/thijse/Arduino-EEPROMEx
  2. Click the DOWNLOAD ZIP button in the panel on the
  3. Rename the uncompressed folder Arduino-EEPROMEx-master to EEPROMEx.
  4. You may need to create the libraries subfolder if its your first library.
  5. Place the EEPROMEx library folder in your arduinosketchfolder/libraries/ folder.
  6. Restart the IDE.
  7. For more information, read this extended manual
  • If you want to have a package that includes all referenced libraries, use the pre-packaged library
  1. Download the package as a zipfile here or as a tarball here .
  2. Copy the folders inside the libraries folder to you your arduinosketchfolder/libraries/ folder.
  3. Restart the IDE.
  4. For more information, read this extended manual

Using different data formats

The aim of the library is to also support other standard data types: it currently implements writing and reading to int, long, float and double.

For reading:

uint8_t read(int address);
bool readBit(int address, byte bit)
uint8_t readByte(int address);
uint16_t readInt(int address);
uint32_t readLong(int address);
float readFloat(int address);
double readDouble(int address);

Where address is the starting position in EEPROM, and the return value the value read from EEPROM.

For writing:

bool write(int address, uint8_t value);
bool writeByte(int address, uint8_t value);
bool writeInt(int address, uint16_t value);
bool writeLong(int address, uint32_t value);
bool writeFloat(int address, float value);
bool writeDouble(int address, double value);

The update functions are different from the write functions: they will check per byte if the current value differs and only update the the cell with a different value. This will not only reduce wear, and can also significantly reduce write time.

bool update(int address, uint8_t value);
bool updateByte(int address, uint8_t value);
bool updateInt(int address, uint16_t value);
bool updateLong(int address, uint32_t value);
bool updateFloat(int address, float value);
bool updateDouble(int address, double);

Manipulating Single bits

The following functions implements reading and writing single bits:

bool readBit(int address, byte bit)

Where bit is the write position in the byte, ranging from [0..7], with bit 0 being the right-most. The return value is the read bit.

bool writeBit(int address, uint8_t bit, bool value)
bool updateBit(int address, uint8_t bit, bool value)

Data blocks

Using the block functions any data can be read, written and updated:

int readBlock(int address, const T& value)
int writeBlock(int address, const T& value)
int updateBlock(int address, const T& value)

where T is the type of the data to read/write/update. This can be a basic type, but also a more complex type like a struct. The return value gives the number of bytes that have been read, written or updated.

One can also read/write arrays of data-blocks:

int readBlock(int address, const T[]; value, int items)
int writeBlock(int address, const T[]; value, int items)
int updateBlock(int address, const T[]; value, int items)

Debugging EEPROM applications

It is easy to burn out a memory cell in few minutes, so during debugging it would be very useful to limit the number of allowed writes. It is easy to put a bracket at the wrong location, and placing an EEPROM write inside of a loop, rather than outside, and introduce extensive writing causing wear. The following function helps limit the number of writes.

setMaxAllowedWrites(int allowedWrites);

More writes than allowed will be refused and result in an error message. You can also set the address range used by the library:

setMemPool(int base, int memSize);

The lower value is used by the getAddress function, the upper value is used for setting the EEPROM size. Writing outside the maximum size will result in an error message. The following EEPROM sizes are predefined

Based on processor:

*EEPROMSizeATmega168
*EEPROMSizeATmega328
*EEPROMSizeATmega1280
*EEPROMSizeATmega32u4
*EEPROMSizeAT90USB1286
*EEPROMSizeMK20DX128

Based on board:

*EEPROMSizeUno
*EEPROMSizeUnoSMD
*EEPROMSizeLilypad
*EEPROMSizeDuemilanove
*EEPROMSizeMega
*EEPROMSizeDiecimila
*EEPROMSizeNano
*EEPROMSizeTeensy2
*EEPROMSizeLeonardo
*EEPROMSizeMicro
*EEPROMSizeYun
*EEPROMSizeTeensy2pp
*EEPROMSizeTeensy3

EEPROM performance

All of the read/write functions make sure the EEPROM is ready to be accessed. Since this may cause a delay of max 4ms, time-critical applications should first poll the EEPROM e. g. using the isReady function before attempting any actual I/O:

bool isReady();

On using and modifying libraries

Copyright

EEPROMEx is provided Copyright © 2013-2017 under LGPL License.

arduino-eepromex's People

Contributors

bdeeming avatar friedcircuits avatar gandy92 avatar ivankravets avatar marcelrv avatar paulstoffregen avatar per1234 avatar thijse avatar tvcsantos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-eepromex's Issues

Unable to compile

Arduino: 1.8.12 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h: In member function 'int EEPROMClassEx::readBlock(int, const T&)':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:121:71: error: there are no arguments to 'eeprom_read_block' that depend on a template parameter, so a declaration of 'eeprom_read_block' must be available [-fpermissive]

eeprom_read_block((void*)&value, (const void*)address, sizeof(value));

                                                                   ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:121:71: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h: In member function 'int EEPROMClassEx::writeBlock(int, const T&)':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:143:66: error: there are no arguments to 'eeprom_write_block' that depend on a template parameter, so a declaration of 'eeprom_write_block' must be available [-fpermissive]

eeprom_write_block((void*)&value, (void*)address, sizeof(value));

                                                              ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h: At global scope:

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:195:22: error: conflicting declaration 'EEPROMClassEx EEPROM'

extern EEPROMClassEx EEPROM;

                  ^

In file included from C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:29:0,

             from F:\Downloads 2019\Documents\Arduino\ota-jarvis-iot-home-may2020\ota-jarvis-iot-home-may2020.ino:1:

C:\Users\balra\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\EEPROM/EEPROM.h:77:20: error: 'EEPROM' has a previous declaration as 'EEPROMClass EEPROM'

extern EEPROMClass EEPROM;

                ^

In file included from F:\Downloads 2019\Documents\Arduino\ota-jarvis-iot-home-may2020\ota-jarvis-iot-home-may2020.ino:2:0:

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h: In constructor 'EEPROMVar::EEPROMVar(const T&)':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:32:18: error: 'class EEPROMClass' has no member named 'getAddress'

address(EEPROM.getAddress(sizeof(T)))

              ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h: In member function 'void EEPROMVar::save()':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:71:13: error: 'class EEPROMClass' has no member named 'writeBlock'

  EEPROM.writeBlock<T>(address, var);

         ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:71:25: error: expected primary-expression before '>' token

  EEPROM.writeBlock<T>(address, var);

                     ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h: In member function 'void EEPROMVar::update()':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:75:13: error: 'class EEPROMClass' has no member named 'updateBlock'

  EEPROM.updateBlock<T>(address, var);

         ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:75:26: error: expected primary-expression before '>' token

  EEPROM.updateBlock<T>(address, var);

                      ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h: In member function 'void EEPROMVar::restore()':

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:83:12: error: 'class EEPROMClass' has no member named 'readBlock'

 EEPROM.readBlock<T>(address, var);

        ^

C:\Users\balra\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMVar.h:83:23: error: expected primary-expression before '>' token

 EEPROM.readBlock<T>(address, var);

                   ^

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

problem with ATtiny3217

Beste Thijse,
I have troubles using the ATtiny3217
https://github.com/SpenceKonde/megaTinyCore

The error is:
'NVM_STATUS' was not declared in this scope

Note that the standard Arduino library EEPROM.h still works fine on the ATtiny3217, see this sketch:

#include <EEPROM.h>  
void setup() 
{ Serial.begin(9600);
  while(!Serial);
  float f = 123.456f;  
  int eeAddress = 0;   
  EEPROM.put(eeAddress, f);
  EEPROM.get(eeAddress, f);
  Serial.println(f, 3);   
}
void loop() 
{
}

So, I think it is not a big compatiblity issue.

I have looked for a solution, but I don’t have enough knowledge of the Arduino platform.
Maybe you can talk to Spence Konde what to do.

Use i2c EEPROM with EEPROMEx

Maybe I've overread, but is there a possibility to use an i2c connected EEPROM like MicroChips 24AA025E48 with EEPROMEx?

I'm switching to an ATSAM21D from an ATMega 1284p in my project to get more computing power. Sadly the ATSAM does not have internal EEPROM, allthough it could be emulated in flash. As I already have the mentioned EEPROM (2kb) in my setup to have an unique MAC Address for an ethernet connection, it would be great to use this with my existing structs which hold my configuration data.

https://github.com/JChristensen/extEEPROM seems to work well but is limited to 30-31 bytes per write, hence could not handle the struct.

I'm open to any suggestions.
Cheers

Unable to compile for arduino nano every

I cannot compile my code for the arduino every board. I only included the library to see if it would compile and it does not. Help.
This is the compiler output.
E:\programata za arduino IDE e tuka\Arduino\arduino-builder -dump-prefs -logger=machine -hardware E:\programata za arduino IDE e tuka\Arduino\hardware -hardware C:\Users\User\AppData\Local\Arduino15\packages -tools E:\programata za arduino IDE e tuka\Arduino\tools-builder -tools E:\programata za arduino IDE e tuka\Arduino\hardware\tools\avr -tools C:\Users\User\AppData\Local\Arduino15\packages -built-in-libraries E:\programata za arduino IDE e tuka\Arduino\libraries -libraries E:\arduino skechovi\libraries -fqbn=arduino:megaavr:nona4809:mode=off -ide-version=10813 -build-path C:\Users\User\AppData\Local\Temp\arduino_build_989311 -warnings=default -build-cache C:\Users\User\AppData\Local\Temp\arduino_cache_710031 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose E:\arduino skechovi\PLOCI\Vaga HX711\Sim_vaga\Sim_vaga.ino E:\programata za arduino IDE e tuka\Arduino\arduino-builder -compile -logger=machine -hardware E:\programata za arduino IDE e tuka\Arduino\hardware -hardware C:\Users\User\AppData\Local\Arduino15\packages -tools E:\programata za arduino IDE e tuka\Arduino\tools-builder -tools E:\programata za arduino IDE e tuka\Arduino\hardware\tools\avr -tools C:\Users\User\AppData\Local\Arduino15\packages -built-in-libraries E:\programata za arduino IDE e tuka\Arduino\libraries -libraries E:\arduino skechovi\libraries -fqbn=arduino:megaavr:nona4809:mode=off -ide-version=10813 -build-path C:\Users\User\AppData\Local\Temp\arduino_build_989311 -warnings=default -build-cache C:\Users\User\AppData\Local\Temp\arduino_cache_710031 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose E:\arduino skechovi\PLOCI\Vaga HX711\Sim_vaga\Sim_vaga.ino Using board 'nona4809' from platform in folder: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6 Using core 'arduino' from platform in folder: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6 Detecting libraries used... "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE Alternatives for HX711.h: [[email protected]] ResolveLibrary(HX711.h) -> candidates: [[email protected]] "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE Alternatives for SoftwareSerial.h: [[email protected]] ResolveLibrary(SoftwareSerial.h) -> candidates: [[email protected]] "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE Alternatives for EEPROM.h: [[email protected]] ResolveLibrary(EEPROM.h) -> candidates: [[email protected]] "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE Alternatives for EEPROMex.h: [[email protected]] ResolveLibrary(EEPROMex.h) -> candidates: [[email protected]] "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "E:\\arduino skechovi\\libraries\\HX711\\HX711.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src\\SoftwareSerial.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "E:\\arduino skechovi\\libraries\\EEPROMEx\\EEPROMex.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE Generating function prototypes... "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE "E:\\programata za arduino IDE e tuka\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\preproc\\ctags_target_for_gcc_minus_e.cpp" Compiling sketch... "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino/api/deprecated" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\cores\\arduino" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\variants\\nona4809" "-IE:\\arduino skechovi\\libraries\\HX711" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\SoftwareSerial\\src" "-IC:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.6\\libraries\\EEPROM\\src" "-IE:\\arduino skechovi\\libraries\\EEPROMEx" "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp" -o "C:\\Users\\User\\AppData\\Local\\Temp\\arduino_build_989311\\sketch\\Sim_vaga.ino.cpp.o" In file included from E:\arduino skechovi\PLOCI\Vaga HX711\Sim_vaga\Sim_vaga.ino:5:0: E:\arduino skechovi\libraries\EEPROMEx/EEPROMex.h:188:22: error: conflicting declaration 'EEPROMClassEx EEPROM' extern EEPROMClassEx EEPROM; ^~~~~~ In file included from E:\arduino skechovi\PLOCI\Vaga HX711\Sim_vaga\Sim_vaga.ino:4:0: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\libraries\EEPROM\src/EEPROM.h:145:20: note: previous declaration as 'EEPROMClass EEPROM' static EEPROMClass EEPROM; ^~~~~~ Using library HX711 at version 0.2.0 in folder: E:\arduino skechovi\libraries\HX711 Using library SoftwareSerial at version 1.0 in folder: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\libraries\SoftwareSerial Using library EEPROM at version 2.0 in folder: C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\libraries\EEPROM Using library EEPROMEx at version 1.0.0 in folder: E:\arduino skechovi\libraries\EEPROMEx exit status 1 Error compiling for board Arduino Nano Every.

EEPROMex Library Compilation Error

I'm facing error running one of the examples of your library

C:\Users\asd\Documents\Arduino\libraries\Arduino-EEPROMEx-master/EEPROMex.h:29:24: fatal error: avr/eeprom.h: No such file or directory

#include <avr/eeprom.h>
compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Please help me, I need eeprom to writeLog variable

ESP8266 avr/eeprom.h library issue

I was wondering if it was possible to solve this issue of using the EEPROMex library with an ESP8266 device (such as node MCU) when I try to compile the code I get an error saying Avr/EEPROM.h no such file in the directory and I did a bit of research which said that this library cannot be used with ESP32 devices (I'm not sure if that is the same for ESP8266 I'm assuming it is) so if there is a fix or a change I could make to make the code work for my node MCU it would be a great help, thanks.

Making things more compatible

Can you change:

EEPROMClassEx EEPROM;

to something like:

EEPROMClassEx EEPROMEx;

EEPROMEx.h is not a drop in replacement for EEPROM.h as it doesn't have indexers and length function for instance.

easy to expect setMaxAllowedWrites to work when _EEPROMEX_DEBUG is not set

After reading the documentation for this library (both the README, and https://playground.arduino.cc/Code/EEPROMex/), I was at first under the misapprehension that setMaxAllowedWrites set a limit even when _EEPROMEX_DEBUG was not set. But that's wrong, as I later learned by reading the code; only when _EEPROMEX_DEBUG is set does it do anything. It would be easy to make this mistake and harm your hardware.

The only places that mention this, that I've found (now that I know what to look for) are some of the examples which mention that "More writes will only give errors when _EEPROMEX_DEBUG is set"

It would be good to at least mention _EEPROMEX_DEBUG where the documentation talks about setMaxAllowedWrites.

I think it would be a good idea to change the code to warn when setMaxAllowedWrites is used and _EEPROMEX_DEBUG is not set.

void EEPROMClassEx::setMaxAllowedWrites(int allowedWrites) {
#ifdef _EEPROMEX_DEBUG
	_allowedWrites = allowedWrites;
#else
    #warning "setMaxAllowedWrites has no effect since _EEPROMEX_DEBUG is not set"
#endif
}

Added CRC check option to fork.

Hello,

I updated the code in my fork (https://github.com/bzuidgeest/Arduino-EEPROMEx/) to include the functionality from https://github.com/AMPWorks/ArduinoLibs/tree/master/EEPromUtils into this libraries read/write/update block functions. So when writing data to EEPROM it also adds a start byte, records the length being written, and adds a CRC to the end of the data. I added function parameters to switch this behavior on and off.

the old functions are still all there and call the new ones using the new safeWrite parameter to switch off the new functionality.

The specific reason I had for adding these changes is that I want to be able to see if I read valid (initialized) eeprom data. the CRC check allows me to do this. Your library also had has far nicer code than the library I pulled the CRC code from.

I also changed readInt into readInt16 and readLong into readInt32. This is less confusing as the size of int and long differ depending on platform (teensy vs avr)and that might lead to mistakes if you do not look carefully.

If find just creating a pull request presumptuous. I can still do this if you find the changes interesting. I pulled enough code of github. Time to try put something back.

PS C++/github is not my most used language/sourcecontrol system. To me the changes I made look nice enough and seem to work in the tests I did, but I advise looking over the changes carefully.

Let me know.

Doesn't write properly sometimes

Hey guys,
I'm using this library in a project and figured out that it doesn't always save data to EEPROM properly.
In general this library works great, but sometimes there's no write/update made where it should.

In my project I'm using the following librarys:
sdelay.h
Wire.h
OneWire.h
DallasTemperature.h
LiquidCrystal_I2C.h
EEPROMex.h
Time.h
DS1307RTC.h

How can I figure out which version of EEPROMex I'm using?
My EEPROMex-folder is named "EEPROMEx-9.1"...but I can't remember if this was the default folder name or I changed it.

wrong indentation or missing bracket?

in file: EEPROMex.cpp
in function:
void EEPROMClassEx::setMemPool(int base, int memSize) {
//Base can only be adjusted if no addresses have already been issued
if (_nextAvailableaddress == _base)
_base = base;
_nextAvailableaddress=_base; //<- this is outside if conditional statement: is right?

Inconsistent value from readLong, always higher by 768??

Probably something really dumb going on here, but I'm stumped

I've got the same setup as the examples

 EEPROM.setMemPool(memBase, EEPROMSizeUno);
 EEPROM.setMaxAllowedWrites(maxAllowedWrites);

On button press I save said long value, then read the value in a different function on another button press.

When I write then read immediately, the value is returned as expected from readLong,

    
  Serial.println("writing delaytime value ");
  Serial.println(String(delayTime));//652
  EEPROM.writeLong(delayTimeAddr, delayTime);
  Serial.println("getting delaytime back"); //652
  Serial.println(EEPROM.readLong(delayTimeAddr));
  long read = EEPROM.readLong(delayTimeAddr)); //652

but once the readLong occurs in another or outer function, the value changes to a higher value by 768. 0b11 0000 0000.

  //outer function
  long read = EEPROM.readLong(delayTimeAddr)); //1420

This smells of a signed vs unsigned bit situation. Though I'm not sure, my cpp knowledge have long since passed me and am simply trying to save a larger value to memory.

Not able to Locate EEPROM.h file

C:\Program Files (x86)\Arduino\libraries\EEPROMex/EEPROMex.h:23:20: fatal error: EEPROM.h: No such file or directory
#include <EEPROM.h>
^
compilation terminated.
Error compiling.

If I include EEPROM in main Code I get this problem.. I am using Arduino 1.6.3

C:\Program Files (x86)\Arduino\libraries\EEPROMex/EEPROMVar.h:1:22: fatal error: WProgram.h: No such file or directory
#include <WProgram.h>
^
compilation terminated.
Error compiling.

Update Double uses write

I was reading though the code and line 311 does a write instead of an update.

bool EEPROMClassEx::updateDouble(int address, double value)
{
return (writeBlock(address, value)!=0);
}

Need a function to clear EEPROM Memory

Hi

I was thinking to clear memory using Update Function (Avoiding write cycle count in case same value).

Default value of EEPROM is 0xFF.

Only need to clear the range set by this function
EEPROM.setMemPool(memBase, EEPROMSizeUno);

or have some function to set a specific value on all use able memory selected by above function

Since I am new user of this library , I was doubtful that I would be able to make any better clear function that could do the job without violating library standards.

Purpose is to only read a set of variables when data is written for that set of variables.

I can clarify if objective is not understood.

Can be done?

Fix compiler warnings

I normally prefer to have all warning on during compilation, since some warnings actually may be catastrofig. Could you fix warnings below. You could use e.g.
#ifdef _EEPROMEX_DEBUG
#define _PARAM_allowedWrites allowedWrites
#define _PARAM_address address
#else
#define _PARAM_allowedWrites
#define _PARAM_address
#endif

and then void EEPROMClassEx::setMaxAllowedWrites(int _PARAM_allowedWrites) {


libraries\Arduino-EEPROMEx-master\EEPROMex.cpp:74:45: warning: unused parameter 'allowedWrites' [-Wunused-parameter]
void EEPROMClassEx::setMaxAllowedWrites(int allowedWrites) {

libraries\Arduino-EEPROMEx-master\EEPROMex.cpp:319:35: warning: unused parameter 'address' [-Wunused-parameter]
bool EEPROMClassEx::isWriteOk(int address)

libraries\Arduino-EEPROMEx-master\EEPROMex.cpp:341:34: warning: unused parameter 'address' [-Wunused-parameter]
bool EEPROMClassEx::isReadOk(int address)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.