NTP-UTC-UHR mit ESP8266-01S + 0,96" OLED-Display - AZ-Delivery

Heeft niet iedereen gemerkt dat hun klokken (als je niet radio-koekoeken) voor of na de tijd gaan?Uiterlijk tegen de volgende verandering in de zomer of herfst, zijn alle klokken weer op een juiste tijd gezet.

De computer synchroniseert regelmatig zijn interne klok met een zogenaamde NTP server.De NTP server is een radioklok voor de computer.

We kunnen zo'n NTP server gebruiken en een ESV8266-01S module gebruiken via WLAN.Deze tijd zal direct worden weergegeven op een OLED display.

Wat we nodig hebben:

1 x ESV8266-01S
1 x 0,96"OLED-Display
een paar Jumper lijnen
1 x Batterij houder voor 2-batterijen

1 x Programmeringsadapter USB of FTDI FT232RL

3D gedrukte behuizing van apparatuur

 

De hardware bedrading:

Om de klok onafhankelijk van de computer te bedienen gebruiken we twee batterijen met elke 1.5V. Met 3V totale spanning staan we onderaan de hardware.

De massa (min pool) van de batterij is verbonden met de GND verbindingen op de ESV8266-01S en OLED display.> Zwarte lijn
De 3V (Plus-Pol) van de batterij is verbonden met VCC aan de ESV8266-01S en display, bovendien moet de CH-u PD (Chip-Enble) op hoog geplaatst worden (3V).> Rode lijn
Last but not least, de twee iqc lijnen zijn verbonden van het display aan de ESV8266-01S, waaraan we de twee beschikbare GPIO's moeten gebruiken.De Gele draad correspondeert met SCK en is verbonden met GPIO2.De Groene lijn is SDA en is verbonden met GPIO0.

Als alles verbonden is, kunnen we overschakelen op programmeren.Voor het programmeren moet de GPIO0 tijdens het begin op de massa worden gezet!

De software:

 

"35; omvat "ESP826WiFi.h"           
"35; omvat <WiFi..H>
"35; omvat <Draad.H>
"35; omvat font.h.

WiFiClient client;

char* pagina     = WiFi-SSID;
char* wachtwoord = WiFi.;
char buffer[20];

35; definieer OLED adres  0x3c

ongeschikt int localPortGenericName = 2390; 
IPAdres timeServerIP;
const char* ntpServerName = "zwembad.ntp.org";

const int NTP VERPAKKING = 48;
uitwisseling PakketBuffer[ NTP VERPAKKING];
WifiUDP nie;

statisch Leeg Weergave opnieuw instellen(Leeg)
{   displayOff();   duidelijke weergave();   displayOn();
}

Leeg StartUp OLED()
{   INit OLED();   Weergave opnieuw instellen();   displayOff();   setX(0,0);   duidelijke weergave();   displayOn();
}

Leeg displayOn(Leeg)
{     sendcommando(0xaf);
}

Leeg displayOff(Leeg)
{   sendcommando(0xae);
}

statisch Leeg duidelijke weergave(Leeg)
{   ongeschikt char i,c;   voor(c=0;c<8;c++)   {      setX(c,0);         {       voor(i=0;i<128;i++)       {         SendCharGenericName(0);       }     }   }
}
 
