I posted this earlier today on the Google Group before seeing that these new forums were up and running
Guys
,
Still a babe in the woods with all this stuff.
Essentially i am trying to send Temperature Values (and later others) from an Arduino with DS18B20 sensors
In the first instance i receive the values and store them as INT - - i then use the following to convert them to Strings to send to the publish topic on the MQTT broker.
The Publish messages get there (and i am receiving Subscribe messages that i am listening for - so i assume my sketch is OK in that regard
Here is the relevant code
void PublishValues()
{
String temp_str;
char temp[5];
TankTemp2 = TankTemp;
temp_str = String(TankTemp2); //converting ftemp (the float variable above) to a string
temp_str.toCharArray(temp, temp_str.length() + 1); //packaging up the data to publish to mqtt whoa...
Serial.print("Publish message to MQTT on Topic/Temperature: ");//all of these Serial prints are to help with debuging
Serial.println(temp);
MQTT.publish("topic/TankTemperature", temp); //money shot
}
TankTemp is defined as an INT initially - then when i was having no luck with that i created a new float TankTemp2 and tried that
The topic on the MQTT server is gettiing the info and displaying it in the Debug Window - however it is always the same value [250, 0]
I have been searching on Google and found many answers by Nick on this - i have tried taking the +1 off the end - however that truncates what i see locally down to a single digit but still gives me the same values at the receiving end [250,0]
Not sure what i am doing wrong here - must be something very obvious - i thought perhaps the 250,0 was Binary/Hex etc - but the value never changes - even when the temperature readings do change on my Arduino.
I am using Arduino IDE 1.8.2 and the included PubSub library with it.
I have an Arduino Mega with inbuilt ethernet.
regards
Craig