<h3id="static-ip-assignment"><iclass="fa fa-caret-right"></i> Static IP assignment<aclass="headerlink"href="#static-ip-assignment"title="Permanent link">¶</a></h3>
<p>It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with <em>WiFi.begin</em>.<supid="fnref:1"><aclass="footnote-ref"href="#fn:1"rel="footnote">1</a></sup></p>
<p>To assign a static IP Address, specify it in the <ahref="../api/index.html#staip">AutoConnectConfig parameter</a>. In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed.</p>
<h3id="static-ip-assignment-1"><iclass="fa fa-caret-right"></i> Static IP assignment <supid="fnref:1"><aclass="footnote-ref"href="#fn:1"rel="footnote">1</a></sup><aclass="headerlink"href="#static-ip-assignment-1"title="Permanent link">¶</a></h3>
<p>It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with <em>WiFi.begin</em>.</p>
<p>To assign a static IP to ESP8266 with WIFI_MODE_STA, the following parameters are required:</p>
<ul>
<li>IP address.</li>
<li>Gateway address.</li>
<li>Subnet mask.</li>
<li>Primary DNS server.</li>
<li>Secondary DNS server. (optional)</li>
</ul>
<p>The above parameters must be executed before <em>AutoConnect::begin</em> as <ahref="../api/index.html#staip">arguments of AutoConnectConfig</a>.</p>
<p>Declare only AutoConnect, performs handleClient.</p>
<p><imgsrc="../images/handlePortal.svg"/></p>
<h2id="used-with-mqtt-as-a-client-application">Used with MQTT as a client application<aclass="headerlink"href="#used-with-mqtt-as-a-client-application"title="Permanent link">¶</a></h2>
<p>The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch.</p>
<p>The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.</p>
<p>This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the <ahref="https://thingspeak.com/">ThingSpeak</a> for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as <ahref="https://github.com/knolleary/pubsubclient">MQTT client</a>. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.</p>
<p>Call <ahref="../api/index.html#begin"><strong>AutoConnec::begin</strong></a>. If you need to assign a static IP address, executes <ahref="../api/index.html#autoconnectconfig-api"><strong>AutoConnectConfig</strong></a> before that. </p>
<p>Invokes <ahref="../api/index.html#handleclient"><strong>AutoConnect::handleClient()</strong></a> at inside <codeclass="codehilite">loop()</code> to enable the AutoConnect menu.</p>
<p>'454951' in the example above, but your channel ID should be different. <aclass="footnote-backref"href="#fnref:2"rev="footnote"title="Jump back to footnote 2 in the text">↩</a></p>
</li>
<liid="fn:3">
<p><codeclass="codehilite"><spanclass="cp">#include</span><spanclass="cpf"><ESP8266WebServer.h></span><spanclass="cp"></span></code> does not necessary for uses only client.
<script>
window.onload = function() {
Gifffer();
}
</script> <aclass="footnote-backref"href="#fnref:3"rev="footnote"title="Jump back to footnote 3 in the text">↩</a></p>
<p><codeclass="codehilite"><spanclass="cp">#include</span><spanclass="cpf"><ESP8266WebServer.h></span><spanclass="cp"></span></code> does not necessary for uses only client. <aclass="footnote-backref"href="#fnref:3"rev="footnote"title="Jump back to footnote 3 in the text">↩</a></p>
@ -218,11 +218,19 @@ A home path of AutoConnect is **/\_ac** by default. You can access from the brow
#define AUTOCONNECT_URI "/_ac"
```
### <iclass="fa fa-caret-right"></i> Static IP assignment
### <iclass="fa fa-caret-right"></i> Static IP assignment [^1]
It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*.[^1]
It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*.
To assign a static IP Address, specify it in the [AutoConnectConfig parameter](api.md#staip). In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed.
To assign a static IP to ESP8266 with WIFI\_MODE\_STA, the following parameters are required:
- IP address.
- Gateway address.
- Subnet mask.
- Primary DNS server.
- Secondary DNS server. (optional)
The above parameters must be executed before *AutoConnect::begin* as [arguments of AutoConnectConfig](api.md#staip).
@ -31,7 +31,7 @@ Declare only AutoConnect, performs handleClient.
## Used with MQTT as a client application
The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch.
The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.
This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the [ThingSpeak](https://thingspeak.com/) for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as [MQTT client](https://github.com/knolleary/pubsubclient). This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.
@ -97,18 +97,31 @@ After upload and reboot complete, the message publishing will start via the acce
For the client sketches, the code required to connect to WiFi is the following four parts only.
1. \#include directive[^3]
<imgsrc="../images/include.png"width="55%"/>
Include ```AutoConnect.h``` header file behind the include of ```ESP8266WiFi.h```.
<imgsrc="../images/include.png"width="55%"/>
2. Declare AutoConnect
<imgsrc="../images/declare.png"width="55%"/>
The declaration of the [**AutoConnect variable**](api.md#autoconnect) is not accompanied by ESP8266WebServer.
<imgsrc="../images/declare.png"width="55%"/>
3. Invokes "begin()"
<imgsrc="../images/begin.png"width="55%"/>
Call [**AutoConnec::begin**](api.md#begin). If you need to assign a static IP address, executes [**AutoConnectConfig**](api.md#autoconnectconfig-api) before that.
<imgsrc="../images/begin.png"width="55%"/>
4. Performs "handleClent()" in "loop()"
<imgsrc="../images/handleClient.png"width="55%"/>
Invokes [**AutoConnect::handleClient()**](api.md#handleclient) at inside ```loop()``` to enable the AutoConnect menu.
<imgsrc="../images/handleClient.png"width="55%"/>
[^3]:```#include <ESP8266WebServer.h>``` does not necessary for uses only client.