Open mshaz opened 2 years ago
Hi I m a newbie in coding, I have an error when trying to publish mqtt. Please help.
The initial serial code without client.publish works fine and the output is like below;
0 1 1 1 0 0 0 0 0
My code:
void loop() { byte n = SUART.available(); if (n != 0) { char x = SUART.read(); Serial.print(x); client.publish(mqtt_topic,x);
}
error message: exit status 1 invalid conversion from 'char' to 'const char*' [-fpermissive]
Hi mshaz,
You can 'typecast' your char into a const char* like this:
client.publish(mqtt_topic,x); ->> client.publish(mqtt_topic, (const char*) x);
Hope this helps you.
Tiepolino
Hi I m a newbie in coding, I have an error when trying to publish mqtt. Please help.
The initial serial code without client.publish works fine and the output is like below;
0 1 1 1 0 0 0 0 0
My code:
void loop() { byte n = SUART.available(); if (n != 0) { char x = SUART.read(); Serial.print(x); client.publish(mqtt_topic,x);
}
}
error message:
exit status 1 invalid conversion from 'char' to 'const char*' [-fpermissive]