Hi everybody, this is my first post, so I hope I'm doing the right moves on the forum !
I'm quite new about Arduino and I'm working on a "classic" project, but with a issues that I didn't solve.
I use a Arduino Uno WIFI Rev 2 to connect to a wifi and send data by using POST request to a webserver. I used WifiNINA and ArduinoJSON.
The problem is: I never entered inside the IF after client.connectSSL, because by using a browser I need to login with username and password in a classic login page...but I don't find working solutions with Arduino.
The code that I'm using is the following:
#include <WiFiNINA.h>
#include <ArduinoJson.h>
#include <SPI.h>
char ssid[] = "XXXXXXXXXXXXXXXXXX";
char pass[] = "XXXXXXXXXXXXXXXXXX";
int status = WL_IDLE_STATUS;
DynamicJsonDocument doc(1024); //
char server[] = "https://XXXXXXXXXXXXX";
WiFiClient client;
void setup() {
Serial.begin(9600);
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(5000);
}
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
IPAddress gateway = WiFi.gatewayIP();
Serial.print("IP Address: ");
Serial.println(ip);
String fv = WiFi.firmwareVersion();
if (fv != "1.4.8") {Serial.println("Please upgrade the firmware"); }
} // end setup
void loop() {
doc["XXXXX"][0] = "XXXXXX";
doc["XXXX"] = "XXXXX";
doc["XXXXX"] = "XXXXXX";
Serial.print("Provo a connettermi !...\n\r ");
if (client.connectSSL(server, 443)) {
Serial.print("Sono connesso !...invio la richiesta POST \n\r ");
client.println("POST \'https://XXXXXXXXX' ");
// client.println("Host: https://XXXXXXXX");
client.println("accept: application/ld+json");
client.println("Content-Type: application/ld+json");
client.println("Connection: close");
client.print("Content-Length: 1024");
client.println(measureJson(doc));
client.println();
serializeJson(doc, client);
// client.print(doc);
}
else{Serial.print("Non sono connesso \n\r");}
if (client.connected()) {
client.stop();
}
Serial.print("Risultato...: ");
Serial.println(serializeJson(doc, client));
delay(3000);
}
Thank you !