So I am currently trying to send a temperature value (a string) over mqtt, but the Arduino IDE keeps complaining about "invalid conversion from 'int' to 'const char*' [-fpermissive] and I can't figure out how to convert my str value to a char. Can anybody help me?
This is the last part of my code, I am strugling with (the last part is what is messing me up):
/----------------Read data--------------/
byte temperature = 0;
byte humidity = 0;
if (dht11.read(pinDHT11, &temperature, &humidity, data)) {
return;
}
for (int i = 0; i < 40; i++) {
if (i > 0 && ((i + 1) % 4) == 0) {
}
}
/---------------Send data---------------/
client.publish(outTopic, (int)temperature); [This is where the error orccurs]
}
Does anyone know a easy way to convert a str to a const char?
So I am currently trying to send a temperature value (a string) over mqtt, but the Arduino IDE keeps complaining about "invalid conversion from 'int' to 'const char*' [-fpermissive] and I can't figure out how to convert my str value to a char. Can anybody help me?
Your "str value" isn't a str(ing) value but a simple integer.
You can convert the integer to a a C string using the ita function.
Are you sure 'dht11.read()' takes a pointer to a byte? If it's expecting a pointer to an int, it will write beyond the byte's memory and cause undefined and unexpected behavior.
You can declare base per the function call (have you tried googling your new instruction or reading DKWatson's reply?) or leave it as 10 as was originally posted.
I'm doubting you are getting the same error. Which error do you have now?
Have you looked up (googling, read or otherwise) the parameters required by client.publish()? I don't know what they are as I don't know what it is related to since only a code snippet was provided.