Cov txheej txheem:

Tau Sijhawm Los Ntawm Internet Siv ESP8266 - NTP Clock Project Nrog ESP8266 Nodemcu: 5 Kauj Ruam
Tau Sijhawm Los Ntawm Internet Siv ESP8266 - NTP Clock Project Nrog ESP8266 Nodemcu: 5 Kauj Ruam

Video: Tau Sijhawm Los Ntawm Internet Siv ESP8266 - NTP Clock Project Nrog ESP8266 Nodemcu: 5 Kauj Ruam

Video: Tau Sijhawm Los Ntawm Internet Siv ESP8266 - NTP Clock Project Nrog ESP8266 Nodemcu: 5 Kauj Ruam
Video: Qhia txog show Wifi password hauv Computer 2024, Hlis ntuj nqeg
Anonim
Tau Sijhawm Los Ntawm Internet Siv ESP8266 | NTP Clock Project Nrog ESP8266 Nodemcu
Tau Sijhawm Los Ntawm Internet Siv ESP8266 | NTP Clock Project Nrog ESP8266 Nodemcu

Hauv qhov kev qhia no peb yuav pom yuav siv sijhawm li cas siv ESP8266/nodemcu nrog Arduino IDE. Tau txais lub sijhawm tshwj xeeb tshaj yog muaj txiaj ntsig hauv cov ntaub ntawv nkag mus rau lub sijhawm cim koj nyeem. Yog tias koj txoj haujlwm ESP8266 tau nkag mus rau Is Taws Nem, koj tuaj yeem tau txais sijhawm siv Network Sijhawm raws tu qauv (NTP) - koj tsis xav tau lwm yam khoom siv ntxiv. Koj tuaj yeem txuas koj li ESP8266 rau koj lub network wifi thiab nws yuav yog lub moos uas yuav ua tiav nrog network, yog li yog tias ib zaug koj tau tshaj tawm cov cai nws yuav tau txais sijhawm los ntawm internet yog li nws ib txwm tso saib lub sijhawm raug.

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau

Txog qhov haujlwm no koj yuav xav tau ob peb yam: ESP8266/NODEMCUA USB cable rau program nws.

Kauj Ruam 2: NTP yog Dab Tsi thiab Nws Yuav Ua Haujlwm Li Cas?

NTP yog dab tsi thiab Nws Yuav Ua Haujlwm Li Cas?
NTP yog dab tsi thiab Nws Yuav Ua Haujlwm Li Cas?
NTP yog dab tsi thiab Nws Yuav Ua Haujlwm Li Cas?
NTP yog dab tsi thiab Nws Yuav Ua Haujlwm Li Cas?

NTP yog dab tsi: NTP sawv cev rau Network Time Protocol. Nws yog tus txheej txheem Internet Txheej Txheem (IP) rau synchronizing lub khoos phis tawj moos mus rau qee qhov siv hla lub network. Cov txheej txheem tuaj yeem siv los ua kom sib txuas txhua yam khoom siv sib txuas mus rau Kev Sib Koom Thoob Ntiaj Teb (UTC). NTP teeb tsa lub moos ntawm cov khoos phis tawj rau UTC, txhua lub sijhawm hauv zos cheeb tsam offset lossis hnub lub sijhawm txuag lub sijhawm offset tau thov los ntawm tus neeg siv khoom. Qhov no cov neeg siv khoom tuaj yeem sib koom ua ke rau cov servers tsis hais txog qhov chaw thiab lub sijhawm sib txawv li cas. Nws yuav ua haujlwm li cas rau peb: Cov neeg siv khoom xws li ESP8266 txuas rau tus neeg siv khoom siv Tus Neeg Siv Datagram raws tu qauv (UDP) ntawm chaw nres nkoj 123. tus neeg siv khoom xa mus thov pob ntawv mus rau NTP server Hauv kev teb rau qhov kev thov no NTP server xa lub sijhawm thim pob ntawv. Ntau lub pob ntawv ntim khoom muaj ntau cov ntaub ntawv xws li UNIX timestamp, qhov tseeb, ncua lossis sijhawm sijhawm.

Kauj Ruam 3: Txhim Kho Tsev Qiv Ntawv ntawm Arduino IDE

Txhim Kho Tsev Qiv Ntawv ntawm Arduino IDE
Txhim Kho Tsev Qiv Ntawv ntawm Arduino IDE

Hauv koj Arduino IDE mus rau Libraries tus thawj coj thiab tshawb rau NTP thiab tsuas yog rub NTP cov tsev qiv ntawv raws li kuv rub tawm, xa duab rau kev pab ntxiv.

Kauj Ruam 4: Coding Tshooj

Coding Tshooj
Coding Tshooj
Coding Tshooj
Coding Tshooj

Thov luam cov cai hauv qab no & muab koj daim ntawv pov thawj network nyob hauv koj tus lej ces koj yuav tsum tau teem sijhawm ua haujlwm rau kuv nws yog 19800 Vim tias kuv lub sijhawm siv yog utc+5: 30 yog li UTC +5: 30 = 5.5*60*60 = 19800UTC+1 = 1*60*60 = 3600CALCULATE koj lub sijhawm hauv cheeb tsam thiab kho nws thiab tom qab ntawd upload cov cai.#Suav nrog "NTPClient.h" #include "ESP8266WiFi.h" #include "WiFiUdp.h" const char*ssid = "***** ****** "; const char*password =" *********** "; const ntev utcOffsetInSeconds = 19800; char daysOfTheWeek [7] [12] = {" Hnub Sunday "," Monday ", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; // Txhais NTP Client kom tau sijhawmWiFiUDP ntpUDP; NTPClient timeClient (ntpUDP, "pool.ntp.org", utcOffsetInSeconds); tsis muaj teeb meem () {Serial.begin (115200); WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); Serial.print ("."); } timeClient.begin ();} void loop () {timeClient.update (); Serial.print (daysOfTheWeek [timeClient.getDay ()]); Serial.print (","); Serial.print (timeClient.getHours ()); Serial.print (":"); Serial.print (timeClient.getMinutes ()); Serial.print (":"); Serial.println (timeClient.getSeconds ()); //Serial.println (timeClient.getFormattedTime ()); ncua (1000);}

Kauj Ruam 5: Tau SIJHAWM

Tau SIJHAWM
Tau SIJHAWM

Tom qab Kev Tshaj Tawm cov cai rau Esp8266 koj tuaj yeem qhib cov ntawv xov xwm thiab yog tias txhua yam zoo, tom qab ntawd koj yuav tuaj yeem tau txais lub sijhawm ntawm tus saib xyuas raws li kuv muaj peev xwm tau txais lub sijhawm hauv kuv cov ntawv saib. Yog li nrog txoj haujlwm no koj tuaj yeem txuas ib qho tso saib thiab ua kom lub moos network raug. Yog li muaj kev lom zem ua koj lub moos network.

Pom zoo: