Grabbing all digits of a number from ethernet client.read() -- Please Help

Hello everyone!

I have again spent hours trying to figure this out myself but I can’t :(.

So what I am trying to do is grab ALL the digits (numbers) from a php file using client.read(). I was helped out earlier by SurferTim who had suggested to me a way of grabbing multiple value from different sources on the network. So I took his suggestions and it worked.

But now what I have noticed is that if my PHP’s output is “999” the code below only returns “9” (if I declare as char and I believe the ASCII number if I declare as int).

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};

EthernetClient client;
//char server[] = "192.168.1.101";//Provide server to scrape data from
IPAddress server(192,168,1,101);//Provide server to scrape data from****
char serverName[] = "192.168.1.101";//Provide server to scrape dat from*****

int totalCount = 0;//****
char pageAdd[64];//*****
// set this to the number of milliseconds delay
// this is 30 seconds
#define delayMillis 30000UL
unsigned long thisMillis = 0;//****
unsigned long lastMillis = 0;//****

void setup()
{
  Serial.begin(9600);
  // Start ethernet
  Serial.println(F("Starting ethernet..."));//*****
  Ethernet.begin(mac);
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
  delay(2000);//****
  Serial.println(F("Ready"));//****
  
}

void loop(){
  thisMillis = millis();

  if(thisMillis - lastMillis > delayMillis)
  {
    lastMillis = thisMillis;

    strcpy(pageAdd,"/ali1.txt");
    
    char digits = getPage(server,80,pageAdd);//If I do "int digits = ..." then I believe I get the ASCII, but with char I only see the last value
    Serial.print(digits);//this only returns the LAST digit
  } 

}


byte getPage(IPAddress ipBuf,int thisPort, char *page)
{
  int inChar;
  char outBuf[128];

  Serial.print(F("connecting..."));

  if(client.connect(ipBuf,thisPort))
  {
    Serial.println(F("connected"));

    sprintf(outBuf,"GET %s HTTP/1.1",page);
    client.println(outBuf);
    sprintf(outBuf,"Host: %s",serverName);
    client.println(outBuf);
    client.println(F("Connection: close\r\n"));
  } 
  else
  {
    Serial.println(F("failed"));
    return 0;
  }

  // connectLoop controls the hardware fail timeout
  int connectLoop = 0;

  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)
    {
      // then close the connection from this end.
      Serial.println();
      Serial.println(F("Timeout"));
      client.stop();
    }
    // this is a delay for the connectLoop timing
    delay(1);
  }

  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();

  return inChar;//Returns the digits
}

So as you can see in the code, I can’t get all the digits :(. So basically I believe that what I will have to do is convert each client.read() byte to an integer using atoi(). But I can’t get it to work. I had changed an existing code by Mr. Nick Gammon to do that. But can anyone give me some tips/example code here? Much thanks guys!

    char digits = getPage(server,80,pageAdd);

How many characters can you store in ONE character? Of course you only get one.

getPage() can not return an array. You could make the function take one more argument that is the address of the array that it is to write to.