Cov txheej txheem:

Esp8266 Kev Txuas Hluav Taws Xob: 10 Kauj Ruam
Esp8266 Kev Txuas Hluav Taws Xob: 10 Kauj Ruam

Video: Esp8266 Kev Txuas Hluav Taws Xob: 10 Kauj Ruam

Video: Esp8266 Kev Txuas Hluav Taws Xob: 10 Kauj Ruam
Video: Простое и дешевое FM-радио Arduino! - Учебник + Код 2024, Kaum ib hlis
Anonim
Image
Image
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj

Txhawm rau pib nrog txoj haujlwm no, Koj xav tau cov hauv qab no:

  • esp8266 (NodeMcu v3 Lua)
  • google tus account (firebase)

Koj tuaj yeem yuav tau esp8266 los ntawm no:

  • amazon.com
  • aliexpress.com

Kauj Ruam 1: Teeb Arduino IDE, Nruab Esp8266 Pawg Thawj Coj:

Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj
Teeb tsa Arduino IDE, Nruab Esp8266 Pawg Thawj Coj

Nruab esp8266 Board:

Qhib Arduino IDE> Cov Ntaub Ntawv> Nyiam> ntxiv Tus Thawj Saib Xyuas Haujlwm URLs> "https://arduino.esp8266.com/stable/package_esp8266c …> OK

Cuab Yeej> Pawg Thawj Coj:> Tus Thawj Saib Xyuas Pawg> esp8266> nruab

Kauj Ruam 2: Teeb Arduino IDE, Nruab Arduino Json Library:

Image
Image

Nruab Arduino json tsev qiv ntawv:

Nruab version 5.13.1

Saib install video NTAWM NO

Kauj Ruam 3: Teeb Arduino IDE, Nruab Firebase Library:

Teeb tsa Arduino IDE, Nruab Firebase Library
Teeb tsa Arduino IDE, Nruab Firebase Library

Nruab Firebase tsev qiv ntawv:

Rub tawm qhov tseeb ruaj khov NTAWM NO> unzip hauv "Documents / Arduino / libraries"

NCO TSEG, Muaj kab nyob hauv "v0.3 Bi-directional streaming support"> hloov cov ntiv tes NYEM QHOV NO INFO

Kauj Ruam 4: Firebase, Tsim Txoj Haujlwm:

Firebase, Tsim Txoj Haujlwm
Firebase, Tsim Txoj Haujlwm
Firebase, Tsim Txoj Haujlwm
Firebase, Tsim Txoj Haujlwm

Tsim Firebase Project:

Mus rau "https://console.firebase.google.com"

Kauj Ruam 5: Firebase, Txoj Cai Txoj Haujlwm:

Firebase, Txoj Cai Txoj Cai
Firebase, Txoj Cai Txoj Cai

Txoj cai txoj haujlwm:

Database (Realtime Database)> cov cai

{/* Mus ntsib https://firebase.google.com/docs/database/security kom paub ntau ntxiv txog cov cai kev nyab xeeb. */ "cov cai": {".read": tseeb, ".write": tseeb}}

Kauj Ruam 6: Firebase, Cov Ntaub Ntawv Teev Npe Sijhawm:

Firebase, Cov Ntaub Ntawv Txog Lub Sijhawm Sijhawm
Firebase, Cov Ntaub Ntawv Txog Lub Sijhawm Sijhawm

Realtime Database cov ntaub ntawv:

Database (Realtime Database)> Cov Ntaub Ntawv

Ntxiv: "LED1"> "0"

Kauj ruam 7: Code:

#suav nrog

#suav nrog

#define WIFI_SSID "SSID" #define WIFI_PASSWORD "WIFI PASSWORD" #define FIREBASE_HOST "?????????????? firebaseio.com" #define FIREBASE_AUTH "AUTH KEY"

int LED1 = 4;

void teeb tsa ()

{Serial.begin (115200);

tus pinMode (LED1, OUTPUT);

ncua (2000);

Serial.println ('\ n'); wifiConnect ();

Firebase.begin (FIREBASE_HOST, FIREBASE_AUTH);

ncua (10);

}

void lub voj ()

{Serial.print (Firebase.getString ("LED1") + "\ n");

analogWrite (LED1, Firebase.getString ("LED1"). toInt ());

ncua (10);

yog (WiFi.status ()! = WL_CONNECTED)

{wifiConnect (); } ncua (10);

}

tsis muaj wifiConnect ()

{WiFi.begin (WIFI_SSID, WIFI_PASSWORD); // Txuas mus rau lub network Serial.print ("Txuas rau"); Serial.print (WIFI_SSID); Serial.println (“…”);

int tus qhia = 0;

thaum (WiFi.status ()! = WL_CONNECTED) {// Tos kom Wi-nkaus txuas txuas qeeb (1000); Serial.print (++ tus qhia); Serial.print (''); }

Serial.println ('\ n');

Serial.println ("Kev sib txuas tau tsim!"); Serial.print ("IP chaw nyob: / t"); Serial.println (WiFi.localIP ()); // Xa tus IP chaw nyob ntawm ESP8266 mus rau lub khoos phis tawj}

Kauj Ruam 8: Txoj Cai, Cov Ntaub Ntawv Tus Kheej:

Txoj Cai, Cov Ntaub Ntawv Tus Kheej
Txoj Cai, Cov Ntaub Ntawv Tus Kheej
Txoj Cai, Cov Ntaub Ntawv Tus Kheej
Txoj Cai, Cov Ntaub Ntawv Tus Kheej

cov ntaub ntawv tus kheej:

SSID> lub npe ntawm koj lub network wifi

WIFI PASSWORD> password ntawm koj lub network wifi

FIREBASE HOST> qee yam xws li "?????????????. Firebaseio.com". Koj tuaj yeem pom nws hauv "Cov Ntaub Ntawv" tab ntawm koj Lub Sijhawm Teev Npe.

AUTH KEY> Txoj haujlwm teeb tsa> Cov nyiaj pabcuam> Cov ntaub ntawv zais cia

Kauj Ruam 9: Esp8266 Tsav Tsheb:

Esp8266 Cov Tsav Tsheb
Esp8266 Cov Tsav Tsheb

Rub tawm:

Nyem qhov no> unzip thiab nruab

Kauj Ruam 10: Xeem Txoj Cai:

Xeem Txoj Cai
Xeem Txoj Cai

Upload chaws:

siv tus qauv esp8266 hauv tus thawj tswj hwm pawg> nyem "ESP-12E module".

Qhib serial saib thiab teeb nws rau "115200".

Thiab koj yuav tsum tau txais cov ntaub ntawv zoo ib yam li hauv koj lub database.

Pom zoo: