-->
Page 1 of 2

Self-localization using the Google Maps API

PostPosted: Fri Feb 24, 2017 1:48 pm
by martin_g
Started with a simple proof-of-concept implementation of self-localization of an ESP using the Google Maps API. If does a scan of the locally visible SSIDs, formats a request to the Google Maps Web Service and receives latitude and longitude of its current location if available.

https://github.com/martin-ger/esp_google_locator

Of course, this all might be done better with a GPS-receiver, but this is much more expensive, requires more energy, and does not work indoors.

In order to work in other places than in the home WiFi network, the sketch additionally scans for open WiFi netorks and tries to connect via these.

This should serve as a starting point for some useful application ideas, e.g. like an ESP-based tracker that awakes from deep sleep, does a scan and either uploads its position to a server, stores it in flash for later usage, or performs a location dependent action.

Re: Self-localization using the Google Maps API

PostPosted: Sat Feb 25, 2017 4:40 am
by reaper7
tested, working very good :)
tnx martin!

Re: Self-localization using the Google Maps API

PostPosted: Sat Feb 25, 2017 5:29 pm
by rudy
I can't get this to work for me. I keep getting this result.

444
0.00000,0.00000

I got a Google Maps Geolocation API key and there are no restrictions on it. It says it is enabled.

Any suggestions?

Code: Select all........
WiFi connected
IP address:
192.168.100.107
Scan done!
{
  "considerIp": "false",
  "wifiAccessPoints": [
    {
      "macAddress": "C0:**:**:**:**:98",
      "signalStrength": -89,
      "signalToNoiseRatio": 0
    },
    {
      "macAddress": "DC:**:**:**:**:78",
      "signalStrength": -91,
      "signalToNoiseRatio": 0
    },
    {
      "macAddress": "0C:**:**:**:**:34",
      "signalStrength": -90,
      "signalToNoiseRatio": 0
    },
    {
      "macAddress": "EC:**:**:**:**:35",
      "signalStrength": -89,
      "signalToNoiseRatio": 0
    },
    {
      "macAddress": "98:**:**:**:**:81",
      "signalStrength": -58,
      "signalToNoiseRatio": 0
    }
  ]
}
444
0.00000,0.00000


Code: Select all// Define this if you want to scan for open WiFi networks to connect
//#define FREE_WIFI

// Otherwise these settings will be used for WiFi connection
#define AP_SSID     "2*****65"
#define AP_PASSWORD "82********29"

String google_apikey = "AIzaSyB-*****************************IYPAhne1jMkc";

Re: Self-localization using the Google Maps API

PostPosted: Sat Feb 25, 2017 9:56 pm
by gdsports
Very cool!

Working after one change. I was getting 444 response code.

Code: Select all    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.println(data);


Change
Code: Select allclient.println(data)
to
Code: Select allclient.print(data)
println adds end of line characters so the extra chars throws off the content length.

And one more change. Comment out #define FREE_WIFI because there is an open AP without a connection to the Internet near me.