Go Down

Topic: Reading an Internet String (Read 328 times) previous topic - next topic

Hi guys,

I have the following code:

Code: [Select]
void antwoord()

  for (int t=0; t <= 4; t++){

    String user = String(t);
    String ein = "<";
    String zwei = user;
    String drei = ">";
    String xxx = "/";
    String response = ein + zwei + drei;
    String endresponse = ein + xxx + zwei  + drei;

    if((http_response.indexOf(response) > -1 )&&(http_response.indexOf(endresponse) > -1 )){
      // We check if the <arduino></arduino> are there.
      response_start = http_response.indexOf(response)+3;
      // Where it begins, the 9 is the length of ' <arduino> ',
      // since we dont want it to appear in the response.
      response_end = http_response.indexOf(endresponse);
      // Where it ends
      http_response = http_response.substring(response_start,response_end);
      // We keep only the response of the website
      Serial.println("Website response : ");

      int Plus = http_response.toInt();
      int Saldo = EEPROM.read(t);
      int NewSaldo = Saldo + Plus;
      Serial.println("New Saldo: ");
      Plus = 0;
      Saldo = 0;
      NewSaldo = 0;
      http_response = 0;

    else {
      Serial.println("No response detected...");


It is supposed to take the value's between <t> and </t> and use it to add its content to the integer Saldo. This works for the first run (t=0) but after that t=1,2,3 give me no response detected.

Not sure how this happens.

Never mind, I read over the obvious mistake. http_response is ofcourse the parsed version of the orginal so calling it again will detect nothing.


You get Serial output? You don't want to share that? You want us to guess what is happening? Pass.

Serial ouput:

Code: [Select]

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131