In TinyGPS program, I want to make a string which includes all parameter like as count, lng, lat, speed, altitude and time) . How can I do this string ?
Depending on the radio protocol in use, it is often essential to send a complete string (or char array or whatever) without any gaps. Gaps can cause the fm sync to fail. Even if gaps are tolerated by using a suitable protocol, it is often desirable to keep the radio packet as short as possible for several reasons.
I will send data serially. I will use a transceiver module.But I thik that I must put a comma between each parameter (i.e lat value, lng value, time, etc) because it must be easy to separate in receiver side.
So, if I can different types of data which some of them ints, some of them chars, etc, how can I do string ? When I use struct command, how can I send this struct ?
This works for any struct that contains ints, floats, chars, or arrays of those things (no pointers).
At the receiving end, it would copy the received bytes back onto a structure in a similar way (depending on your transceiver and library). This is also called a "binary" message. As sterretje says, it requires the exact same structure definition on the sender and receiver.
It is more difficult to debug a binary message, so I usually recommend a text message first, like your comma-separated values message. These are easy to print and see on the Serial Monitor. Binary messages are all kinds of ugly on the Serial Monitor... you have to print the HEX values instead.
But if you didn't get the hint, "What transceiver and library are you using?"
Can't find out what type gps.location.lat() returns (I have poor internet connection at the moment) but if you want 6 decimal places (plus 3 whole number places) for a latitude / longitude then an Arduino 'float' will be no good to you, it only has 6-7 significant figures in total. So best to transmit these as strings.
Can't find out what type gps.location.lat() returns
class TinyGPSPlus
{
public:
TinyGPSPlus();
bool encode(char c); // process one character received from GPS
TinyGPSPlus &operator << (char c) {encode(c); return *this;}
TinyGPSLocation location;
OK, thanks, so it is just floats. With a four-byte float for lat & long that gives a resolution of about 100 metres worst case. Good enough for many applications I suppose.