The hardware and software needed are the following:
![]() | Wipy 2.0 | x 1 | buy |
![]() | Expansion board | x 1 | buy |
![]() | Google Maps Geolocation API | x 1 | register |
![]() | uPyGeo | x 1 | buy |
The class initializer is the following:
def __init__(self, google_api_key, my_ssid, wlan_check_interval = 1, mcc=262, mnc=11):
and the arguments are defined as:
- 'google_api_key': Google API key that you get clicking on the link available here;
- 'wlan_check_interval': It defines the wait time between checking for new WiFi signals (in seconds (default = 1));
- 'mcc': Mobile Country Codes (MCC) (default=262 -o2 Germany), you can find some values here;
- 'mnc': Mobile Network Codes (MNC) (default=11 -o2 Germany), same as `mcc`.
A code example to use the `geolocate` class is the following
from geoposition import geolocate
ssid_ = <your ssid> #usually defined in your boot.py file
google_api_key = <API_KEY> #get from google
geo_locate = geolocate(google_api_key, ssid_) #geo_locate object
valid, location = geo_locate.get_location()
if(valid):
print("The geo position results: " + geo_locate.get_location_string())
A PoC is available here.