Trigger a MAKE channel on IFTTT using Pimoroni ESP pHAT

This is not the most elegant solution, but the flow grew while I was exploring the AT commands used by the ESP8266 to make simple HTTP requests.

DON'T FORGET to ADJUST TO YOUR REQUIREMENTS On startup, the flow injects the message to configure the ESP8266 pHAT as client device. The return messages trigger the respective next steps. Adjust the 'connect to WiFi' node with your own WiFi name and password. Once the connection is established, the IP address is printed in the debug panel. There's no diagnostics in case of any errors!!! If an event is triggered, the ESP8266 is made to do a GET request to the IFTTT server. Have a look at their MAKE channel for further info. The GET request features your desired 'event name' and your authentication token (set in 'issue GET to server'), so you will have to set the length of the request in 'submit message length to ESP'.

Add debug nodes to see what's going on behind the scenes.

I use this node to trigger a notification through IFTTT.

[{"id":"bd85594d.427aa8","type":"serial-port","z":"46ef3b53.b910c4","serialport":"/dev/ttyAMA0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"\\r\\n","bin":"false","out":"char","addchar":false},{"id":"1ed2de0.fe12d22","type":"debug","z":"46ef3b53.b910c4","name":"print IP","active":true,"console":"false","complete":"payload","x":747,"y":932,"wires":[]},{"id":"a7db8fec.58247","type":"serial out","z":"46ef3b53.b910c4","name":"","serial":"bd85594d.427aa8","x":778,"y":379,"wires":[]},{"id":"1afbbf2a.e50441","type":"serial in","z":"46ef3b53.b910c4","name":"","serial":"bd85594d.427aa8","x":119,"y":784,"wires":[["854096c0.7abf68"]]},{"id":"c9a0e1c7.365f2","type":"function","z":"46ef3b53.b910c4","name":"issue GET to server","func":"msg.payload = 'GET /trigger/YOUREVENT/with/key/YOURKEY HTTP/1.1\\r\\nHost: maker.ifttt.com\\r\\n\\r\\n';\nreturn msg;","outputs":1,"noerr":0,"x":544,"y":567,"wires":[["a7db8fec.58247"]]},{"id":"67e91083.9816f","type":"inject","z":"46ef3b53.b910c4","name":"on startup","topic":"","payload":"","payloadType":"string","repeat":"","crontab":"","once":true,"x":116,"y":268,"wires":[["ca6b80d5.35948"]]},{"id":"7cdd201b.8322e","type":"switch","z":"46ef3b53.b910c4","name":"CONNECT switch","property":"payload","rules":[{"t":"cont","v":"AT+CWMODE=1"},{"t":"cont","v":"WIFI GOT IP"},{"t":"cont","v":"+CIFSR:STAIP"}],"checkall":"true","outputs":3,"x":470,"y":823,"wires":[["21e07c3f.de1f84"],["839e3abf.7c61c8"],["250290e0.dafd7"]]},{"id":"839e3abf.7c61c8","type":"function","z":"46ef3b53.b910c4","name":"read IP","func":"msg.payload = 'AT+CIFSR\\r\\n';\nreturn msg;","outputs":1,"noerr":0,"x":686,"y":820,"wires":[["a7db8fec.58247"]]},{"id":"21e07c3f.de1f84","type":"function","z":"46ef3b53.b910c4","name":"connect to WiFi","func":"msg.payload = 'AT+CWJAP=\"YOURWIFINAME\",\"YOURWIFIPW\"\\r\\n';\nreturn msg;","outputs":1,"noerr":0,"x":607,"y":732,"wires":[["a7db8fec.58247"]]},{"id":"854096c0.7abf68","type":"delay","z":"46ef3b53.b910c4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":285,"y":784,"wires":[["7cdd201b.8322e","527bb913.ad8448"]]},{"id":"250290e0.dafd7","type":"function","z":"46ef3b53.b910c4","name":"print IP","func":"msg.payload = 'got an IP: '+msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":574,"y":931,"wires":[["1ed2de0.fe12d22"]]},{"id":"4424c182.bbdb4","type":"inject","z":"46ef3b53.b910c4","name":"some trigger","topic":"","payload":"","payloadType":"string","repeat":"","crontab":"","once":false,"x":118,"y":376,"wires":[["b8eba226.47146"]]},{"id":"b8eba226.47146","type":"function","z":"46ef3b53.b910c4","name":"initiate TCP","func":"msg.payload = 'AT+CIPSTART=\"TCP\",\"maker.ifttt.com\",80\\r\\n';\nreturn msg;","outputs":1,"noerr":0,"x":339,"y":378,"wires":[["a7db8fec.58247"]]},{"id":"527bb913.ad8448","type":"switch","z":"46ef3b53.b910c4","name":"GET switch","property":"payload","rules":[{"t":"cont","v":"AT+CIPSTART=\"TCP\",\"maker.ifttt.com\",80"},{"t":"cont","v":"SEND OK"},{"t":"cont","v":"You've fired"}],"checkall":"true","outputs":3,"x":156,"y":493,"wires":[["bbe40bb6.441bf8"],["964b592b.69b4a8"],["964b592b.69b4a8"]]},{"id":"bbe40bb6.441bf8","type":"function","z":"46ef3b53.b910c4","name":"submit message length to ESP","func":"msg.payload = 'AT+CIPSEND=91\\r\\n';\n// adjust '91' to the actual length of your message\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":480,"wires":[["a7db8fec.58247","a3475fed.5cb8a"]]},{"id":"ca6b80d5.35948","type":"function","z":"46ef3b53.b910c4","name":"set ESP to client","func":"msg.payload = 'AT+CWMODE=1\\r\\n';\nreturn msg;","outputs":1,"noerr":0,"x":361,"y":269,"wires":[["a7db8fec.58247"]]},{"id":"a3475fed.5cb8a","type":"delay","z":"46ef3b53.b910c4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":363,"y":566,"wires":[["c9a0e1c7.365f2"]]},{"id":"964b592b.69b4a8","type":"debug","z":"46ef3b53.b910c4","name":"print success","active":true,"console":"false","complete":"payload","x":346,"y":629,"wires":[]},{"id":"25d4a55a.da2b5a","type":"comment","z":"46ef3b53.b910c4","name":"Flow starts here - on startup","info":"","x":128,"y":225,"wires":[]},{"id":"97d7da3d.682828","type":"comment","z":"46ef3b53.b910c4","name":"ESP messages trigger further commands to connect to WiFi","info":"","x":280,"y":870,"wires":[]},{"id":"6493267d.9b6cd8","type":"comment","z":"46ef3b53.b910c4","name":"trigger for IFTTT MAKER channel event","info":"","x":162,"y":339,"wires":[]},{"id":"156619b6.ea99e6","type":"comment","z":"46ef3b53.b910c4","name":"ESP messages trigger GET command and connect to IFTTT","info":"","x":305,"y":445,"wires":[]}]
badryan

Flow Info

created 1 year, 3 months ago

Node Types

Core
  • comment (x4)
  • debug (x2)
  • delay (x2)
  • function (x7)
  • inject (x2)
  • serial in (x1)
  • serial out (x1)
  • serial-port (x1)
  • switch (x2)

Tags

  • ESP8266
  • pHAT
  • RasperryPi
  • IoT
  • IFTTT
  • ATcommands
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option