SimpleIOThings

DIY IoT projects with no coding or soldering required!

     
11

$10 DIY Wifi Smart Button / Switch

SimpleIOThings is the easiest and cheapest way to build DIY IoT projects with no coding or soldering required!

DIY IoT project with no soldering or coding required!

This tutorial will teach you how to build a Wifi Smart Button for about $10 dollars. You won’t have to code anything, and you won’t have to solder or buy expensive electronics equipment. Any services you are asked to use will be 100% free. Its that easy. Lets get started!

Sometimes you just need to communicate with the push of a button. What if I told you it was possible for about 10 bucks? With a wifi connected smart button you could:
– Excuse yourself from a conversation by sending a text or phone call to your own phone.
– Quickly call store/business security for help.
– Invite a reliable friend to come over and watch Netflix with you.

Whatever your particular snap communication need is, a wifi enabled smart button that can help you send a smartphone notification, SMS, email, and even an automated phone call at the press of a button.

The cool thing is, you can build one of these for about 10 dollars. I know you’ve seen these types of tutorials on the internet before, and usually they say something like, just buy a breadboard, soldering iron, breakout board, serial adapter, etc. etc. and after you’ve spent about $50 dollars you can build a cheap Internet of Things (IoT) device. Well, sorry internet. We nerds sometimes forget that most people don’t really have these things lying around. That’s why I built this website around the idea that IoT devices can be built without coding knowledge, soldering, or complicated prototyping.

STEP 1: Gather Your Materials

panic_button_components

Its a good idea to buy your parts first because on the sites where the merchandise is cheapest (Ebay or Aliexpress) shipping times are rather lengthy. Depending on where you live in the world, it might take some time for your components to reach you so its better to do this sooner in the process than later.  Here’s a list of things needed for this project. FYI, I’ve included some affiliate links to  the cheaper places you could buy these components. I’ve done my best to ensure the ads display the lowest price goods that are relevant to this project, and if you buy through them you’ll be helping me maintain this site.  Thanks! 😉

Required Components:

(FYI, if you’re just seeing text below with no images, its probably because you have an adblocker on. I know ads suck, but in this case they were actually a creative way to continuously update the page with the lowest cost parts. Prices change, so if I used static links and pics, the link would quickly become outdated. Please consider turning off adblock for this site for the best experience.)

ESP8266 Development Board (~$3 @ AliExpress; Nov 2017)
AliExpress.com ESP8266 Development Board

DIY Project Box Enclosure 100x60x25mm

Female to Female Jumper Wires

MicroUSB cable (10′ Cable Recommended)

USB Wall Charger

Project Specific Parts

Wifi Smart Button
Tactile Push Button w/ Cap

Suggested Tools:

These are tools needed to build the IoT device in this tutorial, but aren’t necessarily required.

Pliers

Hacksaw

Great. Now like I said, its gonna take a while for your stuff to get to you, so in the meantime lets setup some digital infrastructure that we can use once your stuff arrives.

STEP 2: Setup Your IFTTT Account & Recipes

The Wifi Smart Button, and all of the devices on SimpleIOThings, uses a service called If This Then That (IFTTT). You can find a full tutorial on how to sign up and configure digital communications for your IoT devices in the Getting Started: Setup IFTTT post. Once you completed it, you should have completed the following:

  • Signed up for an IFTTT account
  • Downloaded the IFTTT App
  • Connected to the Maker Channel
  • Recorded your Maker Key
  • Organized Maker Events (Triggers) that lead to IFTTT Actions.

Okay! We’ve got some really nifty digital infrastructure setup for your project. Soooooo…its gonna take a while before you get all this stuff…so its probably best to bookmark this page and come back after it’s all arrived. See you in a few weeks!

STEP 3: Install Firmware to your Dev Board

Oh hi there! Welcome back. I know its been a while. Maybe the seasons changed in your part of the world.  Governments may have risen, switched hands, entered alliances, broken alliances, fallen, and then risen again. Yea…it takes a while to get your stuff. But now that it’s here, lets start building!

connect_devboard_to_pc

 

You can find a full tutorial on how to load firmware onto your ESP8266 Development Board on the Getting Started: Setup ESP8266 Dev Board post.  After you’re done with this tutorial you should have completed the following.

  • Connect your ESP8266 Dev Board and Install Drivers
  • Load Firmware onto Dev Board using ESP8266Flasher.exe.
  • Connect to Dev Board using LuaLoader.

STEP 4: Install Sensor Specific Software to your Dev Board

