I have 3 variables declared as character arrays in arduino: id, temp, humidity.
How could I append them and write them as a string separated by commas.
For example: id:12,temp:23,humidity:50
This is my code so far.
Kind regards
char id[2];
char humidity;
char temp[2];
string example;
void setup()
{
//setup stuff
}
void loop(void)
{
// Receive message
e = sx1272.receivePacketTimeout(10000);
e = sx1272.getRSSIpacket();
Serial.println(e, DEC);
if( sx1272.packet_received.length < 14 )
{
Serial.println("Missing data");
}
else
{
id[0] = sx1272.packet_received.data[0];
id[1] = sx1272.packet_received.data[1];
humidity = sx1272.packet_received.data[4];
temp[0] = sx1272.packet_received.data[9];
temp[1] = sx1272.packet_received.data[10];
}
example = String.format("id:%c,crc:%c,humidity:%c)", id, crc, humidity);