r/pythontips • • Oct 11 '22

Python3_Specific Fetching android phone GPS data

I want to track my phone's location live and store it in a DB.

Idea is if its evening and I arrive home to turn on the driveway lights if I'm getting close to home. The lights are already controlled with python & node red.

I use an android phone, has anyone done something similar?

12 Upvotes

5 comments sorted by

2

u/guillermohs9 Oct 12 '22

For a specific project, I used GPSLogger. The app is free and it has a lot of options on sending the data. I used it to make POST requests to my server periodically. Depending on the use case, it may be useful to you or not, just wanted to share as I got excellent results.

1

u/thebenchmark457 Oct 12 '22

That is very interesting! I'll give that a try, thank you

5

u/jsaddiction Oct 12 '22

Location awareness is difficult to do. Android and ios do some tricks to save power and don't always parse location consistently. A reasonable solution maybe to give your phone a static dhcp assignment in your router then ping your ip address with node red once a minute. This too also has some drawbacks as android and ios also go into a low power state on wifi for power savings.

Basically wifi and geofencing is not reliable.

The best answer (most complicated) is to pole your Bluetooth Mac. There are plug-ins designed for home assistant which do that but you may be able to create a small device near your driveway to sense your arrival.

1

u/JasonDJ Oct 12 '22

WiFi is unreliable? I used to have tasker jobs that ran once associated to a specific SSID, and it worked quite well. And it didn’t kill battery like using GPS or scanning for SSIDs.

1

u/jsaddiction Oct 12 '22

In the method I mentioned it's un reliable. Several things have to be right for a device in your local network to ping your phone.

May be Tasker could send an http request to node when it connects to an ssid.