Closed Antonzlo closed 4 years ago
Hi @Antonzlo,
// use the Stream interface to print the contents
while (mqttClient.available()) {
Serial.print(String(mqttClient.read()));
}
if (String(mqttClient.read()) == String(48)){
This won't work, because when you loop though the data, the first time, mqttClient.read()
will return -1 because the data is all read.
I would suggest:
String data = mqttClient.readString();
if (data.length() == 1 && data[0] == 48){
// ...
} else {
// ...
Please let us know if you still have issues. I'll close this issue for now, as I think I've answered your concerns.
Hello! I want to create smart IoT lamp. But, if I try to use if() function, I do not understand results. My loop function:
In serial, I do receive values, but cant compare them in if():