How to Ping a Remote Host using ESP32 with Arduino IDE

ESP32 is a microcontroller board which allows users to integrate it inside a wireless network and upload the real time data coming from sensors to a web server. Using the built in WiFi driver modules we can connect ESP32 with any wireless network. Once ESP32 is connected to a network a ping can be used to test the working of ESP32. This article will cover Arduino code to ping an ESP32 board.

Introduction to ESP32 Ping

The ESP32 can be used to perform a variety of tasks, including internet communication, data processing, and sensor integration.

Using ESP32 we can perform Ping, which is a simple networking utility that can test reachability of a host on an Internet Protocol (IP) network. When you ping a host, you send a small packet of data to the host and wait for a response. This can be used to determine whether the host is online and functioning properly, as well as to measure the round-trip time (RTT) for packets to travel to and from the host.

To use the ping function on the ESP32, you will need to include the appropriate libraries in your code and then use the ping() function provided by those libraries.

Ping a Remote Host in ESP32 Using Arduino IDE

In this tutorial we will send a ping to a remote host using ESP32 and Arduino IDE code. But before that we have to install the Ping library in the Arduino IDE first.

Installing the Ping Library in Arduino IDE

To install Ping library in Arduino IDE, follow the steps given below:

Step 1: Open the ESP32 Ping library GitHub page. Click Download Zip file. A new library file will download:

Step 2: A new library zip file is downloaded inside the windows download directory:

Step 3: Open Arduino IDE. Now to add zip library Go to: Sketch>Include Library>Add .ZIP Library:

Step 4: Select the ESP32 Ping library we just downloaded:

Step 5: Arduino IDE will begin installation of a new library in Arduino IDE. Once the library is successfully installed the following message can be seen on the serial monitor:

We have successfully installed the Ping library in the Arduino IDE. Now we can upload code to the ESP32 board.


Open Arduino IDE and upload given code in ESP32 board:

#include <WiFi.h>

#include <ESP32Ping.h>  /*including the ping library*/

const char* ssid = "yourNetworkName"; /*Define network SSID*/

const char* password ="yourNetworkPassword"; /*Define Network Password*/

void setup() {

  Serial.begin(115200);  /*Baud rate for serial communication*/

  WiFi.begin(ssid, password);  /*Begin WiFi connection*/

  while (WiFi.status() != WL_CONNECTED) {


  Serial.println("Connecting to WiFi...");


 bool success ="", 3);  /*ping ESP32 using google*/


  Serial.println("Ping failed");



 Serial.println("Ping successful.");


void loop() { }

This code sets up a WiFi connection using the WiFi library. To establish a wireless connection, define the network SSID and password. After that we created a Ping object.

Remember to replace the SSID and password for the network you want to connect.

In the loop() function, the code sends a ping to the host  “” and prints the ping successfully if a response is received. If no response is received, it prints an error message:


After uploading code to ESP32 we can see the board is establishing wireless connection with a network and once the connection is established it will send a ping to the host website. If the ping is successful the following highlighted message will appear on the serial monitor:

We have successfully pinged a remote host using Arduino IDE code in ESP32.


Ping is used in a network to test the connectivity at an IP level to a second TCP/IP device. We can use a remote host to test ESP32 connectivity using the Arduino IDE code. It will measure the round-trip time for packets to send from switch to destination device. This article covers all steps needed to ping a remote host using ESP32 and Arduino IDE. For more detailed information read the article.

About the author


I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.