Close

Progress But Not Perfection

A project log for All-In-One ESP8266 IFTTT Button

This is an IFTTT IoT button based on Noel Portugal's design but implemented on an ESP826-07 breakout board with a built-in button.

stopsendingmejunkstopsendingmejunk 12/31/2015 at 04:260 Comments

Okay I figured out how to get the connection info to stick. I just hard-coded it into init.lua! Sure, the wifi AP config is cool and all, and I'd like to get it working, but this gets me going now. My init.lua looks like this now:

--init.lua

gpio.mode(4, gpio.OUTPUT)
gpio.write(4, gpio.HIGH)
cnt = 0

print("Starting SmartButton")

wifi.setmode(wifi.STATION)
wifi.sta.config("APNAME","password")
wifi.sta.connect()

tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
    cnt = cnt + 1
	print("(" .. cnt .. ") Waiting for IP...")
    if cnt == 10 then
        tmr.stop(1)
        dofile("setwifi.lua")
    end
else
	tmr.stop(1)
    dofile("ifttt.lua")
end
end)
Problem is, as soon as I updated it my board would just boot loop, triggering IFTTT each time. That's cool, I guess. IFTTT is being triggered, I just need to get it to stop rebooting!

I started out by removing all references to reset in ifttt.lua but that caused all sorts of problems so I went back and commented out reset commands one by one until I found the right one. Turns out if you comment out the reset() command on line 14 everything works - the board boots up, triggering IFTTT. It then stays connected and doing nothing until you hit the reset button, at which point it reboots and runs IFTTT again.

So it is basically working, although it needs improvement. There are two directions I could go:

Option 1: Figure out a low-power mode like the original tutorial. This may require an external button be wired in (???), losing the awesomeness of an all-in-one IFTTT button solution. This also has the drawback of taking a bit longer to react. Since I am using it to trigger my lights on and off, speed is ideal. Still, if I could figure out how to do it using the on-board buttons the cool factor would be worth it.

Option 2: Leave the board on and connected and figure out how to initiate the IFTTT connection using the flash button. This would be quicker but would mean the board would need to be plugged in.

I need to start learning LUA or find someone to help me!

Discussions