Can't Send Word "lng" and GPS Longitude in One LoRa Transmission

Hi all,

I am trying to send the word "lng" and the longitude GPS value in one transmission over LoRa. But I can only get it to send the GPS longitude OR the word "lng".

The line that sends this is:

LoRa.print ("lng"), (gps.location.lng(), 6);

Any help with this problem would be great!

Zeb

What do you think that line of code does?

Hi gfvalvo,

I think it sends the word "lng" and the GPS longitude using a LoRa transmitter to a LoRa receiver.

Is this right?

Thanks,
Zeb

....... If it is not correct what is the correct code?

ZebH:
....... If it is not correct what is the correct code?

Hard to tell given that you didn't include a full code or tell us what class the LoRa object is a member of. Does in inherit from the 'Print' class?

Regardless, what you have there now invokes the Comma Operator which is almost never the intent of the person that writes it.

Hi gfvalvo,

The correct line of code that works for sending just the longitude is:
LoRa.print (gps.location.lng(), 6);

And the correct code that works for sending just the word "lng" is:
LoRa.print ("lng");

I am trying to combine the two commands into one command.

How would you recommend I do this?

I am trying to combine the two commands into one command.

Why?

You would be wise to take a look at Robin2's tutorial on SerialInputBasics for ways in which to format messages with start and end markers so that concatenation is really not required.

OK, thanks for the link cattledog!

ZebH:
How would you recommend I do this?

Who knows, as you have not posted your code, no-one knows which library you are using with LoRa.........

Hi all,

I have decided to stay with transmitting the values separately.

I will post what LoRa library I am using in the morning, sorry for not posting it before!

Thanks so much for all your help and patience!

Zeb

Hi again,

For reference I am using the LoRa.h library by sandeepmistry.

I made a stupid mistake of thinking that you can't send lots of LoRa.print lines like "LoRa.print (gps.location.lng(), 6);" and LoRa.print ("lng"); in one packet! You actually can!

Thanks for all your help and patience!

Zeb

It would make sense to make one packet that looks like this:

"lng 44.055697"

Or even one packet that looks like this:
"lat 53.176575 lon -35.175956"

The possibilities literally boggle the mind!

Hi jremington,

Thanks for the advice! All the possibilitys sure are mind boggling!

Zeb