Cov txheej txheem:
- Kauj Ruam 1: Qhov Chaw & Cuab Yeej
- Kauj ruam 2: Nrhiav Google API
- Kauj Ruam 3: Teeb NodeMCu ntawm Arduino IDE
- Kauj Ruam 4: Rub ArduinoJson Library
- Kauj Ruam 5: Txoj Haujlwm
Video: GEOLOACATION: 5 Kauj ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Nws yog kuv Qhov Kev Kawm Caij Ntuj Sov. Kuv xav tsis thoob thaum kuv hnov peb tuaj yeem taug qab qhov chaw ib qho khoom siv yam tsis siv GPS module tsuas yog siv NodeMCU. Los ntawm qhov no peb tuaj yeem taug qab txhua lub cuab yeej. Koj kuj xav tsis thoob li cas peb tuaj yeem taug qab cov cuab yeej siv tsuas yog WiFi. Nov yog cov lus piav qhia kom nkag siab nws.
- · Nws yog Scan koj yuav luag txhua WiFi.
- · Xa cov cuab yeej no mus rau Google siv Google API
- · Raws li qhov no Nws yog nrhiav koj lub cuab yeej qhov chaw
- · Koj muaj kev sib txuas network zoo rau Txoj Haujlwm no.
Kauj Ruam 1: Qhov Chaw & Cuab Yeej
Qhov
- NodeMCU (ESP8266 1.0 12E)
- USB Cable
Cov cuab yeej
Arduino IDE nrog NodeMcu 1.0 12E Board
Google API
Kauj ruam 2: Nrhiav Google API
- Qhib Koj Tus browser thiab ntaus: console.developer.google.com
- Tsim txoj haujlwm tshiab
- Tom qab Tsim Txoj Haujlwm Tshiab nyem rau ntawm daim ntawv pov thawj
- Nyem rau API Key
-
Koj tus lej API tau tsim
Txhawm rau nkag siab yooj yim pom cov duab hauv qab no |>
Kauj Ruam 3: Teeb NodeMCu ntawm Arduino IDE
- Rub tawm Arduino IDE los ntawm qhov txuas hauv qab no:- https:// www. Lub ntsiab/Software arduino.cc/en/
- Ntxiv Node MCu board ntawm Arduino IDE
-
Rau kev xa cov cai ntawm NodeMCU koj yuav tsum ntxiv NodeMCu pawg thawj coj ntawm ARDUINO IDE.
- Mus rau cov ntawv & Nyiam nyob hauv Arduino IDE
- Thiab hauv Pawg Tswj Xyuas Kev Tswj Xyuas Ntxiv tau theej cov kab ntawv txuas hauv qab no
-
arduino.esp8266.com/stable/package_esp8266c…
- thiab nyem Ok
- Pawg thawj coj tau rub tawm
- Mus rau cov cuab yeej thiab pawg thawj coj saib thiab xaiv NodeMCU 1.0 12E
- Saib daim duab avobe kom nkag siab yooj yim
Kauj Ruam 4: Rub ArduinoJson Library
- Mus rau qhov
Sketch Xws li Lub Tsev Qiv Tswj Lub Tsev Qiv Ntawv
Ntaus Arduino Json hauv lub thawv tshawb nrhiav
Rub tawm qhov hloov tshiab kawg ntawm ArduinoJson lub tsev qiv ntawv
tom qab rub tawm lub tsev qiv ntawv nyem ze
Ntxiv tsev qiv ntawv los ntawm
SketchincludeLibraryArduinoJson
Kauj Ruam 5: Txoj Haujlwm
Tshaj tawm cov haujlwm hauv qab no ntawm NodeMCU pawg thawj coj. thiab pom koj lub cuab yeej (NodeMCU 1.0 12E board) qhov chaw ntawm Serial monitor.
#suav nrog
#suav nrog
#suav nrog
char myssid = "Koj SSID"; // koj lub network SSID (lub npe)
char mypass = "Koj Tus Password"; // koj tus password network
// Cov ntaub ntawv pov thawj rau Google GeoLocation API…
const char* Tus tswv tsev = "www.googleapis.com";
Txoj hlua thisPage = "/geolocation/v1/geolocate? Key =";
// --- Tau txais google maps ap key ntawm no:
developers.google.com/maps/documentation/geolocation/intro
Txoj hlua tseem ceeb = "Koj tus lej Google API"; // Nrhiav los ntawm step2
Qhia
int xwm txheej = WL_IDLE_STATUS;
Txoj hlua jsonString = "{ n";
ob latitude = 0.0;
ob qhov ntev = 0.0;
ob qhov tseeb = 0.0;
int ntau_text = 1; // teeb tsa rau 1 rau ntau qhov debug tso tawm
void teeb tsa () {
Serial.begin (9600);
Serial.println ("Pib");
// Teeb WiFi rau hom chaw nres tsheb thiab
txiav tawm ntawm AP yog tias yav dhau los nws tau txuas nrog
WiFi.mode (WIFI_STA);
WiFi.disconnect ();
ncua (100);
Serial.println ( Teeb tsa
ua );
// Peb pib los ntawm kev txuas rau a
WiFi network
Serial.print ( Txuas rau
);
Serial.println (myssid);
WiFi.begin (myssid, mypass);
thaum (WiFi.status ()! = WL_CONNECTED) {
ncua (500);
Serial.print (".");
}
Serial.println (".");
}
void voj () {
char bssid [6];
DynamicJsonBuffer jsonBuffer;
Serial.println ("pib scan");
// WiFi.scanNetworks yuav rov qab los
tus xov tooj ntawm tes pom
int n = WiFi.scanNetworks ();
Serial.println ("scandone");
yog tias (n == 0)
Serial.println ("tsis muaj tes hauj lwm pom");
lwm tus
{
Serial.print (n);
Serial.println ("networkfound …");
yog (ntau_text) {
// Luam tawm cov ntaub ntawv json …
Serial.println ("{");
Serial.println ("\" homeMobileCountryCode / ": 234,"); // qhov no yog UK MCC tiag
Serial.println ("\" homeMobileNetworkCode / ": 27,"); // thiab UK MNC tiag
Serial.println ("\" radioType / ": \" gsm / ","); // rau gsm
Serial.println ("\" carrier / ": \" Vodafone / ","); // cuam tshuam nrog Vodafone
Serial.println ("\" cellTowers / ": ["); // Kuv tsis tau tshaj tawm xov tooj ntawm tes
Serial.println ("],");
Serial.println ("\" wifiAccessPoints / ": [");
rau (int kuv = 0; kuv <n; ++ kuv)
{
Serial.println ("{");
Serial.print ("\" macAddress / ": \" ");
Serial.print (WiFi. BSSIDstr (kuv));
Serial.println ("\", ");
Serial.print ("\" signalStrength / ":");
Serial.println (WiFi. RSSI (kuv));
yog tias (kuv <n - 1)
{
Serial.println ("},");
}
lwm tus
{
Serial.println ("}");
}
}
Serial.println ("]");
Serial.println ("}");
}
Serial.println ("");
}
// tam sim no tsim jsonString…
jsonString = "{ n";
jsonString += "\" homeMobileCountryCode / ": 234, / n"; // qhov no yog UK MCC tiag
jsonString += "\" homeMobileNetworkCode / ": 27, / n"; // thiab UK MNC tiag
jsonString += "\" radioType / ": \" gsm / ", / n"; // rau gsm
jsonString += "\" carrier / ": \" Vodafone / ", / n"; // cuam tshuam nrog Vodafone
jsonString += "\" wifiAccessPoints / ": [n";
rau (int j = 0; j <n; ++ j)
{
jsonString += "{ n";
jsonString += "\" macAddress / ": \" ";
jsonString += (WiFi. BSSIDstr (j));
jsonString += "\", / n ";
jsonString += "\" signalStrength / ":";
jsonString += WiFi. RSSI (j);
jsonString += "\ n";
yog tias (j <n - 1)
{
jsonString += "}, / n";
}
lwm tus
{
jsonString += "} n";
}
}
jsonString += ("] n");
jsonString += ("} n");
//--------------------------------------------------------------------
Serial.println ("");
WiFiClientSecure tus neeg siv khoom;
// Txuas rau tus neeg siv khoom thiab ua tus hu api
Serial.print ("Thov URL:");
// ---- Tau txais Google Maps Api Key ntawm no, Txuas:
Serial.println ("https://" + (String) Host + thisPage + "PUT-YOUR-GOOGLE-MAPS-API-KEY-HERE");
Serial.println ("");
yog (client.connect (Host, 443)) {
Serial.println ("Txuas");
client.println ("POST" + thisPage + key + "HTTP/1.1");
client.println ("Host:" + (String) Host);
client.println ("Kev sib txuas: kaw");
client.println ("Cov ntsiab lus-Hom: thov/json");
client.println ("Tus neeg siv-Tus neeg sawv cev: Arduino/1.0");
client.print ("Cov ntsiab lus-Ntev:");
client.println (jsonString.length ());
client.println (); cov.
client.print (jsonString);
ncua (500);
}
// Nyeem thiab txheeb xyuas txhua kab ntawm
teb los ntawm neeg rau zaub mov
thaum (client.available ()) {
Txoj hlua kab = client.readStringUntil ('\ r');
yog (ntau_text) {
Serial.print (kab);
}
JsonObject & hauv paus = jsonBuffer.parseObject (kab);
yog (root.success ()) {
latitude = hauv paus ["qhov chaw"] ["lat"];
longitude = hauv paus ["qhov chaw"] ["lng"];
raug = paus ["raug"];
}
}
Serial.println ("kaw qhov txuas");
Serial.println ();
client.stop (); cov.
Serial.print ("Latitude =");
Serial.println (latitude, 6);
Serial.print ("Ntev =");
Serial.println (ntev, 6);
Serial.print ("Qhov tseeb =");
Serial.println (qhov tseeb);
ncua (10000);
Serial.println ();
Serial.println ("Rov pib dua …");
Serial.println ();
ncua (2000);
}
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
Kawm Yuav Ua Li Cas Kos Tus Tswm Ciab - Kauj Ruam Ib Kauj Ruam: 6 Kauj Ruam
Kawm Yuav Ua Li Cas Thiaj Li Tswmciab - Kauj Ruam Ib kauj ruam: Cov tswm ciab no siv sijhawm 10 feeb los kos yog tias koj ua raws kuv cov kauj ruam ua tib zoo
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: 9 Kauj Ruam
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: Cov ntawv qhia no yog qhia koj yuav tsim lub Caj Npab Caj Npab ntawm koj tus kheej li cas