Hi there,
I’m working on this tutorial MQTT Tutorial for Raspberry Pi, Arduino, and ESP8266 - Bald Engineer
I’m confused with the byte* payload in the callback function becoming (char)payload*;*
Is the (char) before payload*; is a kind to convert data from payload parameter to char?*
Any help would be appreciated.
Here the code:
*_ <em>*void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i=0;i<length;i++) { char receivedChar = (char)payload[i]; Serial.print(receivedChar); if (receivedChar == '0') // ESP8266 Huzzah outputs are "reversed" digitalWrite(ledPin, HIGH); if (receivedChar == '1') digitalWrite(ledPin, LOW); } Serial.println(); }*</em> _*
Moderator edit: I’m fed up of asking people to use CODE TAGS.