Ethernet client - get optimization.

Hi everyone,

I have the attached code and send some temperature and humidity value to a php script on a server.
Can someone help me, guide me to optimize the code? can I write it in a more compact way? special the "get" part
Thank you

void loop() {
  if (((currentTime = millis()) - previousTime) >= reportingPeriod) {
 h30 = dht30.readHumidity();
    t30 = dht30.readTemperature();
    h31 = dht31.readHumidity();
    t31 = dht31.readTemperature();
    h32 = dht32.readHumidity();
    t32 = dht32.readTemperature();
    h33 = dht33.readHumidity();
    t33 = dht33.readTemperature();
    h34 = dht34.readHumidity();
    t34 = dht34.readTemperature();
  h35 = dht35.readHumidity();
    t35 = dht35.readTemperature();
    EthernetClient client;
if (client.connect("192.168.1.25", 80))
    {
      client.print("get /DistribuitorEtaj.php?CSET=");
      client.print(t30);
      client.print("&CSEH=");
      client.print(h30);
      
      client.print("&CHET=");
      client.print(t31);
      client.print("&CHEH=");
      client.print(h31);

      client.print("&CBET=");
      client.print(t32);
      client.print("&CBEH=");
      client.print(h32);

      client.print("&CMET=");
      client.print(t33);
      client.print("&CMEH=");
      client.print(h33);

      client.print("&CGET=");
      client.print(t34);
      client.print("&CGEH=");
      client.print(h34);

      client.print("&DET=");
      client.print(t35);
      client.print("&DEH=");
      client.print(h35);

      client.print("&CSE=");
      client.print(CSE);
      client.print("&CHE=");
      client.print(CHE);
      client.print("&CBE=");
      client.print(CBE);
      client.print("&PPE=");
      client.print(PPE);
      client.print("&CME=");
      client.print(CME);
      client.print("&CGE=");
      client.print(CGE);
      client.println (" HTTP/1.1"); 
      client.println("Host: 192.168.1.25"); // SERVER ADDRESS HERE TOO
      client.println();
    
    }
    // read the sensors
    // send the GET request to your PHP service

    previousTime = millis();
    Serial.println(previousTime);
  }

:frowning:

Well, with HTTP GET you can have a huge string. Some browsers limit it to 2KB. Your web server may also have a limit.
What are you doing with the data on the PHP side ? putting it into an SQL table ?
If your SQL table has huge long rows, then leave the GET statement as it is. If not, then break your GET statement down so you send data which more or less corresponds with one row in the table. That may mean sending multiple GET statements to cover all your sensors.

Post your PHP script and maybe the structure of the receiving table(s) for more suggestions.

Arrays and for loops.
Arrays and for loops.
Arrays and for loops.
Arrays and for loops.
Arrays and for loops.
Arrays and for loops.
Arrays and for loops.