Table des matières:

GEOLOACATION : 5 Étapes
GEOLOACATION : 5 Étapes

Vidéo: GEOLOACATION : 5 Étapes

Vidéo: GEOLOACATION : 5 Étapes
Vidéo: Geolocation Civil 3D 2022 2024, Juillet
Anonim
GEOLOACATION
GEOLOACATION

C'est mon projet de stage d'été. Je suis vraiment surpris d'entendre que nous pouvons localiser n'importe quel appareil sans utiliser le module GPS uniquement en utilisant NodeMCU. Grâce à cela, nous pouvons tracer n'importe quel appareil. Vous surprenez également comment pouvons-nous tracer un appareil en utilisant uniquement le WiFi. Voici la description du tri pour le comprendre.

  • · C'est Scannez votre presque tout WiFi.
  • · Envoyer l'emplacement de cet appareil à Google à l'aide de l'API Google
  • · Selon cela, il localise l'emplacement de votre appareil
  • · Vous disposez d'une connexion réseau solide pour ce projet.

Étape 1: pièces et outils

les pièces

  • NodeMCU (ESP8266 1.0 12E)
  • Cable USB

Outils

IDE Arduino avec carte NodeMcu 1.0 12E

API Google

Étape 2: Trouvez l'API Google

Trouver l'API Google
Trouver l'API Google
Trouver l'API Google
Trouver l'API Google
Trouver l'API Google
Trouver l'API Google
  • Ouvrez votre navigateur et tapez: console.developer.google.com
  • Créer un nouveau projet
  • Après avoir créé un nouveau projet, cliquez sur les informations d'identification
  • Cliquez sur la clé API
  • Votre clé API a été générée

    Pour comprendre facilement, voir l'image suivante |>

Étape 3: Configurer NodeMCu sur Arduino IDE

Configurer NodeMCu sur Arduino IDE
Configurer NodeMCu sur Arduino IDE
Configurer NodeMCu sur Arduino IDE
Configurer NodeMCu sur Arduino IDE
Configurer NodeMCu sur Arduino IDE
Configurer NodeMCu sur Arduino IDE
  • Téléchargez Arduino IDE à partir du lien suivant:- https://www. Principal/Logiciel arduino.cc/en/
  • Ajouter une carte Node Mcu sur Arduino IDE
  • Pour télécharger du code sur NodeMCU, vous devez ajouter la carte NodeMCu sur ARDUINO IDE.

    • Aller au fichier et aux préférences dans Arduino IDE
    • Et dans la section Gestionnaire de conseil supplémentaire, copiez le lien suivant
    • arduino.esp8266.com/stable/package_esp8266c…
    • et cliquez sur Ok
    • Le tableau est téléchargé
    • Accédez aux outils et au tableau et sélectionnez NodeMCU 1.0 12E
    • Voir l'image avobe pour comprendre facilement

Étape 4: Téléchargez la bibliothèque ArduinoJson

Télécharger la bibliothèque ArduinoJson
Télécharger la bibliothèque ArduinoJson
  • Allez au
  • Sketch Inclure la bibliothèque Gérer la bibliothèque

    Tapez Arduino Json dans le champ de recherche

    Téléchargez la dernière version de la bibliothèque ArduinoJson

    après avoir téléchargé la bibliothèque, cliquez sur fermer

    Ajouter une bibliothèque à partir de

    SketchincludeLibraryArduinoJson

Étape 5: programmer

Téléchargez le programme suivant sur la carte NodeMCU. et voir l'emplacement de votre appareil (carte NodeMCU 1.0 12E) sur le moniteur série.

#comprendre

#comprendre

#comprendre

char myssid = "Votre SSID"; // votre réseau SSID (nom)

char mypass = "Votre mot de passe"; // votre mot de passe réseau

//Identifiants pour l'API Google GeoLocation…

const char* Hôte = "www.googleapis.com";

String thisPage = "/geolocation/v1/geolocate?key=";

// --- Obtenez une clé ap google maps ici:

developers.google.com/maps/documentation/geolocation/intro

String key = "Votre clé Google API"; //Rechercher à partir de l'étape 2

Instruction

int état = WL_IDLE_STATUS;

Chaîne jsonString = "{n";

double latitude = 0,0;

double longitude = 0,0;

double précision = 0,0;

int more_text = 1; // mis à 1 pour plus de sortie de débogage

