mDot Box – Sending Data Through LoRa

Home Forums mDot/xDot mDot Box – Sending Data Through LoRa

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25633
    Nick
    Participant

    I’ve been sifting through various code examples on how to send data through LoRa but coming up a little short. I have been following the code for the mDot Box since it is sending decimal numbers and they are being received on NodeRed on my conduit. We will be sending data in a very similar fashion.

    I understand the data has to be packaged in a vector of type uint8_t, what I am having a difficult time understanding is how it takes a float value (say 12.3456), cast that data as uint8_t elements in a vector and how to translate back into the original float value on the receiving end.

    If anyone can shed some light on this, that would be a huge help. One idea I had was to multiply my float value by 100, 1000, etc. and store that integer value in the vector, send it, and divide it back into it’s decimal value. This method seems easier, however I know the person that wrote the code for the mDot Box is smart and did it for a reason.

    Thanks!

    #25675
    Nick
    Participant

    Just and update to this. I tried a few experiments to crack this one. One of the easiest methods I found was to utilize a union to create a byte-array to send via LoRa. On the other end (MT Conduit LoRa Gateway) I had to do some bit shifting into a new array (in JavaScript) to get back to the true integer value.

    On a side note, I sent the Analog.Read value as the uint_16 value via LoRa since it was easier than translating the float value in Node-RED. It’s quite simple math to convert the analog value to our true measurement value, but I figured performing the math at the Conduit (not battery powered) would be fundamentally correct since we want to conserve as much power on the mDot as possible (though probably not much).

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.