Send double/float data via OTAA


(Yamaha) #1

Hello Everyone,

I want to send double or float data via OTAA the given example is sending just a string and character array.

Can somebody please tell me how can i send double value via lora packet ? for example ( temp or gps)

I have tried different type casting but it’s not working . Please advice

thanks in advance


#2

what node are you using? off the shelf or one of your own and have access to the code?

There are multiple ways to do this depending on the precision needed and number of bytes you want to send.

Andrew


(Yamaha) #3

I am using Seeeduino LoraWan w/gps and yes i have access to the code

No need for multiple ways … the easiest way is enough :smile:


(Arjan) #4

I’d suggest you read about LoRaWAN first, and then search this forum. OTAA is unrelated to sending any data, and you cannot expect people to list all options without even telling us what you’ve tried.


#5

Check my blog http://talk2lora.blogspot.com, last post explains some of what you want to do in detail:
In particular this page: http://talk2lora.blogspot.com/2016/11/building-iot-temperature-sensor-episode_27.html


(Brady Aiello) #6

Try this out. Make sure to use the included payload function. It glues the bytes back together in the right order to compensate for the difference in endianess of the Seeeduino and TTN. https://github.com/brady-aiello/Seeeduino_LoRaWAN_for_hybrid_gateways/tree/master/Seeeduino-LoRaWAN-GPS-app


(Brady Aiello) #7

Unions work well for sending LoRa packets from C. If you’re using Python / Micropython, struct-packing is the way to go. It keeps the message size small.


(Georousseau) #8

good example, thanks. and good blog


(Garrymacin) #9

Decimals have much higher precision and are usually used within financial applications that require a high degree of accuracy. Decimals are much slower (up to 20X times in some tests) than a double/float. Decimals and Floats/Doubles cannot be compared without a cast whereas Floats and Doubles can. Decimals also allow the encoding or trailing zeros.

Float - 7 digits (32 bit)

Double-15-16 digits (64 bit)

Decimal -28-29 significant digits (128 bit)

The main difference is Floats and Doubles are binary floating point types and a Decimal will store the value as a floating decimal point type. So Decimals have much higher precision and are usually used within monetary (financial) applications that require a high degree of accuracy. But in performance wise Decimals are slower than double and float types.


(Arjan) #10

While true, this applies to programming languages that have a dedicated Decimal type, like .NET in the article you’re linking to. I don’t think many, if any, LoRaWAN nodes will use that. Even if they do, while designing a LoRaWAN application one should consider if that precision makes any sense. 128 bits for a .NET Decimal is a whopping 16 bytes for a single value. In LoRaWAN devices quite often floats are first converted into an integer using some multiplication, to keep a limited number of decimal digits, after which only 2 or 4 bytes are transmitted.