ESP8266Ping is a handy library that you can use to ping remote hosts using the famous ESP8266. Download it.
Sample code:
/* With this library an ESP8266 can ping a remote machine and know if it's reachable. It provides some basic measurements on ping messages (avg response time). */ #include <ESP8266WiFi.h> #include <ESP8266Ping.h> const char* ssid = "YOUR_SSID"; // Your Wifi Name const char* password = "YOUR_PASSWORD"; // Wifi Password const IPAddress remote_ip(8, 8, 8, 8); // Remote host void setup() { Serial.begin(115200); delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.println("Connecting to WiFi"); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(100); Serial.print("."); } Serial.println(); Serial.print("WiFi connected with ip "); Serial.println(WiFi.localIP()); Serial.print("Pinging ip "); Serial.println(remote_ip); // Ping if (Ping.ping(remote_ip)) { Serial.println("Success!!"); } else { Serial.println("Error :("); } } void loop() { // loop }