Help to send string as payload
I am pretty new to programming and Arduino. I have made a temp sensor, and all are OK, but I need to send the value to the controller as a string, or a char. How can I convert the float to a string.
I have tried with :
It converts right, but when I got the readings in the controller I got 20, if the temp actually are 23.
Maybe normally not. The Vera Controller reads the value nicely whatever which type this is. But the Vera are connected to a Control4 controller, this wants the value to be a string or int. I have managed the value to be an int, but then I do not have any decimals. So it would be nice if I could have it to be a string
Are you sure you send a correct value? Did you try printing the char-buffer before sending it?
dtostrf should be the correct function to use.
I have tried different things, the thing I have changed, is the type of value who would be send from the sensor.
The default :
gives me the following error in Control 4 :
[string "Lua Code"]:120: bad argument #1 to 'SetVariable' (strValue should be a string) (ReceivedFromProxy)
I tried to add the lines :
char charVal; //temporarily holds data from vals
and changed the send to :
But the same happens
If I cast the temperature to int I got the it, but without decimals
If I try with :
String string = "24,8"; send(msg.setSensor(i).set(string)); No error in Control4, but the sent temperature is 1