Things used in this project
This is a software-only project
Note: ArduinoIDE 1.6.7 users should read my message here.
Please refer to This Hackster.io Project for the basics of using and connecting the ESP8266 in the Arduino IDE environment. My lab tests were performed on the ESP8266-01 which is the least capable of all the models, so this software should run on any of the breakout boards available. I am using Arduino 1.6.6 as the IDE environment and version 1.6.5-947-g39819f0 of the ESP8266-for-Arduino. You are reminded that this environment is still experimental and that changes made often break existing code. You can find installation instructions here, please only use the instructions under the heading: Installing with Boards Manager.
Have you ever wondered...
Free WiFi... you just find the Access Point name, connect, and you are on a landing page. At my regular Marriotts, I receive my eKey at the front desk in a paper folder with the current WiFi key written on the envelope. Recently, at one hotel, I had to put in the initial of my last name and my room number. After that, I was off on the Internet.
So, is the Captive Portal stuff magic? In a sense, there is some slight-of-hand behind the scenes with the Access Point connection to your smartphone, tablet, or notebook.
But, can the inexpensive ESP8266 when used as an Access Point perform the same magic? The answer is a definitive "YES". By using a little creative coding with the AP DNS service, a web browser remains captured no matter what URL they type (some browsers do require a properly formatted page request, however: for example, if you do not allow search from the address line.)
How is DNS redirection useful?
Not every ESP8266 needs an Internet connection! Only those devices that present a status that one wishes to monitor or control over the Internet need a router connection. For in-home use, you can enhance security by programming the ESP8266 to be an Access Point (AP) and a Web Server. By using DNS redirection with a connected device (I use an old cellphone and cheap table with WiFi as my remote control readers.)
I can simply connect to the AP and type "display.com" in the address bar of Chrome and off the browser goes to the landing page - I do not need to know the IP address of the web server because the DNS request is captured by the ESP8266 AP and redirected to the ESP8266 webpage. (In IE, I just type anything in the address bar, for example "junk" and press Enter.)
Show me the magic
// if DNSServer is started with "*" for domain name,
// it will reply with the provided IP to all DNS requests
dnsServer.start(DNS_PORT, "*", apIP);
I know, kind-of anticlimactic, ugh?
How can I use this technique?
Security, for one thing: no Internet connection means nothing sneaking in through the firewall. Status devices, mainly send-only, where a remote ESP8266 or smart device is used to aggregate and display sensor information. For nodes that accept commands, you should implement some security access to the AP: password, hidden login pages, etc.
If you have a mischief nature, configure a fake page and give your overnight friends the AP "guest" name. Every page they attempt to go to will come back like a boomerang - or, you can randomly select a few pages just to up the excitement ;)
I am using one of these AP units in my attic and accessing it simply gives me the attic temperature. When I get around to connecting a 120V relay, I will implement an override for the automatic attic vent which is now a "dumb" device using a bimetal sensor.
No preview (download only).
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!