Hello,
As the title says, I have been using EEPROM.put/get to store a string in the EEPROM of a 3.2. When later power cycling, the string completely changes value. Any ideas? I'm speculating that maybe all the values get left/right shifted?
Serial:
As the title says, I have been using EEPROM.put/get to store a string in the EEPROM of a 3.2. When later power cycling, the string completely changes value. Any ideas? I'm speculating that maybe all the values get left/right shifted?
Code:
#include <StreamMessageHandler.h>
#include <EEPROM.h>
StreamMessageHandler USBSERIAL;
char testWordread[10];
String testWord;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
USBSERIAL.registerState(ping,"ping");
USBSERIAL.registerState(readName,"readname");
}
void loop() {
// put your main code here, to run repeatedly:
USBSERIAL.run();
}
state ping() {
Serial.println("pong");
testWord = USBSERIAL.parameter(0);
EEPROM.put(0,testWord.c_str());
}
state readName() {
EEPROM.get(0,testWordread);
testWord = String(testWordread);
Serial.println(testWord);
}
Serial:
Code:
ping::aaaaaaaa
pong
readname //before power cycle
aaaaaaaa
readname // after power cycle
YzˆÆùT‚b
ping::aaaaaaa
pong
readname //before
aaaaaaa
readname
Yz?ÆyT‚