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);
the compilation failed with error code: “Storage1:147: error: no matching function for call to ‘PubSubClient::publish(const char , float&)'”
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 where the string value is stored, the numbers are the decimals before and after the comma, but not sure about the latter