hi I am having trouble with a packet decoder in TTN I cannot figure any help would be appreciated. My data is put into a 16-byte message on a LoRaWAN Arduino device
They are all 16-bit uint16_t (temp & hum) I encode them like so:
It looks like you are putting the bytes in in the payload the other way around (byte 0 low byte of int, byte 1 high byte of int). However it is hard to say without seeing the relevant part of the Arduino sketch.
BTW, you are sending far too often. You are allowed 30 seconds of airtime a day, sending every 15 seconds violates the FUP and might even exceed legal limits (the ones that result in fines or jail time).
You may find that we’re very very reluctant to help when you didn’t change your uplink time in the code you posted - please can you reassure us that you have dialled back to ~3 minutes which would be OK(ish) for that size of payload. Note, larger payloads will need longer delays.
I’ve not seen this implementation before - what is the device, firmware, version numbers and why use a packed struct which I’d only use to move data between C & Python. A simple byte array usually does the job - otherwise you’ll need to look at how it’s packed and decode accordingly.
This does not match your decoder. First of all your humidity is just one byte, not two. Then the next hurdle is the way your compiler packs the structure and the order of bytes used by the controller, all things that you can not control and do not match your (current) assumptions.
I would advice to use a byte array and putting the values ‘manually’ at the position you want them. That way you control what goes where and do not run into issues when you start using another device where the architecture differs and the compiler behaves differently.
Apart from the never say never idiom, there’s also that it’s not much of a solution if it’s not future proof - and with global warming someone else may be helped out if you show how to do that.