Go Down

Topic: 1 Piezo sensor and multiple Secret knocks? (Read 759 times) previous topic - next topic

FedxE

Hello, I'm no programmer but i want to modify this code by Steve Hoefer


What i want is that the same Piezo sensor could read 2 or 3 different secret knocks and respond with different values.

for example:

if
secret knock-1 (2 knocks)
then
set Digital Pin 2 HIGH

if
secret knock-2 (3) knocks
then
set DigitalPin 3 High


I'm willing to pay if someone could do this. i've been trying to do this since last 2 weeks with no luck. Thanks

FedxE

Heres the Arduino file script.

patduino

Hi FedxE,

Are you sure that the circuitry works?  What have you been able to do -- can you detect any knocks at all?

Pat.
There are 10 types of people in the world, those who understand binary, and those that don't.

PaulMurrayCbr

Before offering bunch of programming advice, the first question is: have you been able to get the initial sketch working? No point attempting to modify something that doesn't work.
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

FedxE

Hello guys, thanks for your time. Regarding your questions. Yes it works exactlly like it should. My piezo reads the knocks just fine and does what it suppose to do.  When i started a few weeks back I added a second secret knock and i duplicated everything in the script (i added a "1" in the end of each variable or int. For example; secrerknock and secretknock1, listentosecretknock and listentosecretknock1) the problem i had was that when the script started to read, some times it would look for secretknock and sometimes for secretknock1 but it would never listen for both at the same time. So it was pointless. I dont know if it makes any sense what i just wrote. I will try to recreate the script and upload a video. Thanks!

patduino

You'll need to look for both knock patterns concurrently and pick the first one that matches.
There are 10 types of people in the world, those who understand binary, and those that don't.

FedxE

Could you please give me a hint? As i stated above im no programmer :smiley-confuse: ! Thanks

patduino

Ok, yeah, I saw that. I'll download your example and let you know what I think.

Just out of curiosity, what's the application for this?
There are 10 types of people in the world, those who understand binary, and those that don't.

PaulS

Quote
Could you please give me a hint?
Suppose that you have two patterns, 120221 and 212012, where the 0, 1, and 2 represent interval muliplicands. If you get a duration of 1 times the interval, compare that with the first value in each pattern. Only one matches. If the next value you get is 2, the first pattern is still in contention. If the next value is a 4, that doesn't match the next value in any of the patterns still in contention, so the knock sequence is not one you are supposed to recognize.

However you represent the patterns that are valid knock patterns, you get knocks at some interval that you morph in the same way you morphed the data in the valid knock patterns. The 0 through n morphed values match, or do not match the 0 through n morphed values in the stored patterns.
The art of getting good answers lies in asking good questions.

FedxE

Ok, yeah, I saw that. I'll download your example and let you know what I think.

Just out of curiosity, what's the application for this?
Hey, thanks! I'm pretty sure you've heard of "Knocki" if not, search for it. Its a device that lets you turn any surface into "touch surface" and lets you interact with your smart home. I have a smartthings hub in my house and i have everything automated. I use ifttt or webcore which lets me control my switches etc by using web requests.

I have an esp-8266 with a web request script that works like this:

If
 GPIO 0 is HIGH
Then
 Send web request (Ifttt url that turns on my lights)

If
 GPIO 2 is HIGH
Then
 Send web request (Ifttt url that turns off my lights)

if you'd like i can attach the ifttt script.

Bottom line, arduino has a script about knocks if the first secret knock is validated then it turns Pin 6 to HIGH  which is connected to ESP'S GPIO 0.

If the SECOND secret knock is validated it turns pin 7 to HIGH which is connected to ESP'S GPIO 2.

P.S i want to create my own because kocki is still a work in progress and idk when is it gonna be available.

patduino

Thanks for the info.  I'm pretty impressed with the whole SmartThings environment. 

It also sounds like you're an IFTTT power user; nice!

At one time, SmartThings offered an Arduino shield, but that hasn't been available for a year+ or so... I was working with a client that had grand plans for them, but -- poof!  gone.
There are 10 types of people in the world, those who understand binary, and those that don't.

patduino

Ok... So after looking over your example code, I think the easiest thing will be to leave it essentially as-is, but check the collected knock pattern against both (or more) secret code patterns and return a code associated with the pattern that matches.
There are 10 types of people in the world, those who understand binary, and those that don't.

jarnoldbrown

Can you show the piezo and the circuitry around it? Would be hard to check without knowing that.

FedxE

#13
Sep 22, 2017, 02:22 am Last Edit: Sep 22, 2017, 02:47 am by FedxE
Can you show the piezo and the circuitry around it? Would be hard to check without knowing that.

just like this: https://www.arduino.cc/en/uploads/Tutorial/knock_bb.png

Thanks for your time

FedxE

Ok... So after looking over your example code, I think the easiest thing will be to leave it essentially as-is, but check the collected knock pattern against both (or more) secret code patterns and return a code associated with the pattern that matches.
Hey, i tried a few things with no luck. Anyways thanks for the help!

Go Up