Problem with variable size sent by GET to arduino.

Hi, I am a newbie in arduino, and I wonder surely this will have a very simple solution.

I have a Webserver on Arduino Nano, to send Get data runs smoothly except when exceeded a certain amount of characters, put example:

If the request is this works:

xx.xx.xx.xx/?ID=12345678aeiou

if(cadena.substring(posicion)==("ID=12345678aeiou"))
          {
            digitalWrite(led,HIGH);
            delay(1000);
            digitalWrite(led,LOW);
           }

But if the request is greater fault:

xx.xx.xx.xx/?ID=12345678aeioufhgjkmnlpqrstuwxyz

if(cadena.substring(posicion)==("ID=12345678aeioufhgjkmnlpqrstuwxyz"))
          {
            digitalWrite(led,HIGH);
            delay(1000);
            digitalWrite(led,LOW);
           }

Thanks for the help.

Please post code when you have a problem like that.

You could be overflowing an array or running out of SRAM. If that is a String data type, I presume running out of SRAM.

The String class is more RAM-heavy than char* strings, and running out of memory can have various and confusing symptoms.

Without the whole sketch answers are just guesswork though, the fault might lie elsewhere from where you suspect.

If you are looking for a match and don't want to allocate more strings, rather than call substring and compare, use indexOf which doesn't allocate:

if (cadena.indexOf ("ID=12345678aeioufhgjkmnlpqrstuwxyz") == posicion)

SurferTim: Please post code when you have a problem like that.

You could be overflowing an array or running out of SRAM. If that is a String data type, I presume running out of SRAM.

MarkT: The String class is more RAM-heavy than char* strings, and running out of memory can have various and confusing symptoms.

Without the whole sketch answers are just guesswork though, the fault might lie elsewhere from where you suspect.

If you are looking for a match and don't want to allocate more strings, rather than call substring and compare, use indexOf which doesn't allocate:

if (cadena.indexOf ("ID=12345678aeioufhgjkmnlpqrstuwxyz") == posicion)

Exactly, the problem was the SDRAM. I reduced the number of strings declared in the code and I solved.

Thanks very much.