i am assigning hexadecimal address in EEPROM.WRITE(hexaddress,value).but i will take int only so i convet it into decimal and then assign it but it will give incorrect output. Can anyone please help.
write_read_flash_mar02a.ino (1.2 KB)
i am assigning hexadecimal address in EEPROM.WRITE(hexaddress,value).but i will take int only so i convet it into decimal and then assign it but it will give incorrect output. Can anyone please help.
write_read_flash_mar02a.ino (1.2 KB)
Please post your code.
@anon73444976 i all ready attached it. can you please check
write_read_flash_mar02a.ino (1.2 KB)
Do you know that mobile devices can't read .ino files. Best post it like it says in the instructions link you got when you first posted.
It it totally irrelevant how you specify the address, it all gets converted to binary inside the machine. There is no need to convert anything to anything. It is only print functions that convert to decimal for you. All operations are in binary. Note the EEPROM write function will only store a single byte, that is just an 8 bit variable.
I find it amazing you'd repeat the attachment, rather than simply doing as you were asked, to help others to help you.
int addr = 8392703;
Are you using an UNO where an 'int' can't hold any number larger than 32767?
EEPROM.write(8392703, ssid[i]);
You are writing all bytes in the same address?!?
for (int i = 0; i < data_read_buf.length(); i++)
{
byte readValue = EEPROM.read(i);//it will read data as per write
You are reading data starting at address 0, nowhere near address 8392703.
#include "EEPROM.h"
//int addr = 0;
int addr = 8392703;
//int addr = 1082925031;
#define EEPROM_SIZE 20
String data_read_buf = "01030FFAED";
// the sample text which we are storing in EEPROM
//char ssid[64] = data_read_buf;
void setup()
{
Serial.begin(115200);
Serial.println("starting now...");
if (!EEPROM.begin(EEPROM_SIZE))
{
Serial.println("failed to init EEPROM");
delay(1000000);
}
String stringOne = data_read_buf;
char ssid[data_read_buf.length()];
stringOne.toCharArray(ssid, data_read_buf.length());
// writing byte-by-byte to EEPROM
for (int i = 0; i < data_read_buf.length(); i++) //
{
EEPROM.write(8392703, ssid[i]);
addr -= 1;// from last address it will decrement
}
Serial.println("addr=");
Serial.println(addr);
EEPROM.commit();
// reading byte-by-byte from EEPROM
for (int i = 0; i < data_read_buf.length(); i++)
{
byte readValue = EEPROM.read(i);//it will read data as per write
if (readValue == 0)
{
break;
}
char readValueChar = char(readValue);//read ascii value and convert it into char
Serial.print(readValueChar);
}
}
void loop()
{
}