-
-
Save sarasantos/e4673cefc088ae664422dabe19f83258 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
#include <HTTPClient.h> | |
const char* ssid = "REPLACE_WITH_YOUR_SSID"; | |
const char* password = "REPLACE_WITH_YOUR_PASSWORD"; | |
void setup() { | |
Serial.begin(115200); | |
delay(4000); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(1000); | |
Serial.println("Connecting to WiFi.."); | |
} | |
Serial.println("Connected to the WiFi network"); | |
} | |
void loop() { | |
if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status | |
HTTPClient http; | |
http.begin("https://en.wikipedia.org/w/api.php?action=query&exlimit=1&explaintext=1&exsentences=10&formatversion=2&prop=extracts&titles=Pet_door&format=json"); //Specify the URL | |
int httpCode = http.GET(); //Make the request | |
if (httpCode > 0) { //Check for the returning code | |
String payload = http.getString(); | |
Serial.println(httpCode); | |
Serial.println(payload); | |
} | |
else { | |
Serial.println("Error on HTTP request"); | |
} | |
http.end(); //Free the resources | |
} | |
delay(10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment