I have installed ArduinoHttpClient but when I try to compile I get
This output
C:\Users\peter\OneDrive\Documents\Arduino\httptest\httptest.ino:2:10: fatal error: Arduino_HTTP_Client.h: No such file or directory
#include <Arduino_HTTP_Client.h> // <-- The new, modern HTTP client library
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1Compilation error: Arduino_HTTP_Client.h: No such file or directory
As you can see it is installed.
Here is my program
#include <WiFiS3.h>
#include <Arduino_HTTP_Client.h>
#include "secret.h"
#include <SPI.h>
#include <SD.h>
// --- Configuration ---
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
const char serverAddress[] = "192.168.0.9";
int port = 443;
// --------------------
// Create the client objects
WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int counter = 1;
const int chipSelect = 10;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("--- Starting Secure Test with Arduino_HTTP_Client ---");
// The new library requires SSL to be enabled explicitly
client.sslEnable();
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to WiFi network!");
IPAddress ip = WiFi.localIP();
Serial.print("Arduino IP Address: ");
Serial.println(ip);
if (!SD.begin(chipSelect)) {
Serial.println("SD card initialization failed!");
return;
}
Serial.println("SD card initialization successful.");
}
void loop() {
if (counter > 10) {
Serial.println("Test finished.");
while (true);
}
Serial.print("\n--- Sending Request #");
Serial.print(counter);
Serial.println(" ---");
String postData = "logdata=" + String(counter) + "&device=UNO_R4_SECURE";
String contentType = "application/x-www-form-urlencoded";
// Make the POST request
client.post("/arduino_data/save_data.php", contentType, postData);
// Read the response
int statusCode = client.responseStatusCode();
String response = client.responseBody();
Serial.print("Server Status Code: ");
Serial.println(statusCode);
Serial.print("Server Response: ");
Serial.println(response);
// Log to SD card
File logFile = SD.open("datalog.txt", FILE_WRITE);
if (logFile) {
logFile.print("Request: ");
logFile.print(counter);
logFile.print(", Status: ");
logFile.println(statusCode);
logFile.close();
} else {
Serial.println("Error writing to SD card.");
}
counter++;
delay(10000);
}
I think I am close and I got it to work with just http to my Synology nas and it sent data and posted back 200. I just need help with that final push to https. I can’t find any other suggested libraries in the r4 documentation. Assistance would be greatly appreciated..
