I need some help, I will have to store many 9 character strings example (234597801, 675789501, 657896510) are ID coming from an external equipment.
So I need to store many of these numbers using the smallest eeprom address number, I use esp8266 with 4096 eerpom addresses, however if I write one character to each address I will have 455 ID's saved but I need to store more values as I could do that?
It's just that I'm programming both for ESP and for an app, there will be communication between them.
Anyway, now I will not have time to analyze and test everything I have available, in C for PIC (microchip) I know how to do this, I used a lot already, but now in Arduino IDE I am time this problem.
If it's easy for you to put a simple example of how to do it, I'd be grateful, but if it's hard work you can let me turn around and run after the information.
Yes I do not support either, I usually take examples and modify my need.
However, I saw a lot of material available in English, I am Brazilian, and my English is very beginner, I confuse myself with words, so it is a little complicated to understand all material available on the Internet.
However I thought of a way to continue taking up less eeprom space, I'll take the ID (string) split into 5 2-character strings (45, 68, 89 for example) then convert to byte, then instead of occupying 9 addresses. eeprom to save each ID, I would only occupy 5.
It may not be the best option, but so I think I can do it, realize that it is not lack of willpower, it is by not knowing the correct paths and a simple example would help me to follow the best path.
2. Memory mapping of string of Step-1 is: 32 33 34 35 39 37 38 30 31 (spaces are for clarity).
3. You want to save it into EEPROM of ESP using minimum locations -- (1) Normal storage of the data of Step-2 would require: 9 locations. (2) Equivalent integer (234597801 ==> 0x0DFBADA9) would require: 4 locations. (3) Convert string data of Step-2 into unsigned long integer data:
4. Store 4-byte data of Step-3(2) into internal EEPROM (starting at location 0x0010) of ESP8266 using codes to be written by OP. (My codes read back 0. Have data been written?)
2. EEPROM.write() and EEPROM.read() functions are valid for ESP8266's EEPROM.
3. EEPROM.begin() and EEPROM.commit() are also two needed functions for ESP8266's EEPROM.
Example Codes (Writing the string "234597801" into EEPROM of ESP8266 and reading back)
#include <EEPROM.h>
char myData[] = "234597801";
byte readArray[4];
unsigned long y;
union
{
unsigned long x;
byte myData[4];
} data;
void setup()
{
Serial.begin(115200);
y = strtoul(myData, nullptr, 10);
Serial.println(y, HEX); //shows: DFBADA9 => 0DFBADA9
Serial.println("====");
data.x = y;
EEPROM.begin(512); //Initialize EEPROM
for (int i = 0; i < 4; i++)
{
EEPROM.write(0x0010 + i, data.myData[i]);
}
EEPROM.commit(); //Store data to EEPROM
}
//--read back written data from EEPROM and show on Serial Monitor at 1-sec interval-
void loop()
{
int addr = 0x0010;
Serial.println(""); //go next line as ESP prints garbage
Serial.println("Reading back previously written from EEPROM of ESP8266");
for (int i = 0; i < 4; i++)
{
readArray[i] = EEPROM.read(0x0010 + i);
if (readArray[i] < 0x10)
{
Serial.print('0');
}
Serial.print(readArray[i], HEX);
Serial.print(' ');
}
delay(1000);
}