<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=ESP32%3A_WiFi_contoh</id>
	<title>ESP32: WiFi contoh - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=ESP32%3A_WiFi_contoh"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=ESP32:_WiFi_contoh&amp;action=history"/>
	<updated>2026-04-20T16:44:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=ESP32:_WiFi_contoh&amp;diff=57330&amp;oldid=prev</id>
		<title>Onnowpurbo at 02:13, 6 October 2019</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=ESP32:_WiFi_contoh&amp;diff=57330&amp;oldid=prev"/>
		<updated>2019-10-06T02:13:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:13, 6 October 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int hostPort = 80;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int hostPort = 80;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int BUTTON_PIN = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int BUTTON_PIN = &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;15&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int LED_PIN = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;5&lt;/del&gt;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  const int LED_PIN = &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  void setup()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  void setup()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=ESP32:_WiFi_contoh&amp;diff=57323&amp;oldid=prev</id>
		<title>Onnowpurbo: Created page with &quot;Sumber: https://learn.sparkfun.com/tutorials/esp32-thing-hookup-guide/arduino-example-wifi     #include &lt;WiFi.h&gt;    // WiFi network name and password:  const char * networkNam...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=ESP32:_WiFi_contoh&amp;diff=57323&amp;oldid=prev"/>
		<updated>2019-10-06T01:51:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Sumber: https://learn.sparkfun.com/tutorials/esp32-thing-hookup-guide/arduino-example-wifi     #include &amp;lt;WiFi.h&amp;gt;    // WiFi network name and password:  const char * networkNam...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: https://learn.sparkfun.com/tutorials/esp32-thing-hookup-guide/arduino-example-wifi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;WiFi.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 // WiFi network name and password:&lt;br /&gt;
 const char * networkName = &amp;quot;YOUR_NETWORK_HERE&amp;quot;;&lt;br /&gt;
 const char * networkPswd = &amp;quot;YOUR_PASSWORD_HERE&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 // Internet domain to request from:&lt;br /&gt;
 const char * hostDomain = &amp;quot;example.com&amp;quot;;&lt;br /&gt;
 const int hostPort = 80;&lt;br /&gt;
 &lt;br /&gt;
 const int BUTTON_PIN = 0;&lt;br /&gt;
 const int LED_PIN = 5;&lt;br /&gt;
 &lt;br /&gt;
 void setup()&lt;br /&gt;
 {&lt;br /&gt;
   // Initilize hardware:&lt;br /&gt;
   Serial.begin(115200);&lt;br /&gt;
   pinMode(BUTTON_PIN, INPUT_PULLUP);&lt;br /&gt;
   pinMode(LED_PIN, OUTPUT); &lt;br /&gt;
 &lt;br /&gt;
   // Connect to the WiFi network (see function below loop)&lt;br /&gt;
   connectToWiFi(networkName, networkPswd);&lt;br /&gt;
 &lt;br /&gt;
   digitalWrite(LED_PIN, LOW); // LED off&lt;br /&gt;
   Serial.print(&amp;quot;Press button 0 to connect to &amp;quot;);&lt;br /&gt;
   Serial.println(hostDomain);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop()&lt;br /&gt;
 {&lt;br /&gt;
   if (digitalRead(BUTTON_PIN) == LOW)&lt;br /&gt;
   { // Check if button has been pressed&lt;br /&gt;
     while (digitalRead(BUTTON_PIN) == LOW)&lt;br /&gt;
       ; // Wait for button to be released &lt;br /&gt;
 &lt;br /&gt;
     digitalWrite(LED_PIN, HIGH); // Turn on LED&lt;br /&gt;
     requestURL(hostDomain, hostPort); // Connect to server&lt;br /&gt;
     digitalWrite(LED_PIN, LOW); // Turn off LED&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void connectToWiFi(const char * ssid, const char * pwd)&lt;br /&gt;
 {&lt;br /&gt;
   int ledState = 0;&lt;br /&gt;
 &lt;br /&gt;
   printLine();&lt;br /&gt;
   Serial.println(&amp;quot;Connecting to WiFi network: &amp;quot; + String(ssid));  &lt;br /&gt;
 &lt;br /&gt;
   WiFi.begin(ssid, pwd); &lt;br /&gt;
 &lt;br /&gt;
   while (WiFi.status() != WL_CONNECTED) &lt;br /&gt;
   {&lt;br /&gt;
     // Blink LED while we&amp;#039;re connecting:&lt;br /&gt;
     digitalWrite(LED_PIN, ledState);&lt;br /&gt;
     ledState = (ledState + 1) % 2; // Flip ledState&lt;br /&gt;
     delay(500);&lt;br /&gt;
     Serial.print(&amp;quot;.&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Serial.println();&lt;br /&gt;
   Serial.println(&amp;quot;WiFi connected!&amp;quot;);&lt;br /&gt;
   Serial.print(&amp;quot;IP address: &amp;quot;);&lt;br /&gt;
   Serial.println(WiFi.localIP());&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void requestURL(const char * host, uint8_t port)&lt;br /&gt;
 {&lt;br /&gt;
   printLine();&lt;br /&gt;
   Serial.println(&amp;quot;Connecting to domain: &amp;quot; + String(host));&lt;br /&gt;
 &lt;br /&gt;
   // Use WiFiClient class to create TCP connections&lt;br /&gt;
   WiFiClient client;&lt;br /&gt;
   if (!client.connect(host, port))&lt;br /&gt;
   {&lt;br /&gt;
     Serial.println(&amp;quot;connection failed&amp;quot;);&lt;br /&gt;
     return;&lt;br /&gt;
   }&lt;br /&gt;
   Serial.println(&amp;quot;Connected!&amp;quot;);&lt;br /&gt;
   printLine();&lt;br /&gt;
 &lt;br /&gt;
   // This will send the request to the server&lt;br /&gt;
   client.print((String)&amp;quot;GET / HTTP/1.1\r\n&amp;quot; +&lt;br /&gt;
                &amp;quot;Host: &amp;quot; + String(host) + &amp;quot;\r\n&amp;quot; +&lt;br /&gt;
                &amp;quot;Connection: close\r\n\r\n&amp;quot;);&lt;br /&gt;
   unsigned long timeout = millis();&lt;br /&gt;
   while (client.available() == 0) &lt;br /&gt;
   {&lt;br /&gt;
     if (millis() - timeout &amp;gt; 5000) &lt;br /&gt;
     {&lt;br /&gt;
       Serial.println(&amp;quot;&amp;gt;&amp;gt;&amp;gt; Client Timeout !&amp;quot;);&lt;br /&gt;
       client.stop();&lt;br /&gt;
       return;&lt;br /&gt;
     }&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   // Read all the lines of the reply from server and print them to Serial&lt;br /&gt;
   while (client.available()) &lt;br /&gt;
   {&lt;br /&gt;
     String line = client.readStringUntil(&amp;#039;\r&amp;#039;);&lt;br /&gt;
     Serial.print(line);&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Serial.println();&lt;br /&gt;
   Serial.println(&amp;quot;closing connection&amp;quot;);&lt;br /&gt;
   client.stop();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void printLine()&lt;br /&gt;
 {&lt;br /&gt;
   Serial.println();&lt;br /&gt;
   for (int i=0; i&amp;lt;30; i++)&lt;br /&gt;
     Serial.print(&amp;quot;-&amp;quot;);&lt;br /&gt;
   Serial.println();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Pranala Menarik==&lt;br /&gt;
&lt;br /&gt;
* [[ESP32]]&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>