This is derived from working code:
uint8_t payload[30]; // Allow for up to 30 byte payload, increase/decrease as appropriate
uint8_t payloadSize;
// Take & process readings
float degC = readTemperatureTo2DP();
uint16_t tempToSend = (uint16_t) ((degC +100) * 100);
// Add bytes to payload
payload[0] = highByte(tempToSend);
payload[1] = lowByte(tempToSend);
payloadSize = 2;
// Transfer to modem
modem.beginPacket();
for (uint8_t c = 0; c < payloadSize; c++) {
modem.write(payload[c]);
}
err = modem.endPacket(confirmed);
Passing one byte at a time could possibly be refined but the MKRWAN library using Templates and other sophistications isn’t something I want to mess with. It works, but it’s not the best DIY device around as it’s a bit pricey and hard to get below 40uA when asleep.