Go Down

Topic: IFTTT with the Nano 33 IoT (Read 58 times) previous topic - next topic


Has anyone converted code from some other Arduino to connect 2 way communication with IFTTT or Microsoft Flow using the Nano 33 IoT?

I know that IFTTT is not the best lately since communication times can range from a few minutes to several hours, but it still is a fairly cool way to control devices.

I don't know much about Microsoft flow but it has probably improved some of the issues with IFTTT.

Here is the link to the IFTTT webhooks which is needed to get things started https://ifttt.com/maker_webhooks

And here is a link to a Microsoft Flow example https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/IoT-Button-Microsoft-Flow/ba-p/47011


So this is seriously difficult stuff but super important to my Robotics course.

I have tried lots of ways of sending information to IFTTT, but getting minimal success (Sending the url is not the hard part. Controlling the data sent and getting a reply is the difficult part).

So I backed up and tried to do things using just javascript and the IFTTT Webhooks. After a lot of failed attempts this, reasonably easy javascript and form element webpage has started to work.

Code: [Select]

Webhook Event Name: <input id="myIfttEvent" type=text placeholder="myEvent" value="test-webhook"><br>
IFTTT Key: <input id="myIfttKey" type=text placeholder="9437582374982374985" value="JJJJJJJJJJJJ"><br>
value1: <input id="myValue1" type=text value="myOne"><br>
value2: <input id="myValue2" type=text value="myTwo"><br>
value3: <input id="myValue3" type=text value="myThree"><br>

<input type=button value=ifttt8 onclick="{

(async function(){
    let data = {value1:43,value2:34,value3:'hi'}
    let myResponse = fetch('https://maker.ifttt.com/trigger/' + document.getElementById('myIfttEvent').value + '/with/key/' + document.getElementById('myIfttKey').value, {
        method: 'POST',
        mode: 'no-cors',
        headers: {
           'Content-Type': 'application/x-www-form-urlencoded'
        body: 'value1=' + document.getElementById('myValue1').value + '&value2=' + document.getElementById('myValue2').value +'&value3=' + document.getElementById('myValue3').value
    document.getElementById('myDiv01').innerHTML = await JSON.stringify(myResponse)
     }  )()

<div id="myDiv01">...</div>

Not there yet but hopefully this is a step in the right direction.


Feb 16, 2020, 05:53 pm Last Edit: Feb 16, 2020, 11:18 pm by jerteach
Ok, so first step solved. I can now one way send info to IFTTT using the Nano 33 IoT. Note: the data is sent using URL-encoded format value1=45&value2=Mary&value3=tom25. Not sure why this was so hard to figure out.

Using IFTTT webhooks my event is called test-webhook and you have to go to the webhooks documentation page to find out your KEY. I have the key in this code as jjjjjjjjjjjjjjjjjjjjjjjj

Using IFTTT webhooks you can monitor your activity, refresh the page and get proof that your values have been sent. Also using IFTTT you can now send an email or anything with just connecting the code using IFTTT. I want to be able to receive from IFTTT using the Arduino and that is a problem since your Arduino does not have an outside URL unless you have setup your router to give it an outside URL.

Anyone with experience setting up their router to port forward? My problem is that I would want to do it at home and at school. School might be a bit more confusing. Anyone have workarounds for this kind of thing?

Below is my working code to send one-way to IFTTT.

Code: [Select]

 * ifttt.ino
 * Written by Arturo Guadalupi
 * November 2015
 * updated for IFTTT by
 * By Jeremy Ellis twitter @rocksetta
 * Webpage http://rocksetta.com
 * Arduino High School Robotics Course at
 * https://github.com/hpssjellis/arduino-high-school-robotics-course
 * Expects an IFTTT webhook called test-webhook
 * Go to webhooks Documentation page to find your Key
 * Key in this sketch is jjjjjjjjjjjjjjjjjjjjjj must be changed

#include <SPI.h>
#include <WiFiNINA.h>

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "maker.ifttt.com";    // name address for Google (using DNS)

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiSSLClient client;

void setup() {
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);

  String fv = WiFi.firmwareVersion();
    Serial.println("Please upgrade the firmware");

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
  Serial.println("Connected to wifi");

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 443)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("POST /trigger/test-webhook/with/key/jjjjjjjjjjjjjjjjjjjjjjjj HTTP/1.1");
    client.println("Host: maker.ifttt.com");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Content-Length: 35");  // The length of the next long line
   // client.println();

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println("disconnecting from server.");

    // do nothing forevermore:
    while (true);

void printWiFiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");

Go Up