void setup() {

Serial.begin(9600);

Serial.println("Démarrer");

// Mettre le WiFi en mode station et

se déconnecter d'un point d'accès s'il était précédemment connecté

WiFi.mode(WIFI_STA);

WiFi.disconnect();

retard (100);

Serial.println( Configuration

terminé );

// On commence par se connecter à un

Réseau Wi-Fi

Serial.print( Connexion à

);

Serial.println(myssid);

WiFi.begin(myssid, mypass);

while (WiFi.status() !=WL_CONNECTED) {

retard (500);

Serial.print(".");

}

Serial.println(".");

}

boucle vide() {

char bssid[6];

DynamicJsonBuffer jsonBuffer;

Serial.println("début de l'analyse");

// WiFi.scanNetworks retournera

le nombre de réseaux trouvés

int n = WiFi.scanNetworks();

Serial.println("scandone");

si (n == 0)

Serial.println("aucun réseau trouvé");

autre

{

Serial.print(n);

Serial.println("réseaux trouvés…");

si (plus_texte) {

// Imprime le json formaté…

Serial.println("{");

Serial.println("\"homeMobileCountryCode\":234, "); // c'est un vrai MCC britannique

Serial.println("\"homeMobileNetworkCode\":27, "); // et une vraie multinationale britannique

Serial.println("\"radioType\":\"gsm\", "); //pour GSM

Serial.println("\"transporteur\":\"Vodafone\", "); //associé à Vodafone

Serial.println("\"cellTowers\": ["); // Je ne signale aucune antenne relais

Serial.println("], ");

Serial.println("\"wifiAccessPoints\": [");

pour (int i = 0; i < n; ++i)

{

Serial.println("{");

Serial.print("\"macAddress\": \"");

Serial.print(WiFi. BSSIDstr(i));

Serial.println("\", ");

Serial.print("\"signalStrength\": ");

Serial.println(WiFi. RSSI(i));

si (i < n - 1)

{

Serial.println("}, ");

}

autre

{

Serial.println("}");

}

}

Serial.println("]");

Serial.println("}");

}

Serial.println(" ");

}

// maintenant construire le jsonString…

jsonString = "{n";

jsonString +="\"homeMobileCountryCode\": 234, \n"; // c'est un vrai MCC britannique

jsonString +="\"homeMobileNetworkCode\": 27, \n"; // et une vraie multinationale britannique

jsonString +="\"radioType\": \"gsm\", \n"; // pour GSM

jsonString +="\"carrier\": \"Vodafone\", \n"; // associé à Vodafone

jsonString +="\"wifiAccessPoints\": [n";

pour (int j = 0; j < n; ++j)

{

chaîne json += "{n";

jsonString +="\"macAddress\": \"";

jsonString +=(WiFi. BSSIDstr(j));

chaîne json +="\", \n";

jsonString +="\"signalStrength\": ";

chaîne json += WiFi. RSSI(j);

chaîne json += "\n";

si (j < n - 1)

{

chaîne json +="}, \n";

}

autre

{

chaîne json +="}\n";

}

}

chaîne json += ("]\n");

chaîne json += ("}\n");

//--------------------------------------------------------------------

Serial.println("");

Client WiFiClientSecure;

//Connectez-vous au client et effectuez l'appel api

Serial.print("URL de demande: ");

// ---- Obtenez la clé Google Maps Api ici, lien:

Serial.println("https://" + (Chaîne)Hôte + thisPage +"PUT-YOUR-GOOGLE-MAPS-API-KEY-HERE");

Serial.println(" ");

if (client.connect(Host, 443)) {

Serial.println("Connecté");

client.println("POST" + thisPage + clé +"

client.println("Hôte:" + (Chaîne)Hôte);

client.println("Connexion: fermer");

client.println("Type de contenu: application/json");

client.println("User-Agent: Arduino/1.0");

client.print("Content-Length: ");

client.println(jsonString.length());

client.println();

client.print(jsonString);

retard (500);

}

//Lire et analyser toutes les lignes de

la réponse du serveur

while (client.available()) {

Ligne de chaîne =client.readStringUntil('\r');

si (plus_texte) {

Serial.print(ligne);

}

JsonObject& root =jsonBuffer.parseObject(line);

if (root.success()) {

latitude =root["emplacement"]["lat"];

longitude =root["emplacement"]["lng"];

précision = racine["précision"];

}

}

Serial.println ("fermeture de la connexion");

Serial.println();

client.stop();

Serial.print("Latitude =");

Serial.println(latitude, 6);

Serial.print("Longitude =");

Serial.println(longitude, 6);

Serial.print("Précision =");

Serial.println (précision);

retard (10000);

Serial.println();

Serial.println("Redémarrage…");

Serial.println();

retard (2000);

}

Conseillé: