Introduction: Make Any Surface a "Touch Surface" to Trigger Automations IFTTT With NodeMCU and Piezo for Under $20 Bucks!

Hello, in this instructable you will learn how to turn any surface into an interactive surface with only basic knocks.

You can trigger your lights to turn on with 2 knocks and turn off with 3 knocks.

Perhaps you want to play music, send messages, find your phone, turn on tv, etc.


You can do all of that with IFTTT and this Project.


You can modify the Arduino code to match whatever secret knock you want to make.

The code was written by Steve Hoefer for hes door knock project. It was modified to accept multiple knocks by a friendly member of arduino forums. (Thanks Patduino) General idea of how to execute the project by Me.


The whole idea is inspired by "Knocki" a kickstarter project i´ve been following for a while but they have not release it yet. I didn´t want to wait any longer so i decided to create my own while they release their product.

I strongly recommend you to buy Knocki since that will be a user friendly device.



This instructable is for for entertainment and educational purposes.


In this project i triggered my chandelier which is connected to my HomeSeer Hs-Wd100+ Smart Z wave switch which is included in my SmartThings V2 Hub.


Your free to make improvements to this project but please post it in here so we can use it too!


To accomplish this project preferably you should have basic Arduino understanding and basic electronics knowledge.

Once you set up everything you can install the sensor wherever you want and change the settings via IFTTT so if after some time you want to use it for other purpose (For example instead of turning on your room´s light you wanna turn on your kitchen lights) you can do this by changing the automation in ifttt.

IMPORTANT NOTES ABOUT SOME ERRORS YOU COULD GET ARE ON THE LAST STEP!!!

Without any further ado let´s begin



Step 1: Components and Tools Needed.

Picture of Components and Tools Needed.

Components:

1- (1) NodeMCU (I used V3 by Lolin) - $8.07 usd on ebay from China and $16 usd from amazon US.

2- (1) Piezo sensor - $1.56 for 5 pieces on ebay.

3- (1) 1M Resistor - $1 usd for a pack.

4- (1) Micro USB cable with wall plug adapter. - You must have an old one around your house. if not $8 usd)

5- (1) Small case to fit the project. (I used my 3D printer and This NodeMCU case by Rreinhard in Thingiverse I modified the file to patch the hole it has in one face)

Tools:

1- Wire strippers

2- about 10 Cm of 22 AWG wire

3- Soldering Iron with flux paste and soldering wire.

4- Glue gun to stick the piezo sensor to the base of the enclosure.

5- 3M Double sided tape to stick the case to the surface of your choice.

(Alternatively you can use the protoboard quick connect cables if you dont want to solder anything)

Step 2: Knowing the NodeMCU Pinout and Wiring.

Picture of Knowing the NodeMCU Pinout and Wiring.

First we need to understand how to wire the piezo sensor to the NodeMCU.

(+) The positive terminal of the piezo goes to NodeMCU ADC0 (analog input 0).

(-) The negative terminal of the piezo goes to NodeMCU GND pin.

You need to solder a 1M resistor between piezo positive and negative!

Step 3: Let the Soldering Begin

Picture of Let the Soldering Begin

So now that we understand how to wire everything, its time to solder.

Remember to solder that 1M resistor between positive and negative or else you will get a lot of random values and the project wont work.

Once you get everything soldered, you need to place the NodeMCU and the Piezo sensor into the enclosure and stick the piezo sensor to the base with the glue gun.

Step 4: Setting Up IFTTT

Picture of Setting Up IFTTT

To make this work ofcourse we need a good multi device platform.


I chose IFTTT.

Register at IFTTT or login with your Google account. Once you login follow the steps bellow.


  1. Go to my Applets
  2. Services
  3. All services
  4. Type in the search bar "Webhooks" and click on the icon
  5. Select "Connect"
  6. Click on my Applets
  7. Create a new Applet
  8. Select "If this" Statement
  9. Again, search for "Webhooks" and click on the icon
  10. Select "Receive a web request"
  11. Create an event. You can call it however you want but for this demonstration i named it "Lights_Off"
  12. Select "Then that" Statement
  13. Type in the search bar whichever service you want to trigger. Im using SmartThings.
  14. Select "Switch Off"
  15. Select your device. Mine is "Chandelier" then create action.
  16. Select finish and go to home screen
  17. Go to My applets and then to Services on the right top corner select Documentation
  18. Type your Event name on the "{event}" and your done.

Now copy only this part /trigger/{event}/with/key/*YOUR KEY* and paste it in arduino.

Once you set up everything you can install the sensor wherever you want and change what it should do via IFTTT so if after some time you want to use it for other purpose (For example instead of turning on your room´s light you wanna turn on your kitchen lights) you can do this by changing the automation in ifttt.


You can create multiple IFTTT Applets with the same EVENT name so when you knock you trigger all of the applets with the exact same Webhooks event name.

Step 5: Time for Coding!

Picture of Time for Coding!
  1. Set up the NodeMCU with Arduino IDE
  2. Go to File/Preferences. copy and paste the link on the bottom of this list in "Boards manager URL"
  3. Modify the code to your needs
  4. Upload the code
  5. Test that the knock sensor is working fine

copy and paste this link: "http://arduino.esp8266.com/stable/package_esp8266com_index.json"

For the curious and with arduino coding knowledge you can add as many secret knocks as you wish. Just edit the code a little bit. This project is ready for a third secret knock pattern.

for better understanding of the code please visit Steve hoefer´s instructable HERE and scroll down to Step 2 to find more info about the RejectValue and other variables in the code.

Here´s the actual code

Step 6: Installation

Picture of Installation

Now you only have to stick some 3M double sided tape on the top side of your enclosure box and place your new invention wherever you want!

Thats it. Thanks for your time and reading this instructable. If you found this interesting or helpful please help me out Liking and sharing this project.

A few ideas to improve the project if you want:

  • Adding a rechargable battery.
  • Adding suction cup instead of the 3M tape.
  • Adding a Webserver so you can change the variables etc via a webpage.

A few errors you could run into

Error = "New lock stored"

Error = "WDT reset"

Fix = Try a different USB cable. the NodeMcu is not getting enough power. You can as well use a 5V power supply and plug it in "VIN" and "G" of the NodeMCU.

Comments

Swansong (author)2017-10-05

Knock on something and the lights go out. . . I'm seeing some awesome Halloween applications for this!

FedericoE7 (author)Swansong2017-10-05

Glad to hear that!, Let us know if you automate any props with this. also you can place the piezo under a mat or something and set down the threshold to a lower value for example (3) so its more sensitive. that way you can trigger pneumatics with a relay or something. Cheers