Cov txheej txheem:
- Kauj Ruam 1: Yam Koj Xav Tau
- Kauj ruam 2: Kev sib txuas
- Kauj ruam 3: Rub cov tsev qiv ntawv
- Kauj ruam 4: NTP yog dab tsi
- Kauj Ruam 5: Coding Tshooj
- Kauj Ruam 6: Tau Hnub & Sijhawm
Video: Mloog Internet: Zaum Hnub thiab Sijhawm Nrog OLED Siv ESP8266 NodeMCU Nrog NTP Raws Cai: 6 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Nyob zoo cov txiv neej hauv cov lus qhia no peb yuav tsim lub moos internet uas yuav tau txais sijhawm los ntawm internet yog li qhov haujlwm no yuav tsis xav tau RTC los ua haujlwm, nws tsuas yog xav tau kev ua haujlwm internet txuas
Thiab rau txoj haujlwm no koj xav tau esp8266 uas yuav muaj wifi kom tau txais kev siv internet thiab tso saib kom pom lub sijhawm ntawm nws thiab esp8266 yuav nqa sijhawm los ntawm internet siv NTP raws tu qauv, ntp sawv rau lub sijhawm network raws tu qauv, yog li muaj cov ntp servers ntawm lub vev xaib uas tau siv los ua haujlwm sib tham hauv computer thiab peb yuav siv bthose servers kom tau sijhawm nyob hauv peb qhov haujlwm.
Kauj Ruam 1: Yam Koj Xav Tau
rau qhov project no koj yuav xav tau cov hauv qab no:
Esp8266/nodemcu
Oled ssd1306 0.96"
Jumper xov hlau
Cov qhob cij
Usb kab
Kauj ruam 2: Kev sib txuas
Qhov 4-pin OLED zaub sib txuas lus nrog ESP8266 tus qauv siv I2C raws tu qauv, hauv qab no yog daim duab kos duab thiab cov rooj sib txuas los txuas OLED I2C pins nrog NodeMCU los tso saib Internet sijhawm.
Kauj ruam 3: Rub cov tsev qiv ntawv
Nco ntsoov tias koj rub tawm SD1306 cov tsev qiv ntawv hauv Koj li Arduino lub tswv yim raws li qhia hauv duab thiab kom ntseeg tau tias koj Adafruit GFX lub tsev qiv ntawv ib yam, yog tias tsis yog ces nruab ob lub tsev qiv ntawv no.
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: NTP yog dab tsi
NTP yog ib qhov qub tshaj plaws kev sib tham Internet raws tu qauv (IP) rau synchronizing moos ntawm lub computer network. Nws tau tsim los ntawm David L. Mills ntawm Tsev Kawm Qib Siab Delaware xyoo 1981. Cov txheej txheem no tuaj yeem siv los sib txuas ntau lub network rau Kev Sib Koom Ua Haujlwm Sijhawm (UTC) hauv ob peb milliseconds. UTC yog thawj lub sijhawm tus qauv uas lub ntiaj teb tswj hwm lub moos thiab sijhawm. UTC tsis hloov pauv thiab txawv rau thaj chaw sib txawv. NTP siv UTC raws li lub sijhawm siv thiab muab sijhawm raug thiab sib koom ua ke thoob plaws Internet.
NTP ua haujlwm ntawm tus qauv hierarchical client-server. Tus qauv saum toj kawg nkaus muaj lub moos siv hu ua "stratum0" zoo li lub moos atomic, xov tooj cua tsis zoo, GPS, GSM uas tau txais sijhawm los ntawm lub hnub qub. Cov servers uas tau txais sijhawm los ntawm stratum0 raug hu ua "stratum1" thiab cov servers uas tau txais sijhawm los ntawm stratum1 hu ua "stratum2" thiab ntxiv rau. Qhov no mus ntxiv thiab qhov tseeb ntawm lub sijhawm mus zuj zus tom qab txhua theem. NTP txiav txim siab xaiv qhov zoo tshaj plaws ntawm ob peb lub sijhawm muaj peev xwm los ua ke uas ua rau nws ua txhaum-ua siab ntev tuaj yeem ua raws. Yog li ntawm no hauv txoj haujlwm no, peb tau txais sijhawm los ntawm NTP server siv ESP8266 NodeMCU thiab qhia nws ntawm OLED zaub. Qhov zoo ib yam ntawm Internet moos yog tsim los ntawm kev siv ESP32 hauv kev qhia yav dhau los.
Kauj Ruam 5: Coding Tshooj
Txhawm rau thov hnub thiab sijhawm, pib lub sijhawm cov neeg siv nrog chaw nyob ntawm NTP servers. Txhawm rau kom raug dua xaiv qhov chaw nyob ntawm NTP cov servers uas nyob ze rau koj thaj chaw. Nov peb siv “pool.ntp.org” uas muab cov servers los ntawm thoob ntiaj teb. Yog tias koj xav xaiv cov servers los ntawm Asia koj tuaj yeem siv "asia.pool.ntp.org". timeClient kuj tseem siv UTC lub sijhawm offset hauv milliseconds ntawm koj lub sijhawm. Piv txwv li, UTC offset rau Is Nrias teb yog +5: 30 yog li peb hloov qhov no offset hauv milliseconds uas yog sib npaug 5*60*60 +30*60 = 19800.
Thaj tsam. UTC lub sijhawm offset (teev thiab feeb). UTC lub sijhawm offset (vib nas this)
INDIA +5: 30 19800
LONDON 0:00 TS 0
NEW YORK -5: 00 -18000
Thov luam cov cai hauv qab no & nkag mus rau koj li wifi & password hauv tus lej & Nkag mus rau lub sijhawm offset hauv cov cai ces rub nws mus rau koj cov laug esp8266.:
#include "NTPClient.h" #include "ESP8266WiFi.h" // muab ESP8266 cov haujlwm Wi-nkaus tshwj xeeb uas peb tau hu los txuas rau network #suav nrog "WiFiUdp.h" // ua haujlwm xa thiab tau txais UDP pob
#suav nrog "SPI.h" // SPI rau cuam tshuam nrog OLED nrog NodeMCu
#suav nrog "Adafruit_GFX.h"
#suav nrog "Adafruit_SSD1306.h"
#define SCREEN_WIDTH 128 // OLED zaub dav, hauv pixels
#define SCREEN_HEIGHT 64 // OLED zaub siab, hauv pixels
#define OLED_RESET -1
Adafruit_SSD1306 zaub (SCREEN_WIDTH, SCREEN_HEIGHT, & Hlau, OLED_RESET);
constchar *ssid = "yourwifissid";
const char *password = "yourwifipass";
WiFiUDP ntpUDP;
NTPClient timeClient (ntpUDP, "pool.ntp.org", 19800, 60000);
String arr_days = {"Hnub Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
Txoj hlua hnub tim _ sijhawm; // Koj tuaj yeem hais qhia lub sijhawm server pas thiab qhov offset (hauv vib nas this, tuaj yeem hloov pauv tom qab nrog setTimeOffset ()). Ntxiv rau koj tuaj yeem hais qhia // ncua sijhawm hloov tshiab (hauv milliseconds, tuaj yeem hloov pauv siv setUpdateInterval ()).
void teeb tsa ()
{
Serial.begin (115200);
WiFi.begin (ssid, password);
thaum (WiFi.status ()! = WL_CONNECTED)
{
ncua (500);
Serial.print (".");
}
yog (! display.begin (SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println (F ("SSD1306 faib tsis tau"));
rau (;;); // Tsis txhob ua ntxiv, voj ib si
}
display.clearDisplay ();
display.setTextSize (2); // Kos 2X-teev cov ntawv
display.setTextColor (WHITE);
display.setCursor (5, 2);
display.println ("Zoo Siab Txais Tos");
display.println ("qhia");
display.println ("Project");
display.display ();
ncua (3000);
timeClient.begin ();
}
void lub voj ()
{
timeClient.update ();
display.clearDisplay ();
Serial.println (timeClient.getFormattedTime ());
display.setTextSize (2); // Kos 2X-teev cov ntawv
display.setTextColor (XEEB);
display.setCursor (0, 2);
int hh = timeClient.getHours ();
int hli = timeClient.getMinutes ();
int ss = timeClient.getSeconds ();
yog tias (hh> 12)
{
hh = hh-12;
display.print (hh);
display.print (":");
display.print (hli);
display.print (":");
display.print (ss);
display.println ("PM");
}
lwm tus
{
display.print (hh);
display.print (":");
display.print (hli);
display.print (":");
display.print (ss);
display.println ("AM");
}
int hnub = timeClient.getDay ();
display.println ("'"+arr_days [hnub]+"'");
date_time = timeClient.getFormattedDate ();
int index_date = date_time.indexOf ("T");
Txoj hlua hnub = date_time.substring (0, index_date);
Serial.println (hnub tim);
display.println (hnub tim);
display.display ();
// Qhia thawj kab ntawv}
Kauj Ruam 6: Tau Hnub & Sijhawm
yog tias koj txuas txhua yam kom raug thiab tso cov cai kom raug zoo ib yam ces koj yuav tuaj yeem pom koj ntp moos ua haujlwm ntawm oled zaub li kuv li hauv kev ua haujlwm hauv oled zaub. Thov xa daim duab rau tso tawm.
Pom zoo:
ESP8266 OLED - Tau Txais Sijhawm thiab Hnub Los Ntawm Internet: 8 Kauj Ruam
ESP8266 OLED - Tau Txais Sijhawm thiab Hnub Los Ntawm Is Taws Nem: Hauv qhov kev qhia no peb yuav kawm paub yuav ua li cas kom tau txais hnub thiab sijhawm los ntawm NIST TIME server siv ESP8266 OLED thiab Visuino, Saib cov vis dis aus
Chaw Ua Haujlwm Roj Teeb Hnub Ci System Nrog Pib Hloov Sab Hnub Poob/Sab Hnub Poob Panels thiab Cua Turbine: 11 Kauj Ruam (nrog Duab)
Chaw Ua Haujlwm Roj Teeb Hnub Ci System Nrog Pib Hloov Sab Hnub Poob/Sab Hnub Poob Panels thiab Cua Turbine: Txoj Haujlwm: Ib thaj tsam 200 square ft. Chaw ua haujlwm xav tau roj teeb. Lub chaw haujlwm tseem yuav tsum muaj tag nrho cov tswj, roj teeb thiab cov khoom siv xav tau rau lub kaw lus no. Hnub ci thiab cua zog yuav them cov roj teeb. Muaj teeb meem me ntsis ntawm tsuas yog
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: 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 qhov ESP8266 txoj haujlwm tau nkag mus rau Is Taws Nem, koj tuaj yeem tau txais sijhawm siv Network T
Siv DS1307 thiab DS3231 Lub Sijhawm Teev Sijhawm Sijhawm Nrog Arduino: 3 Kauj Ruam
Siv DS1307 thiab DS3231 Lub Sijhawm Caij Nyoog Sijhawm Nrog Arduino: Peb tseem tau txais kev thov yuav siv DS1307 thiab DS3231 lub sijhawm teev sijhawm nrog Arduino los ntawm ntau qhov chaw-yog li qhov no yog thawj ntawm ob ntu kev qhia yuav siv li cas. Txog qhov kev qhia Arduino no peb muaj ob lub sijhawm teev sijhawm ua haujlwm rau peb
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej