Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:espressif_arduino [2023/11/18 16:31] pczekalskien:iot-open:espressif_arduino [2023/11/21 21:57] (current) ktokarz
Line 28: Line 28:
 void setup() { void setup() {
  delay(1500);  delay(1500);
- /* You can remove the password parameter if you want the AP to be open. */+ /* You can remove the password parameter  
 +           if you want the AP to be open. */
  WiFi.softAP(ssid, password);  WiFi.softAP(ssid, password);
  
Line 83: Line 84:
  
     // This will send the request to the server     // This will send the request to the server
-    // You can try send the GET request to possibly get the response (with error) 
     client.println("Send this data to server");     client.println("Send this data to server");
 +    // Trying to send the GET request possibly responses (with error)
     // client.println("GET /echo");     // client.println("GET /echo");
  
Line 110: Line 111:
 char pass[] = "**************";  // your network password char pass[] = "**************";  // your network password
  
-unsigned int localPort = 2390;      // local port to listen for UDP packets+unsigned int localPort = 2390;   // local port to listen for UDP packets
  
 // NTP servers // NTP servers
Line 129: Line 130:
 WiFiUDP udp; WiFiUDP udp;
  
-// Prototype of the function defined at the end of this file (required in Visual Studio Code)+// Prototype of the function defined at the end of this file  
 +// (required in Visual Studio Code)
 void sendNTPpacket(IPAddress& address); void sendNTPpacket(IPAddress& address);
  
Line 178: Line 180:
   Serial.println(ntpServerIP);   Serial.println(ntpServerIP);
  
-  sendNTPpacket(ntpServerIP); // send an NTP packet to a time server+  // send an NTP packet to a time server 
 +  sendNTPpacket(ntpServerIP);  
 +  
   // wait to see if a reply is available   // wait to see if a reply is available
   delay(1000);   delay(1000);
Line 196: Line 200:
     Serial.println(cb);     Serial.println(cb);
     // We've received a packet, read the data from it     // We've received a packet, read the data from it
-    udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer+    // read the packet into the buffer 
 +    udp.read(packetBuffer, NTP_PACKET_SIZE); 
  
-    //the timestamp starts at byte 40 of the received packet and is four bytes,+    // the timestamp starts at byte 40  
 +    // of the received packet and is four bytes,
     // or two words, long. First, extract the two words:     // or two words, long. First, extract the two words:
  
Line 211: Line 217:
     // now convert NTP time into everyday time:     // now convert NTP time into everyday time:
     Serial.print("Unix time = ");     Serial.print("Unix time = ");
-    // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:+    // Unix time starts on Jan 1 1970.  
 +    // In seconds, that's 2208988800:
     const unsigned long seventyYears = 2208988800UL;     const unsigned long seventyYears = 2208988800UL;
     // subtract seventy years:     // subtract seventy years:
en/iot-open/espressif_arduino.1700325110.txt.gz · Last modified: 2023/11/18 16:31 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0