Compilation error: expected ',' or ';' before 'String'

int h = dht.readHumidity();
int t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
timeClient.update();

String day = daysOfTheWeek[timeClient.getDay()];
String formattedTime = timeClient.getFormattedTime();
String formattedDayTime = " "String(day) + String(",") + String(formattedTime)" ";
String fireHumid = " "formattedDayTime + String(": Nem: ") + String(h) + String("%")" ";
String fireTemp = " "formattedDayTime + String(": Sicaklik: ") + String(t) + String("C")" ";

hatayı nasıl düzeltebilirim?

  • isnan(h) -> h is an integer. Every possible value is a number. Your check will never trigger
  • " "String(day) -> try String(" ") + String(day)

Please use English in the main forum category

Please edit your post, select all code and click the <CODE/> button. This will apply code tags which make your codee easier to read, easier to copy and the forum software will display it correctly. See How to get the best out of this forum.

In future please post complete sketches that can be tested without us having to guess what the missing parts are. If a sketch is too big (your opinion) you can write a minimal sketch that exhibits the undesired behaviour.

Please post complete error messages if any and describe expected behaviour and actual behaviour.

Please read How to get the best out of this forum.

1 Like

each string needs to be separate by a "+"

String formattedDayTime = " " + String(day) + String(",") + String(formattedTime) + " ";

but this could simply be

String formattedDayTime = " " + day + "," + formattedTime + " ";

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.