I'm playing with Arduino and I want to compare the string coming from a MQTT message.
This is my code to catch the incoming messages:
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
int i=0;
for (i=0;i<length;i++) {
Serial.print((char)payload[i]);
}
Serial.println();
Serial.println((char)payload[0]);
if(topic==topic_conmutador){
if(strcmp((char*)(payload[0]), "0")==0)
digitalWrite(built_in_PIN, LOW);
}
}
The line if(strcmp((char*)(payload[0]), "0")==0){
is giving me this error message:
error: invalid conversion from 'byte {aka unsigned char}' to 'const char*' [-fpermissive]
What am I doing wrong? I just want to check if the first character of the incoming message is a 0.