This worked on April 11, 2025 for an Arduino R4 using the Arduino Desktop IDE on a Windows 11 computer.
Make Sure that the Arduino IDE is updated to the most recent version.
Update the Arduino R4 board package:
- Go to Tools>Board>Board Manager → Search for "Arduino UNO R4" → Install/update to the latest version
#include <WiFiS3.h> // Correct library for UNO R4 WiFi
const char ssid[] = "My_ssid";
const char password[] = "My_password";
void setup() {
Serial.begin(9600);
while (!Serial);
// Connect to WiFi
if (WiFi.begin(ssid, password) != WL_CONNECTED) {
Serial.println("WiFi connection failed!");
while (true);
}
Serial.println("Connected to WiFi!");
// Send HTTP GET request
WiFiClient client;
if (client.connect("jsonplaceholder.typicode.com", 80)) {
client.println("GET /comments?id=10 HTTP/1.1");
client.println("Host: jsonplaceholder.typicode.com");
client.println("Connection: close");
client.println();
}
// Read response
while (client.connected()) {
String line = client.readStringUntil('\n');
Serial.println(line);
}
}
void loop() {}