So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By KDB
#69092 The question is : does it work !!
In my configuration it doesn't !!!

rudy wrote:Don't add it if you don't want it.

sprintf(HostName, "MyESPAP");
User avatar
By KDB
#69191 Hi marinayotte !

Do you see my mistake ?
Never had such problems with a simple program :

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiClient.h>

const char* ssid = "********";
const char* password = "*********";
char hostString[16] = {0};

// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);

void setup(void)
{
Serial.begin(115200);
sprintf(hostString, "ESP_%06X", ESP.getChipId());
Serial.print("Hostname: ");
Serial.println(hostString);
WiFi.hostname(hostString);

// Connect to WiFi network
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());


if (!MDNS.begin(hostString)) {
Serial.println("Error setting up MDNS responder!");
while(1) {
delay(1000);
}
}
Serial.println("mDNS responder started");

// Start TCP (HTTP) server
server.begin();
Serial.println("TCP server started");

// Add service to MDNS-SD
MDNS.addService("http", "tcp", 80);
}









martinayotte wrote:What do you mean "not working" ?

Does your router shows that ESP3 hostname in the IP leases list ?

Don't expect to be able to do "ping ESP3", it won't work since the DNS doesn't know this hostname.
Use mDNS service on your ESP, install Bonjour on Windows, and then "ESP3.local" will be resolved.