Send web request to Webhooks on IFTTT using AT commands
Posted: Wed Feb 21, 2018 12:10 pm
To add a little feature on already done Arduino project I'm using ESP8266-01 module. To trigger the event, it says I need to make a POST or GET web request to: https://maker.ifttt.com/trigger/overhea ... TTi0oo0vRl. (Key changed)
How can I do this by using AT commands of ESP01?
I tried:
I didn't write code for connecting ESP8266 to WiFi as it automatically connects.
But I had no luck. I might just be plain wrong about this.
What is the right way to do this?
Thank you.
How can I do this by using AT commands of ESP01?
I tried:
Code: Select all
#include<SoftwareSerial.h>
SoftwareSerial ESP(3,4); //rx tx
#define DEBUG true
String Host_name = "*****";
String password = "********";
char inv='"';
void ResetConnect();
void triggerIFTTTAPI();
void setup() {
ESP.begin(9600);
Serial.begin(115200);
pinMode(7, INPUT_PULLUP);
Serial.println("Ready press button");
}
void loop() {
if(digitalRead(7)==LOW)
{
triggerIFTTTAPI();
Serial.println("End of program");
}
void triggerIFTTTAPI()
{
String start="AT+CIPSTART"; //command to establish connection
start+="=";
start+=inv;
start+="TCP";
start+=inv;
start+=",";
start+=inv;
start+="maker.ifttt.com";
start+=inv;
start+=",";
start+="80";
start+="\r\n";
sendData(start, 3000, DEBUG);
String cipsend="AT+CIPSEND=100";
cipsend+="\r\n";
sendData(cipsend, 2000, DEBUG);
String request = "GET /trigger/overheat/with/key/c8OXo1RPwep9TTi0oo0vRl";
request+=" HTTP/1.1\r\n";
request+="Host: maker.ifttt.com";
request+="\r\n";
request+="Connection: close";
request+="\r\n\r\n\r\n\r\n";
sendData(request,7000, DEBUG);
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
ESP.print(command);
Serial.println(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (ESP.available())
{
// The esp has data so display its output to the serial window
char c = ESP.read(); // read the next character.
response += c;
}
}
if (debug)
{
Serial.print(response);
}
return response;
}
}
I didn't write code for connecting ESP8266 to WiFi as it automatically connects.
But I had no luck. I might just be plain wrong about this.
What is the right way to do this?
Thank you.