<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>access point Archives | Teach Me Microcontrollers!</title>
	<atom:link href="https://www.teachmemicro.com/tag/access-point/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.teachmemicro.com/tag/access-point/</link>
	<description>Microcontroller Tutorials and Resources</description>
	<lastBuildDate>Sun, 15 Oct 2023 21:12:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://www.teachmemicro.com/wp-content/uploads/2019/04/blue-icon-65x65.png</url>
	<title>access point Archives | Teach Me Microcontrollers!</title>
	<link>https://www.teachmemicro.com/tag/access-point/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>ESP32 WiFi Manager &#124; Dynamic SSID and Password</title>
		<link>https://www.teachmemicro.com/esp32-wifi-manager-dynamic-ssid-password/</link>
					<comments>https://www.teachmemicro.com/esp32-wifi-manager-dynamic-ssid-password/#comments</comments>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Tue, 05 Jan 2021 23:17:27 +0000</pubDate>
				<category><![CDATA[ESP32 Tutorial]]></category>
		<category><![CDATA[access point]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[iot]]></category>
		<category><![CDATA[wifi]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=4857</guid>

					<description><![CDATA[<p>If you've been following my tutorials on ESP32, then you'll notice that the WiFi SSID and password are always hardcoded. This tutorial will show you a way to change the WiFi credentials without needing to edit and re-upload your sketch. Our aim is to create a simple ESP32 WiFi manager. Overview There are two scenarios &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/esp32-wifi-manager-dynamic-ssid-password/">ESP32 WiFi Manager | Dynamic SSID and Password</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you've been following my <a href="https://www.teachmemicro.com/category/tutorials/esp32-tutorial/">tutorials on ESP32</a>, then you'll notice that the WiFi SSID and password are always hardcoded. This tutorial will show you a way to change the WiFi credentials without needing to edit and re-upload your sketch. Our aim is to create a simple <a href="https://www.win-source.net/products/detail/espressif/esp32-pico-d4.html">ESP32</a> WiFi manager.</p>
<h3>Overview</h3>
<p>There are two scenarios where you would need a WiFi SSID and password. The first is when your ESP32 or ESP8266 is in <em>station mode</em> and another is when those microcontrollers are in <em>access point</em> mode.</p>
<p><strong>Station Mode</strong> - device connects to another WiFi router</p>
<p><strong>Access Point Mode</strong> - device acts as the WiFi router</p>
<p>In station mode:</p>
<pre class="lang:arduino decode:true "><code>WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);</code></pre>
<p>In access point mode:</p>
<pre class="lang:arduino decode:true "><code>WiFi.mode(WIFI_AP);
WiFi.softAp(ssid, password);</code></pre>
<p>Both <em>begin() </em>and <em>softAp()</em> functions accept char array pointers and are <em>normally</em> prefixed as constants.</p>
<pre class="lang:arduino decode:true "><code>const char * ssid = "my-wifi-ssid"
const char * password = "my-wifi-password"</code></pre>
<p>So our aim is to have these WiFi credentials not be hardcoded but instead come from user input. If so, then ideally, the device should be in access point mode first then shifts to station mode once it gets the WiFi credentials from the user.</p>
<h3><strong>Step 1: Create a Form</strong></h3>
<p>Once the user connects to the device which is in access point mode, there should be a page to which the WiFi credentials can be registered or updated. For that, we'll create a simple HTML form:</p>
<pre class="lang:arduino decode:true"><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"&gt;
  &lt;meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0"&gt;
  &lt;title&gt;WiFi Creds Form&lt;/title&gt;
  &lt;style&gt;
   body { background-color: #808080; font-family: Arial, Helvetica, Sans-Serif; Color: #000000; text-align:center; }
  &lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;h3&gt;Enter your WiFi credentials&lt;/h3&gt;
  &lt;form action="/" method="post"&gt;
  &lt;p&gt;
   &lt;label&gt;SSID:&amp;nbsp;&lt;/label&gt;
   &lt;input maxlength="30" name="ssid"&gt;&lt;br&gt;
   &lt;label&gt;Key:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/label&gt;&lt;input maxlength="30" name="password"&gt;&lt;br&gt;&lt;br&gt;
   &lt;input type="submit" value="Save"&gt; 
  &lt;/p&gt;
  &lt;/form&gt;
 &lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>This form has two fields, <em>ssid</em> and <em>password</em> which would contain the WiFi creds from the user. These creds will be readable once the Save button is clicked.</p>
<p>Assuming this form is the root page of the web server hosted by the device, then we can just use the <em>arg()</em> function to retrieve the credentials:</p>
<pre class="lang:arduino decode:true "><code>server.on("/", handleRoot);
...
}

void handleRoot() {
  if (server.hasArg("ssid")&amp;&amp; server.hasArg("password")) {
    String ssid = server.arg("ssid");
    String password = server.arg("password");
    // Do next steps here
   ...
   ... 
  }
  else {
    // If one of the creds is missing, go back to form page
    server.send(200, "text/html", INDEX_HTML);
  }
}</code></pre>
<h3><strong>Step 2: Store Data to EEPROM</strong></h3>
<p>It is logical to store the WiFi creds so that we don't have to ask for them again if the device restarts. For this, we use ESP32's EEPROM.</p>
<p>We initialize two <em>char arrays</em> with a fixed size, preferably equal to the <em>maxlength</em> attribute of our text fields in the form. Then we use the <em>toCharArray()</em> function to convert the Strings <em>ssid </em>and <em>password</em> to char arrays, before finally writing to EEPROM using the <em>writeString()</em> function.</p>
<pre class="lang:arduino decode:true"><code>...
char buff1[30];
char buff2[30];
ssid.toCharArray(buff1,30);
password.toCharArray(buff2,30); 
EEPROM.writeString(100,buff1);
EEPROM.writeString(200,buff2);
...</code></pre>
<p>This will now save the WiFi credentials to memory and will stay there regardless if the device is powered or not.</p>
<h3><strong>Step 3: Read Data from EEPROM and Fire Away</strong></h3>
<p>Now that we are able to acquire the creds from the user and store it in memory, the next thing is to be able to retrieve them from EEPROM. This should be done at the start of the sketch/code so that you wouldn't need to load the form again (unless explicitly).</p>
<pre class="lang:arduino decode:true "><code>String s = EEPROM.readString(100);
String p = EEPROM.readString(200);</code></pre>
<p>Here we read the data from EEPROM. Note that the numbers are the specific memory location for the SSID and passwords. If there's nothing there then we load the form. Otherwise, we skip the form and continue. To check if there are WiFi creds on EEPROM, just do:</p>
<pre class="lang:arduino decode:true "><code>if(s.length() &lt;= 0 &amp;&amp; p.length() &lt;= 0){
   // Load form since no SSID and password found
  ...
}</code></pre>
<p>The full sketch for this tutorial is on <a href="https://github.com/kurimawxx00/wifi-manager">this repository</a>.</p>
<p>The code pointed above, on initial commit, will not work on ESP8266 boards yet. We will remove this notice once it's been updated or you can check the repo regularly</p>
<h3><strong>Using the Application</strong></h3>
<p>After uploading the code in the repo pointed, the ESP32 will broadcast an access point:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026.jpg"><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-4870" src="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026-1024x444.jpg" alt="ESP32 access point name for WiFi Manager" width="618" height="268" srcset="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026-1024x444.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026-300x130.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026-768x333.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0026.jpg 1224w" sizes="auto, (max-width: 618px) 100vw, 618px" /></a></p>
<p>The password for this access point is <em><strong>12345678</strong></em><em>.</em></p>
<p>Once connected to the AP, go to <strong><em>192.168.4.1</em></strong>. This is the default access point IP. You can specify this on the code by using:</p>
<pre>IPAddress IP = {10, 10, 1, 1};
IPAddress NMask = (255, 255, 255, 0);
...
WiFi.softAPConfig(IP, IP, NMask);
</pre>
<p>This form should be visible on the IP address:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025.jpg"><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-4871" src="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025-1024x538.jpg" alt="Form for entering WiFi creds" width="618" height="325" srcset="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025-1024x538.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025-300x157.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025-768x403.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0025.jpg 1242w" sizes="auto, (max-width: 618px) 100vw, 618px" /></a></p>
<p>Enter your router's SSID and password and click <em>Save</em>. The device will restart and store the credentials to EEPROM.</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027.jpg"><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-4872" src="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027-1024x261.jpg" alt="Success message" width="618" height="158" srcset="https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027-1024x261.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027-300x76.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027-768x195.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2021/01/IMG_0027.jpg 1242w" sizes="auto, (max-width: 618px) 100vw, 618px" /></a></p>
<p>The access point will be gone and the ESP32's LED will blink every second. To change the WiFi credentials, just short pin 15 to VCC.</p>
<p>For any questions, clarifications or suggestions, kindly drop a comment below!</p>
<p>The post <a href="https://www.teachmemicro.com/esp32-wifi-manager-dynamic-ssid-password/">ESP32 WiFi Manager | Dynamic SSID and Password</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.teachmemicro.com/esp32-wifi-manager-dynamic-ssid-password/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: www.teachmemicro.com @ 2026-11-25 09:13:33 by W3 Total Cache
-->