Great! Now your dev board speaks Lua and its ready to start communicating with the world and run programs. Now it just needs specific instructions or programs to be useful for your specific use case. Lucky for you, I’ve already written the programs needed to get your device up and running. Full instructions on how to program your device with specific settings for your use case can be found on the Getting Started: Loading Device Software Via LuaLoader tutorial page. In this tutorial you should have completed the following:

  • Downloaded SimpleIOThings.zip from the Downloads page.
  • Extracted the zip file and run the SensorSetup.bat file.
  • Input your information into the command prompt  to enter user and device specific information (IFTTT Maker Key, the Maker Event name, the device’s location info, etc).
  • Enter input thresholds, input timeouts, and interval between notifications as prompted.
  • Uploaded device specific files to your ESP8266 Development Board using LuaLoader.
  • Set the Wifi Network Name and Password for your ESP8266 Development Board.

STEP 5: Modding Your Enclosure

All the way back in step 1, we talked about gathering materials. Now that you have everything in hand and your board is programmed, get all your materials together in one space.

Some suggestions on how to mod your enclosure can be found here at Getting Started (5): Modding Your Enclosure. After completing this tutorial you should have completed the following:

  • Created an opening in the rear of the enclosure for the microusb power cable.
  • Created an opening in the front of the enclosure for the button wires.

STEP 6: Build the Button

Now go ahead and unplug your dev board (there is almost no electrical danger to you from touching the dev board while plugged in, but might as well err on the side of safety).

Now, grab the button that you bought, and bend two of the prongs on one side until they snap off. You’ll only need 2 prongs, and the other two will just get in the way. Here’s a picture of what it looks like after you’ve snapped off one of the prongs.

22602164512_9b154215b3_k[1]

After that, flatten out the remaining prongs (bend them flush to the bottom of the button), and then go ahead and grab your two jumper wires and plug them into the remaining prongs. If they wires aren’t grabbing onto the prongs well, increase the amount of “kink” in the prongs with a set of pliers. Finally put the cap on the button. In the end it should look like this:

22589749296_b267a30067_k[1]

Now grab your dev board, and observe the names of the pins on the board. Go ahead and plug your jumper wires into the “GND” and “D2” pins on the right hand side. It should look like this:

22627004201_f05864362c_k[1]

Just a quick note for those of you who are interested in the electronics. When setup this way the button, when pressed, is acting as a bridge between the D2 pin and the electric ground (-). That way when the button is pressed, it grounds the D2 pin, registering a change in electrical signal which the chip detects as a sensor input. Pretty cool! Great, the electronics are all setup. Pretty simple right?

Alright, now you can put your electronics into the enclosure. Plug your usb cable into the dev board, and make sure your jumper wires are well positioned before you close the project box. Finally, place the button on top of the enclosure, and glue it down.

22602575282_8eb036ed49_k[1] 21993172414_f259f627e1_k[1]

And we’re done!

21993348404_3e841ed8d0_k[1]

Your button should now be fully operational. Give it a press and it should trigger whatever you’ve set it up to do, whether that’s a smartphone notification, SMS, phone call, email, etc.

I hope you enjoyed building a super simple Internet of Things device. Hopefully you will be able to use it for something useful, or use it to do something fun. If you enjoyed this tutorial, consider donating at the link below. Thanks for reading!

AutomationBeginnerboardButtonCheapChilldevelopmentDevicesEasyESP8266HomeIFTTTInternetIoTLuaNetflixNodeMCUPanicSmartThings

SimpleIOThings • October 23, 2019


Previous Post

