Arduino WiFi Rev2 & IFTTT Webhook

Hello!

I am very new, but excited to learn. I was wondering if you could take a look at this code and inform me as to why IFTTT is not receiving my webhook. I just got the uno today so if this is botched, I apologize :). I do receive the IP address in the serial monitor, so I believe the uno is connecting to the network fine… this is an amalgam of code from a few different tutorials… hence my confusion!

Any thoughts are greatly appreciated and thanks in advance.

#include <Arduino.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include "AnotherIFTTTWebhook.h"

#define IFTTT_Key "bBnubd2UKtaJTFCkdrNtFG"
#define IFTTT_Event "Email"

void setup() {
  
  char ssid[] = "omitted";
  char pass[] = "omitted";

  Serial.begin(9600);
  while (!Serial);

  int status = WL_IDLE_STATUS;
  while (status != WL_CONNECTED) {
    Serial.print("Connecting to ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(5000);
  }

  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
 
  send_webhook(IFTTT_Event,IFTTT_Key,"Hi its Me!","value 2","value 3");
}

void loop() {
}

Can you manually trigger via a browser? For more info, go to IFTTT Maker Webhooks where xyz=your key

If that doesn’t work, then no point in trying it in code until the problem is resolved.

Also, this worked for me, with an ESP8266. It is based on the ESP8266 HTTPSrequest example, but modified for HTTP. You’ll probably have to change the libraries for the Arduino WiFi Rev 2.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>

const char* host = "maker.ifttt.com";
const int myPort = 80; // for HTTP (not HTTPS)

void setup() {
  Serial.begin(115200); Serial.println();
  WiFi.mode(WIFI_STA);
  WiFi.begin(); // the ESP8266 saves SSID & pswd
  while (WiFi.status() != WL_CONNECTED) {
    delay(500); Serial.print(".");
  }
  Serial.print(WiFi.localIP());

  WiFiClient client; // for HTTP
  Serial.print("conn to "); Serial.println(host);

  if (!client.connect(host, myPort)) {
    Serial.println("conn fail; try again in 15...");
    delay(15000);
    if (!client.connect(host, myPort)) {
      Serial.println("fail again...giving up");
    }
    return;
  }

  String url = "/trigger/myEvent/with/key/myKey";  // works for both HTTP and HTTPS
  Serial.print("requesting URL: ");  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               //               "User-Agent: myAgent\r\n" +   //from HTTPSRequest example
               "Connection: close\r\n\r\n");

  Serial.println("GET sent");

  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("hdrs recd");
      break;
    }
  }

  String line = client.readStringUntil('\n');
  Serial.println("reply was:");  Serial.println("==========");
  Serial.println(line); Serial.println("==========");
  Serial.println("closing conn");
}

void loop() {
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.