String, char, etc

Mine uses the actual start and end EEPROM locations as parameters for the for loop without the need for an offset from zero. This is less confusing to write and maintain

Are you saying that such a for loop does not do what you want and, if so, what proof do you have ?

I assume that you have got a call to EEPROM.begin() in the sketch that you have not posted. Or have you ?

Please post a complete sketch that illustrates whatever problem that you are having

Which Arduino board are you using ?

The use of EEPROM.commit(); seems to indicate an emulated EEPROM like on ESP8266 or ESP32 so you also need to provide the size when calling begin

EEPROM.begin(EEPROM_SIZE);

Yes, @who_took_my_nick said in the original post he was using Esp8266 (but not not which board).

@who_took_my_nick are you aware that esp8266 has no eeprom? The data is actually written to flash memory, the same type of memory the sketch is stored. The eeprom library is provided for backwards compatibility with older types of Arduino that do have eeprom.

Writing your Strings to emulated eeprom is making life difficult, having to erase, understand the location of the start of each String, assuming maximum lengths for the Strings etc. It might be easier to store your Strings in file in flash memory. Esp has a library to emulate writing and reading files to flash memory just like an external SD card. Could this be an easier way for you?

You don't need to concatenate a line of html to send a line of html on serial.
All you need to do is fill the serial out buffer faster than it prints which in Arduino-land even 115200 baud is slow.
You don't need to add texts, just print them directly from flash in order, done.

A C++ String is a container in RAM with the text in the container accessed by the methods of the container. A pointer to String points to a container with its own text.

A C string is text chars ending with a zero whether in RAM, EEPROM, flash, SD or serial data.
A C string pointer points to data, not a container with a copy unless you code it that way.

For the most part, C strings can be treated as arrays of ASCII data, '0' + 9 == '9' == 57.
Get comfy at that level, you can process text at the char level on the fly.

AVR Optiboot allows writing to flash after bootloading.

The actual text data to copy to file, stream or memory is at .c_str(). Just an extra step....

Arduino reference.

Copy-paste from my older sketches is a very bad habit. While I pasted a part of the older sketch I lost focus on entire lines of code.

Here you can see the reason for the mysterious erasing of EEPROM.

void checkConnection(){
  if(WiFi.status() == WL_CONNECTED){
    Serial.println("Connected");
    if(WiFi.SSID()==ssid2){
        for (int i=addr_espSSID; i<512; i++){
            EEPROM.write(i,0);
            }
            Serial.println("getNewCredentials");
         getNewCredentials();
         delay(1000);
         ESP.restart();
    }
    }
  if(WiFi.status() != WL_CONNECTED){
    Serial.println("Not connected");
    x++;
    Serial.println(x);
    if(x > ssid1Limit){
      Serial.println("Restart");
      ESP.restart();
      }
    }
  delay(1000);
  }

One here said to post the whole thing. Yeah, I know I become a jerk. I thought I posted the whole thing that matters. Obviously not.

Anyway, it works for now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.