Close
0%
0%

Geolocation using WLAN and MicroPython

Using the Google Maps Geolocation API and MicroPython on the WiPy 2.0 to determine a device position

Similar projects worth following
I wrote a 'geolocate()' class that runs on MicroPython. This class uses the Google Maps Geolocation API, and together with the MAC Address information captured by the WLAN module of the WiPy 2.0, it is possible to determine the position where you are.

The hardware and software needed are the following:

Wipy 2.0 Wipy 2.0 x 1 buy
Wipy 2.0 Expansion board x 1 buy
Google Maps API Google Maps Geolocation API x 1 register
Python 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.

  • 1 × WiPy 2.0 Board
  • 1 × Google Maps Geolocation API
  • 1 × uPyGeo (GitHub repository)

  • 1
    Read the MicroPython Tutorial

    Read the blog article: #Micropython: Getting Started! and install MicroPython on the WeMos board.

  • 2
    Get the code!

    Download the repository: uPyGeo.

  • 3
    Modify the following lines in the 'boot.py'
    ssid_ = your ssid
    wp2_pass = your wpa2 password

View all 6 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates