Send and decode two variables on TTN

I am using an Arduino MKR WAN 1310 to send temperaure data to TTN.

My Arduino sketch has these four lines of code to send the data to TTN.

byte payload = tempVariable;
delay(1000); // Gives it time to execute.
modem.beginPacket();
modem.write(payload);

My payload decoder on TTN has these lines.
function Decoder(bytes, port)
var decoded = ;
return [
{
“field”: “TEMPERATURE”,
“value”: bytes[0]
}
];
return decoded;
}

My question is this. How do I modify both pieces of code to send another variable such as humidity.

I have scoured the internet for clues. Articles I have found are either too complex or too simple.

Can you help?

Best wishes,

Malcolm

Please link to an example of too simple and too complex.

Then ask a question about the too simple one.

1 Like

Please format you post correctly, post your code using the </> button.

1 Like

Dear Jason and Johan,

Thank you for your prompt replies.

I think I have figured it out. I have to put multiple readings into an array, and then send the array to TTN.

I found this post on the forum which seems to work: MKRWAN.h sending a byte to TTS.

1 Like