Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Leonas
#45687 Just started programming for the Arduino in December and now I am on my second project involving a Mega and Feather Huzzah ESP8266. I am so far that the program on both is pretty much completed (ESP gets xml API train and weather data and rss news feeds, and sends it over to the Mega to display them) but now I would like to be able to adapt certain settings regarding the ESP (ssid, password for the local Wifi router, switching on/off certain feeds, adapt the URLs of hose data providers, colors of the display on the Mega) via a web page on my phone / tablet / computer. This is where I got stuck, or better: overwhelmed. I just don't know where to begin. I see files, libraries and folders like BasicHttpClient, HelloServer, ESP8266WiFi, ESP8266WebServer, ESP8266mDNS, DNSServer, ESP8266mDNS, mDNS_Web_Server, WiFiScan, WiFiMulti, ESP8266WiFiAP, ESP8266WiFiSTA, WiFiServer, WiFiClient, ESP8266HTTPClient, then there's WifiManager, AJAX, POST/GET, WebSockets, MQTT etc. etc. It's just too much to get an overview of just what I need. This morning I saw a post from someone on Instructables(http://www.instructables.com/id/Control-ESP8266-Over-the-Internet-from-Anywhere/?ALLSTEPS) with source code http://www.instructables.com/files/orig/FFD/AL3D/IN3EI5D1/FFDAL3DIN3EI5D1.txt who is able to provide a webpage server by just including
Code: Select all#include <ESP8266WiFi.h>

No Server, DNS, STA or AP, just ESP8266WiFi.h.
I could start working from that but then the question remains what are all those other .h files for?
Does anyone know a clear starting point somewhere on the web to enlighten me? Thanks in advance!
User avatar
By Leonas
#46669 Nobody? Is there no documentation about e.g. when to just use
Code: Select all#include <ESP8266WiFi.h>
WiFiServer server(80);
instead of
Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
?
To avoid misunderstandings: I am very happy with the port of the ESP8266 code to the Arduino platform and I know that documentation always trails coding, so I am not complaining. But I currently have about 5 cm of printed examples and libraries and because of all the trees I can't see the forest (Dutch proverb). Any pointers to basic documentation is very much appreciated.
User avatar
By rudy
#46709
This is where I got stuck, or better: overwhelmed. -


Yeah, I know what that is like. I want to program the ESP8266 and I find that I need to learn JavaScript, learn CSS, learn what is new about HTML, learn Ajax, learn, Learn about internet protocols, learn ...

The learning curve is pretty steep if you want to have control. A lot of people will take an easier route and make use of script or canned solutions. It just depends on how far you want to go.

There isn't a lot of learning information. Just think of yourself as being in the cutting edge. An early adopter. Just assume that it is going to take a while. But eventually more and more will sink in and make sense.
User avatar
By bbx10node
#46728
Leonas wrote:Nobody? Is there no documentation about e.g. when to just use
Code: Select all#include <ESP8266WiFi.h>
WiFiServer server(80);
instead of
Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);



The code on instructables is interesting but I would not build on it. Start with ESP8266WebServer. The reason is both listen on a TCP port but ESP8266WebServer implements the HTTP protcol by parsing the HTTP request headers in the library. The instructables code sketch (WiFiServer) uses simple string matching (see req.indexOf) to parse the HTTP headers. This works OK for demo programs but will require lots of work for non-trivial web pages. If you start with the instructables example, you would end up implementing the equivalent code already available in ESP8266WebServer.

mDNS is a nice feature for servers because it allow clients to connect to the server without knowing its IP address. This appears in many web server example programs. For example, if the code contains

Code: Select all  if (MDNS.begin("esp8266")) {


clients can connect to http://esp8266.local. Well, it works for IOS, Android, and Linux. I am not sure about Windows because I rarely use it. The clients must know the port number if it is not 80.

No Server, DNS, STA or AP, just ESP8266WiFi.h.
I could start working from that but then the question remains what are all those other .h files for?


AP mode means users can use their phone, tablet, or computer WiFi settings to scan for WiFi access points to find the ESP. The users do not need to know the IP address or MDNS name. Once connected the ESP AP, the users are presented with a web page to configure the ESP SSID, password, and other parameters. Captive DNS forces the users to the ESP web server
no matter what URL they input. The following library implements this and more.

https://github.com/tzapu/WiFiManager