1

I am sending strings to an Esp8266 via web browser.

The below code returns the following in serial monitor if I send in browser:

Send from browser to esp8266 - http://192.168.1.220/s1s2s3s4s5d1
Receive in Arduino Serial monitor - GET /s1s2s3s4s5d2 HTTP/1.1

How do i read only the contents s1s2s3s4s5d1 ? This content can vary in length, numbers could be double digits but alphabets will remain in between.

Please note I am still a novice.

// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
  • google arduino parsing strings – jsotola Jan 2 at 17:55
  • Thanks, i have tried to implement some methods unsuccessfully. i simply do not have the experience especially since the content required varies in length. i was hoping to get an example if possible. – S B Jan 2 at 18:00
  • do you have any control over the URL format ....maybe you need to use something like 192.168.1.220?s=1&s2=4&s3=8&d=1&abcd=1234 – jsotola Jan 2 at 18:11
  • will this method retain the letters or does it strip to numbers? – S B Jan 2 at 18:55
0

I have this

if (client.connected()) {
  if (client.available() && client.find(' ')) { // GET /fn HTTP/1.1
    char fn[20];
    int l = client.readBytesUntil(' ', fn, sizeof(fn));
    fn[l] = 0;
    while (client.read() != -1);
    Serial.println(fn);
    client.stop(); 
  }
}
  • Thank you, will apply solution and revert. – S B Jan 2 at 18:54
  • @s-b, did it help? – Juraj Jan 29 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.