Coding Help in calling a function to convert values

Not sure why you set your three variables twice. The second assignment to each of them will overwrite the previous value - so either Gga or Rmc should be used, not both IMO.

BTW, I already advised in another thread to not write it this way but rather

  Rmc rmc(_gps);

for reasons explained in that thread.

However, not exactly sure why you would want to convert the data that way.
Can you explain what you actually want with that? Then we might be able to advise how to do it “better”.

You need to consider that float cannot store any arbitrary number exactly. So even when you calculate the value correctly, you may not actually get that exact result back when you return it.

Also the .longitude and .latitude values you get from that library are of type String so you’d need to convert that first (better into double rather than float).

1 Like