Hi
I’m using DS18B20 temperature sensor.
My goal is to read the sensor data and publish it using client.publish command.
char temperature = sensors.getTempCByIndex(0);
client.publish(“home/storage/esp1/tsensor1”, temperature);
the compilation failed with error code: “Storage1:147: error: no matching function for call to ‘PubSubClient::publish(const char [27], float&)'”
Please help!
Solved thanks to Gertjan Assies. Looks like the getTempCBYIndex returns a float, while the PubSubClient wants something else (a string probably)
Use this command to convert float to string: dtostrf(tempC, 2, 2, temperatureCString);
where tempC is the value you get from the sensor, and temperatureCString a char[6] where the string value is stored, the numbers are the decimals before and after the comma, but not sure about the latter