hello, can you provide your project to study it? i try but i cant do it work in real time...
@JohnnieK Use the code shown in the #6 discussion.
No app using the GPS can work instantaneously using the constellation used by the LocationSensor. The gps using the LocationSensor takes 30 to 60 seconds to acquire it's first satellite fix and subsequent fixes might be possible each successive fix at up to 10000 ms intervals. To record speed, it takes the LocationSensor to report at least two successive satellite fixes. Read about this in LocationSensor .
You can try to set the TimeInterval to 1000 ms, with unpreditable results. The TimeInterval determines the minimum time interval, in milliseconds, that the sensor will try to use for sending out location updates. However, location updates will only be received when the location of the phone actually changes, and use of the specified time interval is not guaranteed. For example, if 30000 is used as the time interval, location updates will never be fired sooner than 30000ms, but they may be fired anytime after.
Values smaller than 30000ms (30 seconds) are not practical for most devices. Small values may drain battery and overwork the GPS.
How are you trying? Are you testing on a bicycle or in a car?
i dont understand where is #6.... i am new to site how other apps in play store get speed in real time?
motorcycle, i get a speed in a few seconds but when i increase speed i dont get the speed, only after a lot seconds... i saw with android studio a project and was "real time" results. to your code i see...19km........ after a lot of sec..... 45km....... after a while 70km
Change the IntervalTime to 1000 ms and see what happens. If you do not get an improvement, you are getting the best possible using the LocationSensor that is part of App Inventor.
Did you test it or is this a description of what they claim? The newest phones have the ability to use information from several satellite constellations. The MIT App Inventor 2 control does not. If you see an improvement using another app; do so. Instead of using LocationSensor, you might have a different result using one of the extensions that are 'replacement' controls (search here App Inventor Extensions | Pura Vida Apps . Will an extension provide a better result, I do not know.
The conversation for May 6 Johnnie has the code.
i see... the app from android studio was real time, like all speedometer apps in play store, i just dont know to use Studio, it was very complicated for me and the app i made is in MIT app... so i dont know how to join them i ll try to minimize the ms and lets hope it works thanks for your time
OK. Good luck. Let us know what you discover.
Can I know How did you make your speedometer? I tried the simplest one but it doesn't work!
Welcome Xinzhi.
What did you try? Explain what is not working?
How speed works is explained here> How do we measure our speed with location.(speedometer) and did you read the posts in this post in comment #10 ?
I just wanna make a speedometer app for a bike something
Here are two ways to make a gauge (speedometer); one uses the Canvas another uses GoogleCharts Make an Analog Gauge and use it to display something useful. The example shows an Altimeter gauge; you can instead plot km/hr or miles/hr by adapting the Blocks.
Here is how the LocationSensor measures speed https://groups.google.com/g/mitappinventortest/c/OxxRsUWzwpw/m/-JlxAS49AwAJ .
Try some Blocks, if you still have issues ask again and you will get specific advice.
Some time ago I wrote an app as you describe using the Canvas. I will see if I can find the code.
Hi aia Can you share the extension?
Thanks
Extension? None is needed, see A Basic LocationSensor Speedometer
If you want to try an extension LocationSensor, try searching App Inventor Extensions | Pura Vida Apps ; there are several.
Thank you brother
this is an interesting problem to detect 0 velocity and i have no good solution to offer and also would need it in my app.
but i think the implementation of SPEED calculation is not perfected in the location sensor n appinventor and here is why i think so.
i used the location sensor speed information in parallel with my old garmin hiking GPS ETREX Vista HCx
first on the side i found a disturbing fact. the phone gives an altitude of 250 ft and garmin reads like 330ft. 330 is also what the topo map indicates, so phone altitude is off. not only in the appinventor also in other GPS app. my phone is a motorola G stylus
back to speed.
the garmin takes about 2 seconds to recognize i stopped walking. i can walk as slowly as 0.8 mi/h and it is still recognized as moving.
in my app it takes about 10sec or more to come to a 0 velocity reading and sometimes it NEVER reads 0 because it does not get a new trigger. i use the location change as trigger and the timer interval is set to 10000ms.
so clearly the garmin does an excellent job in measuring the velocity to very low speed and can quickly differentiate the stopping condition.
and the garmin uses in the conditions mentioned 8 satellites and the phone says it uses 16 out of 24 visible.
therefor i would say garmin has the better algorithm to measure speed and therefor it is possible to have a better 0 speed condition threshold. i mean to tell me within 2 seconds i am not moving is great.
i assume the gramin uses higher sampling rate and more averaging to get a better position fix.
garmin says its accuracy was 3-6 ft and phone had like 6-10m inaccuracy.
any comments?
thanks
erhard
Hi Erhard.
You need to detect 0 velocity and say you don't have a good solution to offer in your app regarding speed. The algorithm App Inventor uses to determine speed is based on using two LocationSensor changed events and is provided by Google. The algorithm requires two LocationChanged events to occur to provide a 'speed'. You might find the speedometer tutorial below interesting.
You say your phone altitude is off and note that this is not only in the app inventor but also in other GPS apps. The Garmin has a barometric altimeter; the LocationSensor uses an algorithm to estimate altitude using satellite information. It is known that altitude precision is approximate at best based on satellite information alone. See GPS versus barometric altitude – the definitive answer
You might wish to read to read about Altitude and Accuracy in Using the Location Sensor
You have a Garmin GPS receiver GPS ETREX Vista HCx eTrex Vista® HCx | Garmin . The Garmin has a high-sensitivity, WAAS-enabled GPS receiver. WAAS uses multiple ground reference stations positioned across the U.S. that monitor GPS satellite data and are used to enhance gps information. The main benefit of the WAAS is a greatly improved accuracy. Traditional GPS is accurate to 15 meters (about 50 feet) (what you get with your cell phone using the LocationSensor). WAAS-enabled GPS is accurate to less than 3 meters 95 percent of the time so your Garmin is more precise than your cell without an extension. The literature reports various estimates of accuracy and ways to achieve greater accuracy. Most of the enhanced accuracy/reliability are beyond the capabilities of App Inventor and a cell phone.
The Motorola G stylus can use the following constellations: GPS, AGPS, LTEPP, SUPL,Glonass, Galileo. The LocationSensor provided with App Inventor can only read and process GPS. There are LocationSensor extensions that can use more constellations/satellites (search for them). This means greater Accuracy can be achieved with your hardware; but not with the present software App Inventor provides. Try an extension. Will an extension help with 'speed', I doubt it but perhaps; let us know if you try using one. The gps receivers in cell phones are not known for particularly great receiving sensitivity. It is near impossible to get information w.r.t. what gps chip any device has and its specifications.
Your LocationSensor is sampling (or attempting to sample) every 10 seconds. See the comments in
[quote="SteveJG, post:27, topic:1957"]
see A Basic LocationSensor Speedometer
[/quote] regarding sampling and /speed.
I doubt it, advertising is persuasive. You like to hike. Find a benchmark and check out the location coordinates and altitude. What do you find? Close but not precise? However I suspect your Garmin is better than the LocationSensor tool used with the gps.
0 'speed' ... best determined when your feet stop trekking. Hope something here is useful.
SteveJG agree with all you rare saying. in the garmin i only used the GPS elevation not the barometer. i also checked the readout against the topo map where i am and the phone is like 100 ft off as i said. actually i do have an older G4 phone which is also off and same as newer phone.
yes i will try another extension.
thanks
erhard
i implemented the KIO4 extension and it works very well - i think as good as the garmin. that again means with the GPS data delivered internally one can make a great GPS app