// Learn about the ESP32 WiFi simulation in
// https://docs.wokwi.com/guides/esp32-wifi
#include <WiFi.h>
#include <Wire.h>
#include <ESPping.h>
const char* remote_host = "203.0.113.1"; // or "8.8.8.8" for Google DNS
void setup() {
Serial.begin(115200);
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void PingTest(){
bool success = Ping.ping(remote_host);
if (success) {
Serial.println("Ping successful!");
// Get detailed ping results
float avgTime = Ping.averageTime();
Serial.print("Average time: ");
Serial.print(avgTime);
Serial.println(" ms");
// You can also specify the number of pings (default is 4)
// bool success = Ping.ping(remote_host, 5);
} else {
Serial.println("Ping failed!");
}
}
void loop() {
PingTest();
delay(250);
}