I would use a char array instead of String, much less problem that way:
char buff[totalLength() + 1]; //create buffer of sufficient length to hold complete string
strcpy_P(buff, PSTR("GET /grafana.php?DHT11_Temperature="));
dtostrf(DHTtemperature, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&DHT11_Humidity="));
dtostrf(DHThumidity, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&BMP085_Temperature="));
dtostrf(BMP085readTemperature, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&BMP085_Pressure="));
dtostrf(BMP085readPressure, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2591_IR="));
dtostrf((TSL2591_IR), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2591_Full="));
dtostrf((TSL2591_Full), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2591_Visible="));
dtostrf((TSL2591_Visible), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2591_Lux="));
dtostrf((TSL2591_Lux), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2561_Visible="));
dtostrf((TSL2561_Visible), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2561_IR="));
dtostrf((TSL2561_IR), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&TSL2561_Lux="));
dtostrf((TSL2561_Lux), 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ7="));
itoa(analogRead(3), (buff + strlen(buff)), DEC); //Carbon Monoxide
strcat_P(buff, PSTR("&MQ135="));
itoa(analogRead(2), (buff + strlen(buff)), DEC); //Air Quality (CO, Ammonia, Benzene, Alcohol, smoke)
strcat_P(buff, PSTR("&MQ5="));
itoa(analogRead(1), (buff + strlen(buff)), DEC); //Natural gas, LPG
strcat_P(buff, PSTR("&MQ135_Acetone="));
dtostrf(MQ135_Acetone, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ135_CO="));
dtostrf(MQ135_CO, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ135_Alcohol="));
dtostrf(MQ135_Alcohol, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ135_CO2="));
dtostrf(MQ135_CO2, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ135_Tolueno="));
dtostrf(MQ135_Tolueno, 4, 2, (buff + strlen(buff)));
strcat_P(buff, PSTR("&MQ135_NH4="));
dtostrf(MQ135_NH4, 4, 2, (buff + strlen(buff)));
Serial.println(buff);
The total length of the string is calculated in a function:
int totalLength() {
int sum = 280; //start with total length of all fixed text
char nbuff[15]; //needs to be long enough to hold longest float
//all floats are converted to text with a minimum length of 4 and 2 decimal places
sum += strlen(dtostrf(DHTtemperature, 4, 2, nbuff));
sum += strlen(dtostrf(DHThumidity, 4, 2, nbuff));
sum += strlen(dtostrf(BMP085readTemperature, 4, 2, nbuff));
sum += strlen(dtostrf(BMP085readPressure, 4, 2, nbuff));
sum += strlen(dtostrf((TSL2591_IR), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2591_Full), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2591_Visible), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2591_Lux), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2561_Visible), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2561_IR), 4, 2, nbuff));
sum += strlen(dtostrf((TSL2561_Lux), 4, 2, nbuff));
sum += strlen(itoa(analogRead(3), nbuff, DEC));
sum += strlen(itoa(analogRead(2), nbuff, DEC));
sum += strlen(itoa(analogRead(1), nbuff, DEC));
sum += strlen(dtostrf(MQ135_Acetone, 4, 2, nbuff));
sum += strlen(dtostrf(MQ135_CO, 4, 2, nbuff));
sum += strlen(dtostrf(MQ135_Alcohol, 4, 2, nbuff));
sum += strlen(dtostrf(MQ135_CO2, 4, 2, nbuff));
sum += strlen(dtostrf(MQ135_Tolueno, 4, 2, nbuff));
sum += strlen(dtostrf(MQ135_NH4, 4, 2, nbuff));
return sum;
}
Although its best to avoid the large buffer and print everything individually. Might be better to use dtostrf() and itoa() instead of letting print() convert the numbers, just in case there is a length difference.
Serial.print(F("total length of string: "));
Serial.println(totalLength());
Serial.print(F("GET /grafana.php?DHT11_Temperature="));
Serial.print(DHTtemperature, 2);
Serial.print(F("&DHT11_Humidity="));
Serial.print(DHThumidity, 2);
Serial.print(F("&BMP085_Temperature="));
Serial.print(BMP085readTemperature, 2);
Serial.print(F("&BMP085_Pressure="));
Serial.print(BMP085readPressure, 2);
Serial.print(F("&TSL2591_IR="));
Serial.print((TSL2591_IR), 2);
Serial.print(F("&TSL2591_Full="));
Serial.print((TSL2591_Full), 2);
Serial.print(F("&TSL2591_Visible="));
Serial.print((TSL2591_Visible), 2);
Serial.print(F("&TSL2591_Lux="));
Serial.print((TSL2591_Lux), 2);
Serial.print(F("&TSL2561_Visible="));
Serial.print((TSL2561_Visible), 2);
Serial.print(F("&TSL2561_IR="));
Serial.print((TSL2561_IR), 2);
Serial.print(F("&TSL2561_Lux="));
Serial.print((TSL2561_Lux), 2);
Serial.print(F("&MQ7="));
Serial.print(analogRead(3)); //Carbon Monoxide
Serial.print(F("&MQ135="));
Serial.print(analogRead(2)); //Air Quality (CO, Ammonia, Benzene, Alcohol, smoke)
Serial.print(F("&MQ5="));
Serial.print(analogRead(1)); //Natural gas, LPG
Serial.print(F("&MQ135_Acetone="));
Serial.print(MQ135_Acetone, 2);
Serial.print(F("&MQ135_CO="));
Serial.print(MQ135_CO, 2);
Serial.print(F("&MQ135_Alcohol="));
Serial.print(MQ135_Alcohol, 2);
Serial.print(F("&MQ135_CO2="));
Serial.print(MQ135_CO2, 2);
Serial.print(F("&MQ135_Tolueno="));
Serial.print(MQ135_Tolueno, 2);
Serial.print(F("&MQ135_NH4="));
Serial.print(MQ135_NH4, 2);
Serial.println();
Note that the DHT and BMP085 readings have been stored in variables, this is necessary if you want to calculate the length separate from the printing, otherwise the values may change and alter the length of the text. You would also need to do this for the readings from the analog inputs.