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

One more question and then I want to try some stuff. You said the "screen 1 initialize" which block is that?

Screen1 is the "master" screen, from where any app begins.
In the blocks page you have:
image
So in the event "initialize" you shall perform the LocationSensor initialization, as well.

I dont even have that. Thanks

AccuMin variable is defined by what? Do I initialize that in the Screen1

OK Admittedly I am horrible at this.

I put AccuMin in the middle of the page but cannot figure the block connectors to set the value

Here is a method that 'works'. GPS with Android 12 to set Provider to gps.

@uskiara @bill_snyder What you have to do depends on your Android.

That method works, if gps is enabled and therefore available in property AvailableProviders

Here is a solution which locks the provider to gps only if it is available

GPSsimple_2_Taifun.aia (13.1 KB)

Taifun

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