sslClient.connect(host, 443) is failing to connect to IFFTT from MKR1000
Post your code to get help.
#include <Servo.h>
#include <WiFi101.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiSSLClient.h>
#include <WiFiUdp.h>
//Your Wifi router setup at home
char ssid[] = "MY2.4G"; //your network SSID (aka WiFi name)
char pass[] = "XXXXXX"; //your network password
int status = WL_IDLE_STATUS;
WiFiServer server(80);
//To send SMS using the s IFTTT
const char* host = "maker.ifttt.com";
WiFiSSLClient sslClient;
void setup() {
delay(10000); //delay to show the console display
int r= Connect_to_Wifi(); // Connect to wifi for sendign text message
}
void loop() {
delay(1000);
sendtextMessage();
}
int Connect_to_Wifi()
{
if (WiFi.status() == WL_NO_SHIELD) {
// In case of connection issues wait
delay(3000);
return 1;
}
// attempt to connect to Wifi network
while ( status != WL_CONNECTED) {
Serial.println("Connecting to Wifi");
status = WiFi.begin(ssid, pass);
if(status != WL_CONNECTED){
// wait 10 seconds for connection:
delay(1000);
}
}
Serial.println("Connected to Wifi");
server.begin();
printWifiStatus();
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
//signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print("Your IP address to use in the browser: ");
Serial.println(ip);
}
//call to IFTTT recipe to send an email or sms to your mobile
void ifttt_Send_SMS() {
String Medicine_not_pickedup = "Y";
String data = "{"value1":"" + Medicine_not_pickedup + ""}";
int i = sslClient.connect(host, 443);
Serial.println("SSL connect return code");
Serial.println(i);
if (sslClient.connect(host, 443)) { //443 or 80
//change this to your Maker setting from settings’s Applets - IFTTT
//sslClient.println("POST /trigger/moition_detected/with/key/XXXXXXXXXXXXXXXX HTTP/1.1");
sslClient.println("POST /trigger/{MedicineNotPicked}/with/key/eMqTXXXXXXXXXdrg4lYIIV6M HTTP/1.1");
sslClient.println("Host: maker.ifttt.com");
sslClient.println("Content-Type: application/json");
sslClient.print("Content-Length: ");
sslClient.println(data.length());
sslClient.println();
sslClient.print(data);
sslClient.stop();
Serial.println("IFTTT request Sucessful");
}
else {
Serial.println("IFTTT request failed");
}
}
I get the value 0 in the statement
sslClient.connect(host,443);
I am able to execute the POST on the webbrowser and get my SMS. So the setup with IFTTT is workign fine
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.