Skip to main content
#include
#include
#include
#include
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("http://www.speedtest.net/api/js/user-info");
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println(payload);
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
float downloadSpeed = doc["download"];
float uploadSpeed = doc["upload"];
float ping = doc["ping"];
Serial.print("Download Speed: ");
Serial.print(downloadSpeed);
Serial.println(" Mbps");
Serial.print("Upload Speed: ");
Serial.print(uploadSpeed);
Serial.println(" Mbps");
Serial.print("Ping: ");
Serial.print(ping);
Serial.println(" ms");
}
http.end();
}
delay(5000);
}
Comments
Post a Comment