Converting string to multiple floats

Im using 2 boards with esp8266. On first one Im connecting 2 sensors that give me 4 different floatables (temperature, humidity, co2 and voc level) and Im converting those 4 variables to strings and sending them to the second board that should receive the data and fill the excel sheet with it. For this I need to convert the string I receive back to those 4 variables so I can do some calculations with them in the excel later on. I set up my task in few parts and Ive got them all working separately - filling the excel sheet with sensors connected directly to second board, sending random string from first board to second one and back,etc…
The part that Im struggling with is parsing the string I receive that contains those 4 variables so I can fill excel with those 4 values.
This is my code from receiver side:

#include <ESP8266WiFi.h>
#include <DHT.h>
#include <rExcel.h>

char ssid[] = "xxx           
char pass[] = "xxx;               
WiFiServer server(80);                    

IPAddress ip(192, 168, 0, 80);            
IPAddress gateway(192,168,0,1);           
IPAddress subnet(255,255,255,0);          

long          idx = 0;                

float h,t,c,v;

char          value[16];              

rExcel        myExcel;                

void setup() {
  Serial.begin(115200);                   
  WiFi.config(ip, gateway, subnet);       
  WiFi.begin(ssid, pass);                 
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  server.begin();                         
  
  //rx buffer clearing
  myExcel.clearInput();  
}

void loop () {

  WiFiClient client = server.available();
  if (client) {
    if (client.connected()) {
      Serial.println("U petlji");
      String hum = client.readStringUntil('\r');
      Serial.println(hum);
      h = hum.toFloat();
      delay(100);
      String tem = client.readStringUntil('\r');
      Serial.println(tem);
      t = tem.toFloat();
      delay(100);
      String co2 = client.readStringUntil('\r');
      Serial.println(co2);
      c = co2.toFloat();
      delay(100);
      String voc = client.readStringUntil('\r');
      Serial.println(voc);
      v = voc.toFloat();
      delay(100);
      client.flush(); 
    }
    
    myExcel.write("Example", "B5", h, 2);                  
    myExcel.write("Example", "B6", t, 2);                  
    myExcel.write("Example", "B7", c, 2);
    myExcel.write("Example", "B8", v, 2);

    myExcel.writeIndexed("Example", idx+11, 1,"%date%");    
    myExcel.writeIndexed("Example", idx+11, 2,"%time%");    
    myExcel.writeIndexed("Example", idx+11, 3, idx);        
    myExcel.writeIndexed("Example", idx+11, 4, h, 2);      
    myExcel.writeIndexed("Example", idx+11, 5, t, 2);     
    myExcel.writeIndexed("Example", idx+11, 6, c, 2);
    myExcel.writeIndexed("Example", idx+11, 7, v, 2);
    
    idx++;
  
    if (idx > 731) {
   
      myExcel.clear("Example","A11:H731");                                  
      myExcel.save();
      
      idx = 0; 
    }
    client.stop(); 
  }
}

And here is the code from sender side:

#include <ESP8266WiFi.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11   
#include <Adafruit_CCS811.h>
Adafruit_CCS811 ccs;
float co2,voc,hum,tem;

char ssid[] = "xxx          
char pass[] = "xxx            

unsigned long askTimer = 0;

IPAddress server(192,168,0,80);       
WiFiClient client;
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);               
  WiFi.begin(ssid, pass);             
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  dht.begin();
  ccs.begin();
}

void loop () {
  client.connect(server, 80);  
  
  hum = dht.readHumidity();
  tem = dht.readTemperature();
  if(ccs.available()){
        if(!ccs.readData ()){
            co2 = ccs.geteCO2();
            voc = ccs.getTVOC();
             }}
  
  if(!isnan(hum))
  {
  String h = String(hum);
  client.println(h);
  client.print("\r");
  delay(100);
  String t = String(tem);
  client.println(t);
  client.print("\r");
  delay(100);
  String c = String(co2);
  client.println(c);
  client.print("\r");
  delay(100);
  String v = String(voc);
  client.println(v);
  client.print("\r");
  delay(100);
  client.flush();
  }
  delay(14600);            
}

On first one Im connecting 2 sensors that give me 4 different floatables

floatable is NOT a type.

Im converting those 4 variables to strings

Liar.

  String h = String(hum);
  String t = String(tem);
  String c = String(co2);
  String v = String(voc);

Not a string in sight.

The part that Im struggling with is

The part I'm struggling with is understanding what the problem is. The code does something, but you didn't tell us what it actually does. We know what you expect, but not how that expectation differs from reality.

You could dispense with Strings altogether, and use dtostrf() on the sender end.

If you really can't stand without crutches, at least use Strings smartly.
String h(hum);
will create a String object wrapping the value in hum converted to a string.

What you are doing is creating a String object wrapping the value in hum converted to a string, then invoking the copy operator (=), then destructing the original. A useless waste of resources.

On the receiving end, you could use the parseFloat() method, without needing to extract each token from the stream in the worst possible way.

Just how I do it (Im not going to analyse your code)

  1. send those variables with a specific "discriminator" between, for example for variables 100.1 - 2.4 - 5 - 5
    send "100.1,2.45,5,5" . (discriminator is comma)
    2 better to decide sending definately decimals, even if they are zeroes (that is for including "dot") i.e. "100.10,2.45,5.00,5.00" .
    3 after reception, add 3-4 spaces on receined String.

4 use indexOf() to locate two subsequent commas. In between is your variables
5 use indexOf() again to locate the dot in the field
6 use int IntVal= substring().toInt() from first comma of field up to dot (inclusive) to get Integer part
7 use int DecVal= substring().toInt() from dot+1 of field up to second comma (inclusive) to get decimal part (in Integer form)

8your variable is : float val= (float)Intval + (float)DecVal/(10*[second comma position-(dotposition-1)] )

9 continue for next variable from step 4

Read the use of indexOf() and substring().
play a little with this and you have it

PaulS lol.
I think Im staring to get the problem which if it wasnt clear is: I only get 0s as values in exel sheet from my code and I presume the problem was with the part of code that should convert string to float.
Thanks for the dtostrf(), It didnt come to mind tbh. Ill give it a go with your tips and let You know what happens.

P.S.

I see now that dtostrf() requires number of characters to convert. My problem is that CO2 and Voc can vary in that manner (can be 400.00 but also 1187.00). Is there any way around this?

Is there any way around this?

It seems unlikely that the number will exceed 1000000000000.00, doesn't it? Determine the largest possible value that you can have, and count the number of characters in the string, before and after the decimal point. Add 2, for the decimal point and for the terminating NULL. Use that value as the size of the char array.