This is my first time posting a question here.
I am using an MKR WiFi1010 and would like to post logging data to Google App Script. I have successfully made an SSL connection and published the data using WiFiSSLClient from the WiFiNINA library using Arduino IDE.
My question is, will WiFiClient work while Arduino Cloud is activated? Now, the board repeat restarting when WiFiClient is called.
I solved the problem by myself.
ArduinoHttpClient.h library was included and the sample code of that library was used.
In the sample code,
WiFiClient wifi;
should be replaced to
WiFiSSLClient wifi;
and it worked well with Arduino IoT Cloud. I attached the sample code to GET IFTTT webhook.
In the case of getting the URL of Google Apps Script, the command takes a long time, and the MKR WiFi 1010 restarts with WDT. In that case, WDT function should be killed with the following command.
ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);
#include <ArduinoHttpClient.h>
WiFiSSLClient wifi;
const String url = "https://maker.ifttt.com/trigger/alertiot/with/key/bospC0wmf**************";
char server[] = "maker.ifttt.com";
HttpClient client=HttpClient(wifi, server, 443); // 443: SSL connection
void setup{
//*****
}
void loop{
sendGet();
//****
}
void sendGet(){
Serial.println("making GET request");
client.get(url);
// read the status code and body of the response
int statusCode = client.responseStatusCode();
String response = client.responseBody();
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.