Sending continuous phone (Android) precise gps location updates over bluetooth

Well folks you are awesome!!!
@SteveJG You were right. I tested with a PIE phone and it worked like it was supposed to. Then I got the broken pip message (That was because I was using USB power and it was not enough juice)!
@Taifun you have been very supportive and I appreciate it as well.

Sigh.....So, what it looks to be is that App Inventor cannot provide what i am looking for. The updates tranmitted would be too slow for Android 12+ and App Inventor needs a facelift to get things on track.i could take the literal gps strings and parse them on the back side but i can't figure out the KIO4 extension.

Well darnit

Yep, definitely right !

What you have to do depends on your Android

In effect my apps are woking on pads featuring Android 10 & 11. (oldy and goody :grin:).
My hints was just related to the fact that with an updating period of 1000 ms and a distance of 0, the GPS interface is "forced" to work as fast as possible, though the real location update could be slower.

Ok, let's say differently.
In your blocks page you should paste the following.
image
The procedure "YourStuff" is just a stub, in my code. You should populate it with the code you need that uses the two variables LatitudeForComputation and LongitudeForComputation.
But please also apply what @SteveJG and @Taifun have said about the provider selection for Android12+
Best wishes.

@uskiara Ugo,

I tried your suggestions and I do get multiple transmits now but it is all the same coordinates. I am not sure what else to do?

The first thing you could do is to provide an updated screenshot of your relevant blocks

Taifun

Touche

Did I notice they updated the app inventor? It has a build date of Dec1 2023.
Anyway, I am afraid I am getting in over my head. I am trying to keep up but all of the different selections in the blocks are getting harder to follow. @Taifun I tried to app some of your stuff to my code so the provider stuff might work, but sadly failed. I had 22 errors and 2 warnings.

So here is what I have and I can can see it transmitting , just not changing coordinates.

test.aia (4.2 KB)

Are you moving around with your device?

You could adjust it to your needs, you only have ro understand the concept

Taifun

1 Like

Yes i am moving around as much as 19 meters 30ft in all directions.

That's not much. .
Which provider are you using?
What is the accuracy?
Are you outside for better gps signal?

Taifun

1 Like

This is probably not enough change to trigger an Android 12+ LocationChanged event without locking Provider to gps. Especially if you are indoors. If Provider is set to fused, your location probably will not register a change at all.

The Android may sometimes be too far away from the Arduino for your Bluetooth to be connected to your Arduino. Bluetooth is short range. You say ' sent continuos precise GPS updates over bluetooth to mu arduino.', and say

The Android is transmitting (showing coordinates change on your device screen) but not changing coordinates (in the Arduino)? Perhaps your Arduino script is not working as you expect it should work?


What happens if you temporarily abandon all the code related to Bluetooth and lock the Location provider to gps. Note that your Blocks do not show you setting and locking the Provider to gps.

Just solve the issue of your LocationSensor code. Run your revised app. Do you see a marker icon in your Title bar (that shows the gps is being used)? Does the location coordinates change when you move 10 meters away but not closer? Be careful what you see is affected by your LocationSensor.TimeInterval.

Once the app works using locked gps (continuously changes location as you move more than 10 meters); ensure your Arduino script works too.

Keep on working on this; this is complicated. :cry: and difficult for most developers to understand.

1 Like

Dear Bill, @bill_snyder,
I totally agree with @SteveJG : when you want to interface AI2 to Arduino you shall do one step at a time. Do the code and check locally the AI2 part, then the communication toward Arduino by using a super-simple code on Arduino, like a "echo on the Serial Monitor of Arduino anything is received on the BT", lastly develop the Arduino code, after you are sure that all the rest is already working. Otherwise you could get crazy in trying to locate what is not working. Unless you are so clever (or lucky :grin:) that everything works at the first attempt.
As far as the "steady" values are concerned, as all we have already said, please be aware that until you don't get linked a sufficient number of satellites, the accuracy is really poor, and therefore, only by walking around, could not be sufficient to "trigger" a new position.
In a nutshell: your first AI2 code should just show on two labels the lat and lon values, as soon as they are received by the location sensor, and that's all. In this way you can be sure that your device is capable to receive updated values. Then you go further with the other steps.
One thing that you can do is also to try a "ready made" app that you can download from appstore so to verify if your area is well serviced by satellites. For example you can try

Best wishes... :crossed_fingers: :crossed_fingers: :crossed_fingers:

EDITED:
you can try to add in the Screen Initialize event the following:
image

1 Like

SteveJG,

I do not know how to lock to a provider. I tried many of the examples and I am just afraid I am over my head with you guys. I could give up, but I really want to learn this.

I think with the right coaching I can learn it.

Consider this though. Here is something I found that seems to give updates as fast as you need them.

It uses a few html pages which I cannot figure where they are coming from, but it looks like it could work.

image
simpleGeoLocationV2.aia (5.7 KB)

As simple as possible while using Companion, this code example sets the Provider to gps
lockProvider

In reality, what needs to be done is more complex since Google introduced a
fused' Provider. This only ensures the gps will provide a LocationChanged event whereas a 'fused' Provider might not. :cry:

Run an example; you should now see an icon on your device showing gps is operating.

Are you using Android 13?

Have you tried Taifun's aia in post #19? Forget doing anything with Bluetooth for the moment. Does Taifun's app work for your purposes to provide frequent coordinate updates?

If it does provide coordinates fast and with precision you require, you still have another issue; controlling your Arduino with the Bluetooth controlling coordinates provided by your Android. I expect it is impossible to control your robot with the gps using MIT's LocationSensor at the precision and frequency and distance from your Android you hope for. I may be wrong. Developers try to avoid out of spec values for coordinates using the Accuracy property to screen the gps coordinates for precision data. I expect that is a waste of time based on my testing.

Once again, I'll say it, I suspect your Arduino script probably is not working for you when used with a standard LocationSensor. Where did you find the script?

This is my take, perhaps an expert will disagree and get your app working the way you dream it should work.

OK, use it but this is what you are buying

The image shows the reported location over a period of 30 seconds. The Android is stationary on my desktop. Do you want this precision?