#include "Arduino.h" #include #include SoftwareSerial HM10(2, 3); char message = ""; String text = ""; String sendBack = ""; void writeStringToEEPROM(int addrOffset, const String &strToWrite) { byte len = strToWrite.length(); EEPROM.write(addrOffset, len); for (int i = 0; i < len; i++) { EEPROM.write(addrOffset + 1 + i, strToWrite[i]); } } String readStringFromEEPROM(int addrOffset) { int newStrLen = EEPROM.read(addrOffset); char data[newStrLen + 1]; for (int i = 0; i < newStrLen; i++) { data[i] = EEPROM.read(addrOffset + 1 + i); } data[newStrLen] = '\0'; // !!! NOTE !!! Remove the space between the slash "/" and "0" (I've added a space because otherwise there is a display bug) return String(data); } String texto; void setup(){ Serial.begin(115200); String retrievedString = readStringFromEEPROM(12); Serial.print("Startup:"); Serial.println(retrievedString); HM10.begin(115200); } boolean wait; void loop(){ int i; //addressCharArray = EEPROM.getAddress(sizeof(char)*7); String retrievedString = readStringFromEEPROM(12); if(HM10.available()) { //text = HM10.readString(); text = HM10.readString(); Serial.println("Text Recevied from Android: "); Serial.println(text); if (text == "GETMSG") { Serial.print("GETMSG received"); Serial.print("MSG to send back:"); Serial.print(retrievedString.c_str()); HM10.print(retrievedString.c_str()); } else { Serial.print("Writting MSG:"); Serial.print(text); writeStringToEEPROM(12, text); sendBack = "MSG Written"; HM10.print(sendBack.c_str()); } } }