event.altitude and event.speed returning wrong values

Hi there :smiley:

I’m just learning to work with the Corona SDK and stumbled across the location (GPS) section. With some help from the examples I got something running, but there are some small problems…

The event.altitude should return something between 1000 and 1050. That works right after starting the app, but after a few seconds it goes to zero and stays there. When I “minimise” the app and re-open it again, it works for a few seconds, just to go to zero again.

The event.speed is permanently at zero as well. I did the maths and turned it to millimetres/second, kilometres/hour, and a few others. It stays always exactly 0.0000 though… Sometimes I get a negative value (which is always -1 m/s or the equivalent in other units), but that is an error according to the reference.

My device is a Sony Xperia Z1 compact with Android 5.1.1 and I code on an ASUS R752M with windows 8.1 if that matters.

Is there any way to get those two working properly?

The build.settings and main.lua can be found on pastebin, because I’m not permitted to upload them here.

Thanks!

As far as speed goes, I don’t know if the GPS is accurate enough to track walking speeds, if you’re just walking around your house. Elevation should change if you change floors. There is also a second issue, if you’re testing inside a building you may be getting location services from a local WiFI router instead of the GPS. It can take a couple of minutes for the device to lock onto GPS signals and being inside makes it harder.

As far as posting code, click on the blue <> button in the row with Bold, Italics, etc. and use Copy/Paste to show code. i.e. in your editor CTRL-A CTRL-C (CMD-A, CMD-C on a Mac) then click the <> button and then CTRL-V (CMD-V) to paste the code into the window that pops up.

Rob

Oh, okay :slight_smile: I thought I made a mistake somewhere in my code and screwed the results up. Good to know that it’s rather my phone’s, router’s and satellites’ fault :smiley: thanks ^^

As far as speed goes, I don’t know if the GPS is accurate enough to track walking speeds, if you’re just walking around your house. Elevation should change if you change floors. There is also a second issue, if you’re testing inside a building you may be getting location services from a local WiFI router instead of the GPS. It can take a couple of minutes for the device to lock onto GPS signals and being inside makes it harder.

As far as posting code, click on the blue <> button in the row with Bold, Italics, etc. and use Copy/Paste to show code. i.e. in your editor CTRL-A CTRL-C (CMD-A, CMD-C on a Mac) then click the <> button and then CTRL-V (CMD-V) to paste the code into the window that pops up.

Rob

Oh, okay :slight_smile: I thought I made a mistake somewhere in my code and screwed the results up. Good to know that it’s rather my phone’s, router’s and satellites’ fault :smiley: thanks ^^