Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →How to make your board ask a server for weather data or time via APIs.
Just a USB connection — no external components required.
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
const char* url = "http://worldtimeapi.org/api/timezone/Asia/Riyadh";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
}
void loop() {
if(WiFi.status() == WL_CONNECTED){
HTTPClient http;
http.begin(url);
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println(payload);
}
http.end();
}
delay(10000);
}Trying to connect to HTTPS (encrypted) sites using plain HTTP code. For HTTPS you must include the security certificate or set the client to Insecure mode.