I’m working on a small project that sends an SMS text message with the ESP8266. I found this tutorial, which uses IFTTT and an HTTPS get request (through the WiFiClientSecure library) to send the message, but for some reason I always get the below in my serial monitor:
connecting to wifi_name_hidden
.
WiFi connected
IP address:
10.0.0.58
connecting to maker.ifttt.com
connection failed
My actual code is below:
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
const char* ssid = "wifi_name_hidden";
const char* password = "wifi_password_hidden";
const char* host = "maker.ifttt.com";
const int httpsPort = 443;
void setup() {
Serial.begin(115200);
Serial.println();
Serial.print("connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
WiFiClientSecure client;
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
String url = "/trigger/event_name_hidden/with/key/c51QL4DQw5Lsl601fXXXXX";
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n");
Serial.println("request sent");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
String line = client.readStringUntil('\n');
Serial.println("reply was:");
Serial.println("==========");
Serial.println(line);
Serial.println("==========");
Serial.println("closing connection");
}
void loop() {
}
Any thoughts? Google has failed me.