Things used in this project

Hardware components:
Esp01
Everything ESP ESP8266 ESP-01
×1
Staples Easy Button
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Nodemcu style5 150px.png 150x150
NodeMCU firmware
Hand tools and fabrication machines:
FTDI Serial TTL-232 USB Cable
ESP8266 ADAPTER AND BREAKOUT BOARD KIT

Schematics

IFTTT Easy Button
IftttEasyButton.fzz

Code

init.luaLua
--init.lua
wifi.setmode(wifi.STATION)
wifi.sta.config("<SSID>","<PSK>")
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
	print("Waiting for IP...")
else
	tmr.stop(1)
    print("Your IP is "..wifi.sta.getip())
    print("5 seconds to stop timer 0")
    tmr.alarm(0, 5000, 0, function()
        print("Starting button listener...")
        dofile("button.lua")
    end)
end
end)
button.luaLua
--button.lua
buttonPin = 4 -- this is ESP-01 pin GPIO02
gpio.mode(buttonPin,gpio.INT,gpio.PULLUP)

function debounce (func)
    local last = 0
    local delay = 200000

    return function (...)
        local now = tmr.now()
        if now - last < delay then return end

        last = now
        return func(...)
    end
end

function onChange()
    if gpio.read(buttonPin) == 0 then
        print("That was easy! ")
        dofile("ifttt.lua") 
        tmr.delay(500000)
    end
end

gpio.trig(buttonPin,"down", debounce(onChange))
ifttt.luaLua
--ifttt.lua
conn = nil
conn=net.createConnection(net.TCP, 0) 

conn:on("receive", function(conn, payload) 
     print(payload) 
     end) 
     
conn:on("connection", function(conn, payload) 
     print('\nConnected') 
     conn:send("GET /trigger/button/with/key/<MAKER-CHANNEL-KEY>"
      .." HTTP/1.1\r\n" 
      .."Host: maker.ifttt.com\r\n"
      .."Accept: */*\r\n" 
      .."User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n" 
      .."\r\n")
     end) 
     
conn:on("disconnection", function(conn, payload) 
      print('\nDisconnected') 
      end)
      
print('Posting to ifttt.com')                                    
conn:connect(80,'maker.ifttt.com')

Credits

Noelportugal
Noel Portugal
2 projects • 54 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog