The use of the ESP8266 in the world of IoT

User avatar
By AlthePal_Auckland
#82156 I have an ESP8266 which I am loading up with this code from the Arduino 1.8 (IDE is on Windows)

==================================================
#include "ESP8266WiFi.h"
#include "ESP8266WebServer.h"
#include "ESP8266mDNS.h"

ESP8266WebServer server(80);

void setup() {

Serial.begin(115200);
WiFi.hostname("solarmeter");
WiFi.begin("Callisto", "LiBai701"); //Connect to the WiFi network

while (WiFi.status() != WL_CONNECTED) { //Wait for connection

delay(200);
Serial.println("Waiting to connect…");

}

Serial.println("");
Serial.println(F("[CONNECTED]"));
Serial.print("[IP ");
Serial.print(WiFi.localIP());
Serial.println("]");

if (MDNS.begin("solarmeter",WiFi.localIP())) { //Start mDNS
Serial.println("MDNS started for solarmeter");
MDNS.addService("http","tcp",80);
}



server.on("/other", []() { //Define the handling function for the path
server.send(200, "text / plain", "Other URL");
});
server.on("/", handleRootPath); //Associate the handler function to the path
server.begin(); //Start the server
Serial.println("Server listening..");

}

void loop() {

server.handleClient(); //Handling of incoming requests

}

void handleRootPath() { //Handler for the root path

server.send(200, "text/plain", "Hello world");

}
=============================================

When I run this and go to my Raspberry Pi I can
ping 192.168.1.140 and that works
ping solarmeter and that works, but it responds that its full name is solarmeter.hub
ping solarmeter.hub and that works.
ping solarmeter.local and that DOES NOT WORK

why is that?

It leads me to question, where exactly does the .local come from. What is it about the mDNS include at the top that would make it respond to .local anyway. I have not actually specified any .hub TLD anywhere ever in this project, so I cant see why the ESP8266 responds with .hub.

Any help in explaining this much appreciated. I dont really want to go forward on my IoT project referring to the device as solarmeter.hub when I dont know where that comes from.
User avatar
By AlthePal_Auckland
#82237 Further information on this. I went to my router, and the DHCP has a configuration box for a local domain name. and in this box it has "hub". I didnt know that was part of the functionality of DHCP ie to specify the local domain name. I thought the specification of .local was some sort of mDNS hard coded default? does anyone have more information on where the .local comes from?