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

Moderator: igrr

User avatar
By MSoubhi
#90516 I am starting with esp01s , and I am trying to run the example


Code: Select all/*
  ESP8266 mDNS-SD responder and query sample

  This is an example of announcing and finding services.

  Instructions:
  - Update WiFi SSID and password as necessary.
  - Flash the sketch to two ESP8266 boards
  - The last one powered on should now find the other.
*/

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

#ifndef STASSID
#define STASSID "My_Home_NetWork"
#define STAPSK  "mohamed&aya"
#endif

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

void setup() {
  Serial.begin(115200);
  delay(100);
  Serial.println("\r\nsetup()");

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

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(250);
    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!");
  }
  Serial.println("mDNS responder started");
  MDNS.addService("esp", "tcp", 8080); // Announce esp tcp service on port 8080

  Serial.println("Sending mDNS query");
  int n = MDNS.queryService("esp", "tcp"); // Send out query for esp tcp services
  Serial.println("mDNS query done");
  if (n == 0) {
    Serial.println("no services found");
  } else {
    Serial.print(n);
    Serial.println(" service(s) found");
    for (int i = 0; i < n; ++i) {
      // Print details for each service found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(MDNS.hostname(i));
      Serial.print(" (");
      Serial.print(MDNS.IP(i));
      Serial.print(":");
      Serial.print(MDNS.port(i));
      Serial.println(")");
    }
  }
  Serial.println();

  Serial.println("loop() next");
}

void loop() {
  // put your main code here, to run repeatedly:
  MDNS.update();
}


the output was
Code: Select all04:17:46.186 -> setup()
04:17:46.186 -> Hostname: ESP_A0AAD7
04:17:46.512 -> ...............
04:17:50.874 -> Connected to My_Home_NetWork
04:17:50.874 -> IP address: 192.168.1.107
04:17:50.874 -> mDNS responder started
04:17:50.874 -> Sending mDNS query
04:17:51.852 -> mDNS query done
04:17:51.852 -> 1 service(s) found
04:17:51.852 -> 1: ESP_4E3621.local (192.168.1.105:8080)
04:17:51.852 ->
04:17:51.852 -> loop() next


put when i ping it "ping ESP_4E3621.local" or "ping ESP_A0AAD7.local"

it didnt work

how to test them ?
User avatar
By urs_eppenberger
#90559 Basically this should work. You should be able to ping your device with the xxxx.local address and get an answer.

We need a little bit more information about your setup.
- do you really have MDNS working on the system you are pinging from?
- is the system you are pinging from in the same network? (same IP address range)

Don't worry, we will get to the bottom of this.

Kind regards,
Urs.
User avatar
By MSoubhi
#90573
urs_eppenberger wrote:Basically this should work. You should be able to ping your device with the xxxx.local address and get an answer.

We need a little bit more information about your setup.
- do you really have MDNS working on the system you are pinging from?
- is the system you are pinging from in the same network? (same IP address range)

Don't worry, we will get to the bottom of this.

Kind regards,
Urs.

yes same network , and i can ping it with the IP
User avatar
By Zachrey
#90608 Make sure your laptop or phone has the thingie installed to do mDNS stuff.

If you have a windows laptop, you need to install bonjour.
Here is a link to the package:
https://support.apple.com/kb/DL999?locale=en_US

If you have Mac laptop, bonjour should already be installed.

If you running Ubuntu Linux, you need to install avahi-daemon (and optionally?? avahi-utils).
you can run:
sudo apt-get install avahi-daemon