Comments

  1. Ariel May 13, 2016 - 12:11 am Reply

    Im new to this and i pretty much got interested in digital electronics again due to the IFTTT and the esp8266. So i dont know anything about Lua and how it works, but i got this to work. How can i get it to work using its own power source without a connection to the computer?

    Can it run the code without lua loader running on my computer?
    Right now its basically working as a more complicated usb button.

    Thanks for in advanced and excuse my ignorance of this topic.

    • SimpleIOThings October 9, 2017 - 4:42 am Reply

      Glad you were able to get it running without having to tinker with the code. That’s exactly how it was designed to work!

      The button can work without plugging into your computer, but it needs a 5 volt power source (i.e. like your phone charger). Any 5v USB power source should allow the device to function without running LuaLoader concurrently. After its programmed, try plugging it into your cell phone charger, give it a minute to boot, and then give it a try.

  2. Bill July 21, 2016 - 5:45 am Reply

    Hello,

    Nice project, just wondering if the SimpleIOThings SensorAlert recipe you made at IFTTT is dependent on some server you are running?

    e:g If I was to use this recipe and you decided to delete your recipe or account, would the notifications stop working for me?

    Thanks for you replay in advance.
    Bill.

    • SimpleIOThings November 2, 2017 - 7:48 pm Reply

      The IFTTT recipes run off the IFTTT service, and are not related to any server or equipment that I run.

      Each user should be setting up their own IFTTT recipes so that they don’t have any dependencies on other users, or this website.

  3. Neb August 15, 2016 - 10:34 pm Reply

    I’m wondering how hard this would be to modify to allow for an enclosure that has more than one button?

  4. Delvis August 31, 2016 - 6:10 pm Reply

    Great tutorial. Thanks for taking the time.

    I wondered if you had a recommendation for how you could make this battery powered as opposed to usb powered. I have wifi in my shed but no power outlets, you see, and I’m planning on building a “Beer Me!” button that sends a text to my wife when I press the button from the shed. All in good fun of course – if I ever actually said that to my wife she’d more likely beat me upside the head than actually bring me a beer. 🙂

  5. Nicolas May 7, 2017 - 3:37 pm Reply

    Hi,

    This tutorial is great! Once I’m done, I will have a few suggestions for improvement. The first one is to buy at least 2 boards. I couldn’t flash the first board I tried. I was really wondering what I did wrong, when I decided to try another board, just in case. It worked at the first try. Considering the price of these boards and the long delivery time from China, it is money well spent.

    Another comment is to try twice or three times the same steps when getting to program the device with LUA doesn’t succeed at first.

    I am stuck however to the very end. I managed to set-up the button and see that it works in LuaLoader window. However, the activation of the button makes the board go in panic mode. Please see the log below:

    > (1) sensor inputs counted! Sending Alert!
    IFTTT Event Name: appelSacha
    Sensor Type: Button_Call_Sacha
    Sensor Location: None
    Sensor Location: Cuisine
    We can connect to 54.84.122.105
    We can connect to 54.84.122.105
    PANIC: unprotected error in call to Lua API (ifttt.lua:63: already connected)

    Could you please help me? Thanks!

  6. Nicolas May 11, 2017 - 2:21 am Reply

    Hi again!

    I found a correction to the problems I reported earlier. Thanks to Noel Portugal, I adapted his code to send the command to IFTTT and fit it in the infrastructure laid down here.

    In order for this to work, the content of the ifttt.lua file should be changed to the following and uploaded to the ESP-8266 board with the LuaLoader.

    I don’t fully understand why the ifttt.lua file made available here doesn’t work (any longer). It may have to do with the way it is handling DNS answers. What’s important is that the following code works (IMHO).

    I think the beer should be for me 🙂

    ________________________________________________________________________________

    –ifttt.lua

    file.open( “iftttKey.lua”, “r” )
    iftttKey = file.read()
    iftttKey = string.gsub(iftttKey, “%s+”, “”)
    file.close()
    –print(“IFTTT Maker Key: “..iftttKey)

    file.open( “eventName.lua”, “r” )
    eventName = file.read()
    eventName = string.gsub(eventName, “%s+”, “”)
    file.close()
    print(“IFTTT Event Name: “..eventName)

    file.open( “sensorType.lua”, “r” )
    sensorType = file.read()
    sensorType = string.gsub(sensorType, “%s+”, “”)
    file.close()
    print(“Sensor Type: “..sensorType)

    file.open( “sensorLocOne.lua”, “r” )
    sensorLocOne = file.read()
    sensorLocOne = string.gsub(sensorLocOne, “%s+”, “”)
    file.close()
    print(“Sensor Location: “..sensorLocOne)

    file.open( “sensorLocTwo.lua”, “r” )
    sensorLocTwo = file.read()
    sensorLocTwo = string.gsub(sensorLocTwo, “%s+”, “”)
    file.close()
    print(“Sensor Location: “..sensorLocTwo)

    conn = nil
    conn=net.createConnection(net.TCP, 0)

    conn:on(“receive”, function(conn, payload)
    gpio.write(4, gpio.LOW)
    tmr.alarm(0, 3000, 1, function()
    delay()
    end)
    end)

    conn:on(“connection”, function(conn, payload)
    print(‘\nConnected’)
    conn:send(“GET /trigger/” .. eventName .. “/with/key/” .. iftttKey .. “/?value1=” .. sensorType .. “&value2=” .. sensorLocOne .. “&value3=” ..sensorLocTwo
    ..” 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’)

    function delay()
    –wifi.sta.disconnect()
    –wifi.sta.config(“”,””)
    dofile(“delay.lua”)
    end

  7. Oliver October 11, 2017 - 4:28 pm Reply

    Hi,

    I made one of these and love it! I have it as a panic button and it worked great…to start with.

    When I’ve left it for a period of time now (a couple of hours maybe?) it just doesn’t respond to the button being pressed. I then have to do a full restart to get it to press. I’m going to try on another board as well as leave it plugged in with the lualoader on to see if it throws up anything, but do you have any ideas about this?

    Thanks

  8. Luigi November 16, 2017 - 9:32 am Reply

    Is there any other place to download the firmware? I’m having trouble getting it from the site you mentioned

    • SimpleIOThings November 17, 2017 - 3:43 am Reply

      You’re in luck because I was recently reviewing the page and realized some of the links went stale.

      You can find it here at the bottom of the page: https://github.com/nodemcu/nodemcu-firmware/releases

      Download the one name nodemcu_integer_0.9.6-dev_20150704.bin.

Leave a Reply

Your email address will not be published / Required fields are marked *