Reputation: 11
Does anyone know how to access GPS and phone sensor data with Pydroid3?
There's very little documentation online, and examples with plyer gps don't work. I'd like to read the light meter sensor, and GPS simultaneously with Pydroid script.
E.g. this code:
from plyer import gps
def print_locations(**kwargs):
print('lat: {lat}, lon: {lon}'.format(**kwargs))
gps.configure(on_location=print_locations)
gps.start()
# later
gps.stop()
Fails with:
ModuleNotFoundError: No module named 'plyer.platforms.linux.gps'
Traceback (most recent call last):
I've also tried with plyer-s fork version from HyTurtle instead of main plyer
Upvotes: 1
Views: 518
Reputation: 11
I've managed to get GPS working with Pydroid3 on new and old Android phones.
On newer Android phones (12) I had to install HyTurtle's version of plyer (as per here: Reading GPS data from android device with Python).
First, go to the Android settings permission manager, and set Pydroid Permissions Plugin to have location data (install the Pydroid permission plugin if you don't have it already).
Next, go to Pydroid3 and open the terminal.
Uninstall existing plyer if necessary:
pip uninstall plyer
Then install HyTurtle's fork:
pip install https://github.com/HyTurtle/plyer/archive/master.zip
Then ask ChatGPT to write some code for Pydroid3 (either Kivy or tkinter) that records the GPS position, and the output works (the code can't be posted here).
Upvotes: 0