I'm using Arduino as a UDP client to send information about values read from sensors.
I'd like to send packets like:
"string1=value1"
where value1 is an integer read from Arduino analog pins.
The problem is that udp.write() only takes as parameter char arrays, so i can't sum a string to an integer and then pass the new string to udp.write().
I have to concatenate a char array to an integer value and then pass the array to the udp.write() function.
At the moment, i'm using dtostrf(FrontSonar_Reading,1,2,temp);
in order to save the integer value in the "temp" array char, but i do not know how to concatenate this result to the array char.
Actually, I have something like:
char string1[] = "string1=";
void loop(){
//...
dtostrf(FrontSonar_Reading,1,2,temp);
Udp.beginPacket(remoteIp, remotePort);
Udp.write(string1);
Udp.write(temp);
Udp.endPacket();
}
it works, but it sends two packets; i'd like to send just one packet with the string and the integer at the same time.
Is it possible?