gmag11 / wifilocation Goto Github PK
View Code? Open in Web Editor NEWGoogle GeoLocation API wrapper for Arduino MKR1000, ESP8266 and ESP32
License: MIT License
Google GeoLocation API wrapper for Arduino MKR1000, ESP8266 and ESP32
License: MIT License
Hi,
I would report an issue that I am having.
Some times the script can provide the lat, long and accuracy values, but often I get
Latitude: 0.0000000
Longitude: 0.0000000
Accuracy: 40000
I understand that these values are the ones used in
typedef struct {
float lat = 0;
float lon = 0;
int accuracy = 40000;
} location_t;
I have uncommented line 12 in WifiLocation.h (//#define DEBUG_WIFI_LOCATION), and when it fails to report lan, long and accuracy there is the following indication
HTTPS ERROR
Nonetheless, when the process goes well, I can see a normal HTTP post which is aligned with this API. Not sure what is causing this. Can anyone provide support to solve this issue?
Thanks for sharing the code. It works very well and I have no major problems with it.
I only noticed that after locating ESP32 in a one place and moving it elsewhere (e.g. a dozen kilometers away), for the first 24-48 hours Google API still returns the coordinates of the previous location. I don't know if it's related to the code itself (rather not), or it's Google API's fault.
It would be nice if this could, optionally, also support the Google Places API Web Service to get back the clear text name of the detected place (like a street and city) rather than just lat and lon.
Hi!, thanks for your library! I'm trying to use this and i have a problem.
Location request data
[
{"macAddress":"98:97:D1:DF:6F:74","signalStrength":-74,"channel":1},
{"macAddress":"34:57:60:11:0E:EC","signalStrength":-88,"channel":2},
{"macAddress":"48:EE:0C:11:52:23","signalStrength":-43,"channel":9},
{"macAddress":"70:62:B8:29:C0:20","signalStrength":-74,"channel":6},
{"macAddress":"C4:12:F5:46:C4:0B","signalStrength":-88,"channel":10}]
Latitude: 0.0000000
Longitude: 0.0000000
Accuracy: 40000
this is the output when trying to run the example provided. I've checked my API key. Do you have any ideias on what is wrong?
It would be nice if ESPWifiLocation could return to the sketch the names of the detected SSIDs. My sketch, for example, needs to check for the presence of a certain SSID. Of course I could do just another scan in my sketch, but that is wasteful in terms of energy consumption and time needed since ESPWifiLocation is doing a scan already.
When installing or updating the library in PlatformIO, it says "Error: Could not load broken JSON"
There is a missing comma on line 6 of library.json that causes this error.
Dear @gmag11 I try your library but I Have this problem
My API work fine and I have a Full GCloud and i have created a new certificate via linux.
What is the problem?? Because 404 ?
`requesting URL: /geolocation/v1/geolocate?key=AI***************************gz-mXZIxXI
request:
POST /geolocation/v1/geolocate?key=AI****************************gz-mXZIxXI HTTP/1.1
Host: www.googleapis.com
User-Agent: ESP8266
Content-Type:application/json
Content-Length:523
Connection: keep-alive
{"considerIP":false,"wifiAccessPoints":[{"macAddress":"DC:XXXXX8:4D","signalStrength":-50,"channel":1},
{"macAddress":"FC:XXXX:E5:41","signalStrength":-86,"channel":8},
{"macAddress":"F0:2XXXXX:1B:D0","signalStrength":-56,"channel":8},
{"macAddress":"F0:2FXXXXXD:1B:D5","signalStrength":-55,"channel":8},
{"macAddress":"F0:2FXXXXXXB:D6","signalStrength":-56,"channel":8},
{"macAddress":"FC:3FXXXXXXC:85","signalStrength":-48,"channel":8},
{"macAddress":"42:EXXXXX:4C","signalStrength":-34,"channel":8}]}
request sent
Free heap: 3688
.
Got response:
HTTP/1.1 404 Not Found
Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8
Date: Tue, 29 Mar 2022 14:23:22 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked
108
{
"error": {
"code": 404,
"message": "Requested entity was not found.",
"errors": [
{
"message": "Requested entity was not found.",
"domain": "global",
"reason": "notFound"
}
],
"status": "NOT_FOUND"
}
}
0
Location request data
7 WiFi networks found
WiFi list:
[{"macAddress":"DC:AXXXX0C:A8:4D","signalStrength":-53,"channel":1},
{"macAddress":"FC:3F:DXXXXX:85","signalStrength":-45,"channel":8},
{"macAddress":"42XXXX:4C","signalStrength":-17,"channel":8},
{"macAddress":"FC:34:9XXXX5:41","signalStrength":-85,"channel":8},
{"macAddress":"F0:2XXXXX1B:D6","signalStrength":-55,"channel":8},
{"macAddress":"F0:2XXB:D0","signalStrength":-53,"channel":8},
{"macAddress":"F0:2F:XXXB:D5","signalStrength":-54,"channel":8}]
[{"macAddress":"DC:AXXXX8:4D","signalStrength":-53,"channel":1},
{"macAddress":"FC:3FXXXX:2C:85","signalStrength":-45,"channel":8},
{"macAddress":"42:EXXX:7E:4C","signalStrength":-17,"channel":8},
{"macAddress":"FC:3XXX1:E5:41","signalStrength":-85,"channel":8},
{"macAddress":"F0:2F:7XXXB:D6","signalStrength":-55,"channel":8},
{"macAddress":"F0:2F:7XXXXB:D0","signalStrength":-53,"channel":8},
{"macAddress":"F0:2FXXXXXB:D5","signalStrength":-54,"channel":8}]
Location: 0.0000000,0.0000000
Longitude: 0.0000000
Accuracy: 40000`
Until 2 months ago I was able to use the query successfully in my application. Now I get an HTTPS error. An update to version 1.2.8 did not bring success either. In the sample code I get the same error.
ESP8266 (d1 mini) + also ESP32
IDE: 1.8.15
ESP Core: 2.7.4
Google API Key is unchanged, the query via Postman is OK.
#define DEBUG_WIFI_LOCATION 1 is set, enclosed the log output. (thats all..)
22:45:32.276 -> Status = 6
22:45:32.771 -> Connected
22:45:32.771 -> Waiting for NTP time sync:
22:45:32.771 -> Current time: Tue Aug 10 20:45:31 2021
22:45:34.211 -> HTTPS error
22:45:34.211 -> Location request data
22:45:35.787 -> 5 WiFi networks found
22:45:35.787 -> WiFi list :
22:45:35.787 -> [
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-59,"channel":1},
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-57,"channel":1},
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-69,"channel":1},
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-76,"channel":1},
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}]
22:45:35.787 -> [
22:45:35.787 -> {"macAddress":"xxx","signalStrength":-59,"channel":1},
22:45:35.832 -> {"macAddress":"xxx","signalStrength":-57,"channel":1},
22:45:35.832 -> {"macAddress":"xxx","signalStrength":-69,"channel":1},
22:45:35.832 -> {"macAddress":"xxx","signalStrength":-76,"channel":1},
22:45:35.832 -> {"macAddress":"xxx","signalStrength":-86,"channel":1}]
22:45:35.832 -> Location: 0.0000000,0.0000000
22:45:35.832 -> Accuracy: 40000
22:45:35.832 -> Result: API connection error
Does anyone have an idea where the error is?
I suspect something is wrong with the certificate / SSL connection.
Hi, i am using the library in a ESP8466 and i am getting a soft reset every time the getGeoFromWiFi() is used but not always. I think this is because there are too many wifi ap's and it kind overflow some variable.
it can be possible?
I have tested the google location api on postman it is working fine and return correct location parameters. when i run this given example with wifi location on esp32 i get the following response.
{"macAddress":"F6:74:1E:2B:F2:80","signalStrength":-27,"channel":1}]
Latitude: 0.0000000
Longitude: 0.0000000
Accuracy: 40000
i have attached the picture when i executed the API on postman.
kindly help me out.
displays this in the Serial Monitor
Latitude: 0.0000000
Longitude: 0.0000000
Accuracy: 40000
Any explanations on the installation? I can't see it anywhere on here, and do it work on windows to get the results etc? it would be sick if you can do a video for the installation for us , cause i'm confuse on how this work.
Download location data up to 1 mile*, When the ESP32/ESP8266 reconnects to WiFi in a different spot, The ESP will delete the previous download and redownload the updated data for a different area, Also having the option to connect to any open WiFi network** to download data when available.
Keep me updated on the results!
*User configurable, Minimum is .01 miles, Maximum is 1.00, Default is 1.00 (In code it would be 01 min, 10 max, 05=0.05 mi)
**User can also still use their own secure networks
This would need to be tested for full functionality.
Do you honour to omit APs with the following properties:
See for example: https://www.androidpolice.com/2020/05/03/opt-out-wi-fi-from-google-location-services/
Hey so it appears with version 1.3.0, your code relies on a library you made called quickdebug
the issue is that quick debug doesn't appear to be within the library manager to download (at which point it could be downloaded with the WifiLocation library) or just simply included with the files of the library.
theres the solution for people to just download and paste the quick debug files however if a user hasn't done this and goes to compile it just says it cant find quickdebug.h
I've tested this across 2 windows machines and against both the legacy and 2.0 version of arduino IDE.
Line 7 is
#include "arduino.h"
Should be:
#include "Arduino.h"
I don't think this is an issue if you are on a windows machine, but is for linux boxes.
Just for completeness - Linux Mint 18.2, I3, 6gb, 1tb, Arduino IDE 1.8.4
Hi,
Will u please add all the attributes like lat, long,speed,altitude,date time etc in this library.
I'm using an Esp32 and an error kept showing up:
_handle_error(): [data_to_read():270]: (-80) UNKNOWN ERROR CODE (0050)
I found that the code 0050 meant that the server were closing the connection, so, I changed the HTTP header in line 120 to keep the conection alive -> "request += "Connection: keep-alive\r\n\r\n";"
Don't know which impacts this may cause, but it fix it for me.
Hi,
after a few days with the new certificate it worked wonderfully, now the old error appears again. Was something else adjusted here on the part of google?
16:17:17.342 -> Waiting for NTP time sync:
16:17:17.342 -> Current time: Mon Aug 23 14:17:18 2021
16:17:17.792 -> HTTPS error
16:17:17.792 -> Location request data
16:17:19.367 -> 8 WiFi networks found
16:17:19.367 -> WiFi list:
16:17:19.367 -> [{"macAddress":"-","signalStrength":-62,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-87,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-73,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-43,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-89,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-79,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-87,"channel":6},
16:17:19.412 -> {"macAddress":"-","signalStrength":-87,"channel":11}]
16:17:19.457 ->
16:17:19.457 -> [{"macAddress":"-","signalStrength":-62,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-87,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-73,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-43,"channel":6},
16:17:19.457 -> {"macAddress":"D-","signalStrength":-89,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-79,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-87,"channel":6},
16:17:19.457 -> {"macAddress":"-","signalStrength":-87,"channel":11}]
16:17:19.502 -> Location: 0.0000000,0.0000000
16:17:19.502 -> Accuracy: 40000
16:17:19.502 -> Result: API connection error
Compiling results in the following error:
WifiLocation\src\WifiLocation.cpp:73:68: error: invalid conversion from 'uint8_t' {aka 'unsigned char'} to 'uint8_t*' {aka 'unsigned char*'} [-fpermissive]
I already solved my problem, "I did not have a billing account associated with the API project"
Connected
Waiting for NTP time sync: .
Current time: Sun Sep 5 06:22:12 2021
Location request data
[{"macAddress":"08:3E:0C:81:B0:D0","signalStrength":-84,"channel":8}]
Location: 4.5383682,-75.6908035
Accuracy: 3560
Result: OK
Originally posted by @alejolopez03 in #10 (comment)
I use only bing api key.the google api key can not applied because i am not use the visa card .
use the BingMapsGeo.ino example.
the program code can compile.and run to here.
the serial information as below:
_Waiting for NTP time sync: ..........
Current time: Mon Jul 3 04:49:44 2023
[ 8144][V][ssl_client.cpp:62] start_ssl_client(): Free internal heap before TLS 203388
[ 8144][V][ssl_client.cpp:68] start_ssl_client(): Starting socket
[ 8285][V][ssl_client.cpp:149] start_ssl_client(): Seeding the random number generator
[ 8286][V][ssl_client.cpp:158] start_ssl_client(): Setting up the SSL/TLS structure...
[ 8291][V][ssl_client.cpp:181] start_ssl_client(): Loading CA cert
[ 8300][V][ssl_client.cpp:257] start_ssl_client(): Setting hostname for TLS session...
[ 8304][V][ssl_client.cpp:272] start_ssl_client(): Performing the SSL/TLS handshake...
[ 8671][E][ssl_client.cpp:37] handle_error(): [start_ssl_client():276]: (-9984) X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[ 8674][E][WiFiClientSecure.cpp:135] connect(): start_ssl_client: -9984
[ 8682][V][ssl_client.cpp:324] stop_ssl_socket(): Cleaning SSL connection.
[ 8688][W][bingMapsGeocoding.cpp:66] getGeoFromPosition(): [BINGGEO] [H:200852][T:loopTask] HTTPS error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.