NodeMcu v1.0 (ESP8266 12E) store/read a value from EEPROM
Posted: Mon May 22, 2017 2:00 pm
Hello, I want to store a value (int) of four numbers like (int a=1111) in the NodeMcu v1.0 EEPROM then when I turn off and on again the board the int i will stay equal to 1111.
I tried this code on my Arduino UNO board and it works fine, to store:
And this one to read the data when I unplug and plug the board again
This works fine on my Arduino Uno but when I try it on my NodeMcu v1.0 board, when I want to get the data I always get on serial monitor a strange number like "-17829890" whatever the number I store before
I tried this code on my Arduino UNO board and it works fine, to store:
Code: Select all
#include <EEPROM.h>
void setup() {
Serial.begin(9600);
int a=1111;
int eeAddress = 0;
EEPROM.put(eeAddress, a);
eeAddress += sizeof(int);
EEPROM.put(eeAddress, a);
Serial.print("Written");
}
void loop() {
/* Empty loop */
}
And this one to read the data when I unplug and plug the board again
Code: Select all
#include <EEPROM.h>
void setup() {
int a;
int eeAddress = 0;
Serial.begin(9600);
while (!Serial) {
;
}
EEPROM.get(eeAddress, a);
Serial.println(a);
}
void loop() {
/* Empty loop */
}
This works fine on my Arduino Uno but when I try it on my NodeMcu v1.0 board, when I want to get the data I always get on serial monitor a strange number like "-17829890" whatever the number I store before