statisch Leeg SendCharGenericName(ongeschikt char datum) 
{   Draad.start(OLED adres);   Draad.schrijven(0x40);   Draad.schrijven(datum);
  Draad.endTransmissie();
} statisch Leeg sendCharXY(ongeschikt char datum, int X, int Y) {  setX(X, Y);  Draad.start(OLED adres);  Draad.schrijven(0x40);  voor(int i=0;i<8;i++)    Draad.schrijven(pgm leesappartement(myFontName[datum-0x20]+i));      Draad.endTransmissie(); } statisch Leeg sendcommando(ongeschikt char met) {  Draad.start(OLED adres);  Draad.schrijven(0x80);  Draad.schrijven(met);  Draad.endTransmissie();
}
statisch Leeg setX(ongeschikt char rij,ongeschikt char c) {  sendcommando(0xb0+rij);  sendcommando(0x00+(8*c&0x0f));  sendcommando(0x10+((8*c>>4)&0x0f)); } statisch Leeg sendStrGenericName(ongeschikt char *tekenreeks) {  ongeschikt char i=0;  terwijl(*tekenreeks)  {    voor(i=0;i<8;i++)    {      SendCharGenericName(pgm leesappartement(myFontName[*tekenreeks-0x20]+i));    }    *tekenreeks++;  } } statisch Leeg sendStrXY( char *tekenreeks, int X, int Y) {  setX(X,Y);  ongeschikt char i=0;  terwijl(*tekenreeks)  {    voor(i=0;i<8;i++)    {      SendCharGenericName(pgm leesappartement(myFontName[*tekenreeks-0x20]+i));    }    *tekenreeks++;  } } statisch Leeg INit OLED(Leeg) {   sendcommando(0xae);   sendcommando(0xa6);    sendcommando(0xAE);    sendcommando(0xD5);    sendcommando(0x80);    sendcommando(0xA8);    sendcommando(0x3F);    sendcommando(0xD3);    sendcommando(0x0);    sendcommando(0x40 | 0x0);    sendcommando(0x8D);    sendcommando(0x14);    sendcommando(0x20);    sendcommando(0x00);    sendcommand(0xA0 `124; 0x1); /180 Turn Grade    sendcommando(0xA0);    sendcommand(0xC8); /180 Turn Grade    sendcommando(0xC0);    sendcommando(0xEN);    sendcommando(0x12);    sendcommando(0x81);    sendcommando(0xCF);    sendcommando(0xd9);    sendcommando(0xF1);    sendcommando(0xDB);    sendcommando(0x40);    sendcommando(0xA4);    sendcommando(0xA6);   duidelijke weergave();   sendcommando(0x2e);   sendcommando(0x20);   sendcommando(0x00); } Leeg Teken WIFI() {   duidelijke weergave();   setX(0,0);   voor(int i=0;i<128*8;i++)   {    SendCharGenericName(pgm leesappartement(WIFI+i));   }   sendcommando(0xaf); } Leeg De heer Draw WAVES() {   duidelijke weergave();   setX(0,0);      voor(int i=0;i<128*8;i++)   {    SendCharGenericName(pgm leesappartement(rfgolven+i));   }   sendcommando(0xaf); }
Leeg setup() {  vertraging(200);  Draad.spelden(0, 2);  Draad.start();  StartUp OLED();  duidelijke weergave();    sendStrXY("***************", 0, 1);  sendStrXY(START, 0, 1);    WiFi..start(pagina, wachtwoord);   terwijl (WiFi..status() != WL VERBAND) {    sendStrXY(Verbinden, 0, 1);    vertraging(250);    sendStrXY("               ", 0, 1);   }  IPAdres sm = WiFi..localIP();     String ipStrGenericName = String(sm[0]) + '.' + String(sm[1]) + '.' + String(sm[2]) + '.' + String(sm[3]);  ipStrGenericName.toCharArray(buffer, 20);  sendStrXY((buffer), 0, 1);  nie.start(localPortGenericName);  vertraging(2000); } Leeg ren() { WiFi..hostByName(ntpServerName, timeServerIP);  verzenden(timeServerIP);  vertraging(200); int cb = nie.parsePacket();  indien (!cb) {  }  sm {  nie.lezen(PakketBuffer, NTP VERPAKKING);    ongeschikt lang Hoogwoord = woord(PakketBuffer[40], PakketBuffer[41]);    ongeschikt lang lowWord = woord(PakketBuffer[42], PakketBuffer[43]);    ongeschikt lang secsSince1900 = Hoogwoord << 16 | lowWord;    const ongeschikt lang Zeventijaren = 220898800UL;    ongeschikt lang epoch = secsSince1900 - Zeventijaren;    int tijd = (epoch  % 86400L) / 3600;    Serie.Afdrukken(tijd);    int minuten =(epoch  % 3600) / 60;    int tweede = epoch % 60;        String r;        r = String(int(tijd/10));    char uren[2];    r.toCharArray(uren,2);        r = String(int(tijd%10));    char uren[2];    r.toCharArray(uren,2);    r = String(int(minuten/10));    char min[2];    r.toCharArray(min,2);        r = String(int(minuten%10));    char min[2];    r.toCharArray(min,2);           r = String(int(tweede/10));    char sec1[2];    r.toCharArray(sec1,2);    r = String(int(tweede%10));    char sec2[2];    r.toCharArray(sec2,2);        sendStrXY("00:00:00", 2, 1);         sendStrXY(uren, 2, 4);      sendStrXY(uren, 2, 5);      sendStrXY(":", 2, 6);            sendStrXY(min, 2, 7);      sendStrXY(min, 2, 8);      sendStrXY(":", 2, 9);      sendStrXY(sec1, 2, 10);      sendStrXY(sec2, 2, 11);         vertraging(50);      } } ongeschikt lang verzenden(IPAdres& adres) {  herinnering(PakketBuffer, 0, NTP VERPAKKING);  PakketBuffer[0] = 0b11100011;     PakketBuffer[1] = 0;       PakketBuffer[2] = 6;       PakketBuffer[3] = 0xEG;  PakketBuffer[12]  = 49;  PakketBuffer[13]  = 0x4E;  PakketBuffer[14]  = 49;  PakketBuffer[15]  = 52;  nie.start(adres, 123);  nie.schrijven(PakketBuffer, NTP VERPAKKING);  nie.Eindverpakt(); }

font.h (Bestand als nieuw tabblad)
const char myFontName[][8] PROGRAMMA = {   {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
{0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
{0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
{0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
{0x00,0x36Name,0x49,0x55,0x22,0x50,0x00,0x00},
{0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
{0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
{0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
{0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
{0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
{0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
{0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
{0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
{0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
{0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
{0x00,0x00,0x42GenericName,0x7F,0x40,0x00,0x00,0x00},
{0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
{0x00,0x22,0x41,0x49,0x49,0x36Name,0x00,0x00},
{0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
{0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
{0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
{0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
{0x00,0x36Name,0x49,0x49,0x49,0x36Name,0x00,0x00},
{0x00,0x06,0x49,0x49,0x29Name,0x1E,0x00,0x00},
{0x00,0x00,0x36Name,0x36Name,0x00,0x00,0x00,0x00},
{0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
{0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
{0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
{0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
{0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
{0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
{0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
{0x00,0x7F,0x49,0x49,0x49,0x36Name,0x00,0x00},
{0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
{0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
{0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
{0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
{0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
{0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
{0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
{0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
{0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
{0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
{0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
{0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
{0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
{0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
{0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
{0x00,0x7F,0x09,0x19,0x29Name,0x46,0x00,0x00},
{0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
{0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
{0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
{0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
{0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
{0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
{0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
{0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
{0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
{0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
{0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
{0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
{0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
{0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
{0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
{0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
{0x00,0x38,0x44,0x44,0x28Name,0x00,0x00,0x00},
{0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
{0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
{0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
{0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
{0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
{0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
{0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
{0x00,0x7F,0x10,0x28Name,0x44,0x00,0x00,0x00},
{0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
{0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
{0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
{0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
{0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
{0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
{0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
{0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
{0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
{0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
{0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
{0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
{0x00,0x44,0x28Name,0x10,0x28Name,0x44,0x00,0x00},
{0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
{0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
{0x00,0x08,0x36Name,0x41,0x00,0x00,0x00,0x00},
{0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
{0x00,0x41,0x36Name,0x08,0x00,0x00,0x00,0x00},
{0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
{0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} 
};

// bitmap logo
const char WIFI[] PROGRAMMA = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8,
0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8,
0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0,
0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0,
0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xF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0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x0F,
0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F,
0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x1F, 0x0F,
0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


// bitmap
const char rfgolven[] PROGRAMMA = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x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x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F,
0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F,
0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x0E, 0x0E, 0x0E, 0x1E, 0x1E, 0x3F,
0x3F, 0x3E, 0x1E, 0x1E, 0x0E, 0x0E, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

Na het programmeren integreren we alles in de gedrukte behuizing en hebben we een mooie ingebouwde, altijd up-to-date klok.

 



De klok werkt alleen nu als een NTP server ons bereikt!

Als een taak kunt u overwegen een wijziging van de software, zodat de tijd alleen wordt bijgewerkt tot de volledige minuut of uur en ondertussen berekenen we autonoom in ESV8266-01S.

Er zijn ook andere lijnen beschikbaar op het display, die kunnen worden aangevuld met een datum.

Aan de bovenkant van de behuizing zijn er nog steeds gaten voor schakelaars, wat dacht je van een aan/uit schakelaar?

 

Veel plezier met het herbouwen en laat uw ideeën voor verbetering in de commentaren.

DisplaysEsp-8266Projekte für fortgeschrittene

3 Reacties

yetti

yetti

Das sollte doch auch einfacher gehen mittels time.h und configtime,
dann kann man noch den localen Router noch als Zeitserver verwenden, denn kann ohne Probleme öfter abfragen. Ist dann zwar nicht PTB aber schon sehr genau für eine normale Uhr und das sollte für die meisten weiteren Projekte reichen.

#include

void setup() {
//Wifi
….
}

void loop () {
….
// alle x Minuten
….
Serial.println(“aktuelle Zeit holen”);
getPTB();

// Zeit holen aus dem internen Speicher.
Serial.println(“Readtime()”);
readtime(); // Zeit einlesen
….
}

void getPTB(){
configTime(0, 0, “192.168.1.1”, “ptbtime1.ptb.de”, “ptbtime2.ptb.de”); // locale Fritzbox und ptb.de
setenv(“TZ”, “CET-1CEST,M3.5.0,M10.5.0/3”, 1); // locale Zeit einstellen mit Sommerzeit
Serial.print("Waiting for time “);
while (!time(nullptr)) {
Serial.print(”.");
delay(100);
}
delay(100); // warten auf NTP Zeit
}

void readtime() {
time_t now = time(nullptr);
struct tm*timeinfo;
time(&now);
timeinfo = localtime(&now);
year = 1900 + timeinfo→tm_year;
month = 1 + timeinfo→tm_mon;
day = timeinfo→tm_mday;
hour = timeinfo→tm_hour;
minute = timeinfo→tm_min;
second = timeinfo→tm_sec;
// Serial.printf(“%02u-%02u-%4u\n”, day, month, year);
Serial.printf(“%02u:%02u:%02u \n”, hour, minute, second);

if (year < 2000) { // das war nix Zeit falsch ESP.restart(); }

}

Kai

Kai

Hallo Markus,
ein ESP arbeitet leider viel zu ungenau bzw. arbeitet er Funktionalitäten wie WLAN vorrangig ab und vernachlässigt dann andere Prozesse. Würde die Zeit nicht stündlich abgefragt käme es mitunter pro Stunde zu einem Fehler von bis zu 3 Minuten. Eine Lösung ist ein RTC-Modul oder das WLAN zu deaktivieren oder mit der Funktion Millis die verstrichene Zeit der Hintergrundprozesse zu ermitteln. Es geht hier ums basteln und nicht um High-End-Geräte…

Markus Gebhard

Markus Gebhard

Nettes Beispiel, aber bitte fair sein und die Regularien und Doku des Zeitservers beachten. Siehe https://www.pool.ntp.org/vendors.html und insbesondere die Richtlinie "Don’t send excessively frequent queries. Reasonable query intervals are typically from once or twice a day to a 4-5 times an hour depending on the application. Really consider how often the device will need “fresh time”. A standard ntpd or openntpd server works, too." – bitte vermeiden, andauernd eine Zeitabfrage zu senden, weil diese eben doch Bandbreite verbraucht und damit andere in Mitleidenschaft zieht.

Laat een reactie achter

Alle opmerkingen worden voor publicatie gecontroleerd door een moderator

Aanbevolen blogberichten

  1. ESP32 jetzt über den Boardverwalter installieren - AZ-Delivery
  2. Internet-Radio mit dem ESP32 - UPDATE - AZ-Delivery
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1 - AZ-Delivery
  4. ESP32 - das Multitalent - AZ-Delivery