# ESP8266 ping not working?

**URL:** <https://forum.arduino.cc/t/esp8266-ping-not-working/1187804>\
**Category:** Programming\
**Created:** [November 11, 2023, 4:12am UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804 "2023-11-11T04:12:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@SteveMann](https://forum.arduino.cc/u/SteveMann)\
**Post date:** [November 11, 2023, 4:12am UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/1 "2023-11-11T04:12:28Z")

</div>

I have a sketch that has been running just fine using the ESP8266Ping.h library. I wanted to flash a new ESP8266 with the same code but I can't get any pings to work.

Any ideas would be appreciated.

```arduino
#define SKETCH "pingTest"
#define VERSION "1.00" // Four characters

/*
   This program is a test of the ping function
*/

//-------------------------
#include <ESP8266Ping.h> //Includes ESP8266WiWi.h
#include <Kaywinnet.h> // WiFi credentials

char pingIP[20]; // IP that we're going to ping.

// ******************************SERIAL**************************
void beginSerial() {
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.println(SKETCH);
  Serial.println(VERSION);
  Serial.println();
}

// ******************************WiFi**************************
void setup_wifi() {
  Serial.println();
  Serial.println("Connecting to ");
  Serial.println(MY_SSID);

  //WiFi.hostname(SKETCH);
  WiFi.begin(MY_SSID, MY_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(WiFi.status());
    Serial.print(" ");
  }

  Serial.println("\nWiFi connected, ");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("Hostname: ");
  Serial.println(WiFi.hostname().c_str());
}

// ******************************PING**************************
void pingit() {
  Serial.print(pingIP);
  Serial.print(F(": "));
  if (Ping.ping(pingIP)) { // Ping
    Serial.println("OK");
  } else {
    Serial.println("Fail");
  }
}

// ******************************SETUP**************************
void setup() {
  beginSerial();
  setup_wifi();
}

// ******************************LOOP**************************
void loop() {
  strcpy(pingIP, "192.168.1.1");
  pingit();
  strcpy(pingIP, "192.168.1.57");
  pingit();
  strcpy(pingIP, "192.168.1.124");
  pingit();
  strcpy(pingIP, "192.168.1.183");
  pingit();
  strcpy(pingIP, "127.0.0.1");
  pingit();

  Serial.println(F("---------------"));
  delay(1000);
}

```

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 11, 2023, 5:45am UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/2 "2023-11-11T05:45:22Z")

</div>

is the new ESP8266 identical to the old one? give details?  
is the code compiling and uploading to the new board OK?  
what is printed on the serial monitor?

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [November 11, 2023, 6:14am UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/3 "2023-11-11T06:14:02Z")

</div>

> [@SteveMann](#):
>
> ESP8266Ping.h

there are several libraries using this .h  
Which library have you installed exactly?  
Is the example sketch of that library working? If not - please show the serial output

---

<div class="post-metadata">

**Author:** ![SteveMann](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@SteveMann](https://forum.arduino.cc/u/SteveMann)\
**Post date:** [November 11, 2023, 2:13pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/4 "2023-11-11T14:13:24Z")

</div>

> [@horace](#):
>
> what is printed on the serial monitor?

```arduino
pingTest
1.00

Connecting to 
Kaywinnet
7 7 7 7 7 7 7 7 3 
WiFi connected, 
IP address: 192.168.1.188
Hostname: ESP-B5AE42
192.168.1.1: Fail
192.168.1.57: Fail
192.168.1.124: Fail
192.168.1.183: Fail
127.0.0.1: Fail

```

> [@noiasca](#):
>
> Which library have you installed exactly?

I keep my libraries up to date, but in this case I tried installing an older version of ESP8266ping.h with the same results. I also tried pinger.h with the same results.

> [@horace](#):
>
> is the new ESP8266 identical to the old one? give details?

I buy my Wemos D1 Minis five or ten at a time. This problem is the same on three that I have tested, including one that had been running the same code for a couple of years.

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [November 11, 2023, 2:19pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/5 "2023-11-11T14:19:46Z")

</div>

> [@noiasca](#):
>
> there are several libraries using this .h  
> Which library have you installed exactly?

Providing just the include is not enough to ensure we are talking about the same library.

Go into your library manager and provide all details about your used library.

P.S. for usual you would ping a structure of type IPAddress - not a char array. but again - this can differ depending on the used library.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@SteveMann](https://forum.arduino.cc/u/SteveMann)\
**Post date:** [November 11, 2023, 2:56pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/6 "2023-11-11T14:56:08Z")

</div>

> [@noiasca](#):
>
> Go into your library manager and provide all details about your used library.

Thanks for sticking with me.  
This is what the Library Manager reports:

 ![pingver](https://europe1.discourse-cdn.com/arduino/original/4X/4/4/7/4471b85572661d4925fe4ab5ac67eebe14e338f2.jpeg)

Clicking on "More" takes me to a dead site:

 ![badpage](https://europe1.discourse-cdn.com/arduino/original/4X/a/1/0/a10b82a5ea53cee04712d9ff92a8e447bbdc1ea3.jpeg)

While I did not compare it line for line, I believe that this is the library on GitHub:  
[dancol90/ESP8266Ping: Ping library for ESP8266 Arduino core (github.com)](https://github.com/dancol90/ESP8266Ping)

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [November 11, 2023, 3:25pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/7 "2023-11-11T15:25:52Z")

</div>

> [@SteveMann](#):
>
> I believe

nope, version doesn't fit together with the library.properties

---

<div class="post-metadata">

**Author:** ![SteveMann](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@SteveMann](https://forum.arduino.cc/u/SteveMann)\
**Post date:** [November 11, 2023, 4:12pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/8 "2023-11-11T16:12:13Z")

</div>

My library is messed up. I downloaded the .cpp and.h file from Github and put them into my sketch folder, and now every ping I send to that library works fine.

Can you clarify where the library files should go? (esp8266ping.h is found in several locations). If I recall the library files are in a libraries folder in my sketchbook folder? My sketch folder is:  
 ![sketchbook](https://europe1.discourse-cdn.com/arduino/original/4X/3/a/3/3a3979fb0bd98cf367b61d141139344dd79d3817.jpeg)

So, my understanding is that the .cpp and .h files should go into  
`C:\Users\steve\Documents\Arduino\libraries\ESP8266ping`

Your input is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [November 11, 2023, 4:18pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/9 "2023-11-11T16:18:00Z")

</div>

> [@SteveMann](#):
>
> C:\Users\steve\Documents\Arduino\libraries\ESP8266ping

looks ok.  
must be in the subfolder libraries under you sketchbook location.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 9, 2024, 4:18pm UTC](https://forum.arduino.cc/t/esp8266-ping-not-working/1187804/10 "2024-05-09T16:18:23Z")

</div>

Closed on May 9, 2024, 4:18pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
