element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog Enchanted Objects Design Challenge - An unexpected visitor to the Enchanted Cottage
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 1 Jun 2015 6:18 AM Date Created
  • Views 1426 views
  • Likes 7 likes
  • Comments 7 comments
  • enchanted_cottage
  • enchanted_objects
  • arduino_yun
Related
Recommended

Enchanted Objects Design Challenge - An unexpected visitor to the Enchanted Cottage

Workshopshed
Workshopshed
1 Jun 2015

Who's at the door

 

Hans and Matilda were fast asleep when they heard a knock at the door. He put on a robe and wandered over to the door. "Who is it", he asked, "The postman" replied the stranger. Hans peered through the spyhole and saw the cap of the postman. Why is the postman visiting in the middle of the night thought Hans? He looked again, below the cap he saw a large pair of eyes, above the cap he saw a large pair of hairy ears and through the darkness he saw a large set of sharp teeth. It was the Wolf!

 

image

 

He checked the door was securely bolted and headed back to bed. Before he'd even made it to the bedroom there was another knock at the door so he headed back. Peering out of the door this time he saw a bowler hat. "Who is it?" he asked. "It's the Doctor" the hat replied. Hans looked through the hole again. Underneath the hat were two large eyes, a large nose and a large set of teeth. Hans backed away from the door, when there was yet another knock. "Who is he asked", "It's the UPS guy with your Element14 delivery", was the reply. Hans was overjoyed and was just about to open the door when he decided to look through the spyhole again. Again a hatted figure stood outside, and again the figure had large fury ears, large eyes and very large and pointy teeth. Hans went back to bed. That night there was a range of visitors to his door claiming to be the milkman, the window cleaner and finally granny. After that Hans stopped answering the knocks at the door and tried to get to sleep.

 

Knock Knock

 

In the morning Hans had a couple of thoughts, the first was he wanted to upgrade his security and the other was that it might be quite good for the system to check the weather automatically in response to people knocking on the door.

 

Hans realised that there was a buzzer in the Arduino kit and looked into taking that apart to use as a sensor. It did not want to open up easily so he invested in some new sensors, some simple piezo transducers.

image

A bit of googling found a suitable circuit for conditioning the sensor signal. The piezo transducer is effectively a voltage source, when the crystal deforms a small voltage is produced. If we put that into a comparator then we can create a strong 0v - 5v swing to indicate the knock. This should be sufficient to wake the Arduino from sleep. A large resistor allows that voltage to discharge and zener diodes stop the inputs being overloaded.

 

image

From Thoughts on interfacing piezo vibration sensor - Do It Easy With ScienceProg

 

Looking in the spares cupboard there were a bunch of 741 opamps that could be used for the comparator but checking the spec he realised that they were not designed to work from a 5v supply, and there were also comments that the output swing was less than the rails so some LM393 comparators were also ordered.

 

Excuse me for interrupting

 

Whilst he was waiting for those he did some tests with the interrupts. Reading the Arduino site he learn that only certain pins could be configured as an external interrupt. Looking at the pin out diagram, all of there are taken by the bridge to the Linino module or the I2C bus.

image

from http://www.pighixxx.com/test/pinoutspg/boards/

 

Hans saw a cryptic comment in the Arduino documentation that some of the Atmel chips supported change interrupts on many more pins. But there was no specific reference to the Yún or the ATMega32u4 and no details on how to how to attach the interrupt handler code to the pin. Luckily Matt Walkers article on Pin Change Interupts explained how it all worked and a bit of further digging found Mike Schwager's library that wraps up all the AVR specific commands in a friendly way.

 

Hans tested this firstly in a simple example.

 

#include "EnableInterrupt.h"
int led = 13;
int myint = 11;
volatile int state = LOW;
void setup()
{
   pinMode(led, OUTPUT);
   enableInterrupt(myint, blink, CHANGE);
}
void loop()
{
   digitalWrite(led, state);
}
void blink()
{
   state = !state;
}
  

 

Then in a power down scenario.

 

#include "EnableInterrupt.h"
#include "LowPower.h"
int led = 13;
int myint = 11;
volatile int state = LOW;
void setup()
{
   pinMode(led, OUTPUT);
   pinMode(myint, INPUT);
   enableInterrupt(myint, blink, CHANGE);
   delay(25000); //Time to reprogramme!
}
void loop()
{
   digitalWrite(led, state);
   LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}
void blink()
{
   state = !state;
}
  

 

Code at: https://github.com/Workshopshed/EnchantedObjects/tree/master/Code

 

These tests proved successful so Hans was happy to make up the circuit once the parts arrived.

 

Next: Enchanted Objects Design Challenge - Knock Knock

 

Reference

http://www.scienceprog.com/thoughts-on-interfacing-piezo-vibration-sensor/

http://www.ti.com/product/lm393

https://github.com/GreyGnome/EnableInterrupt
Arduino - Interrupts
Gammon Forum : Electronics : Microprocessors : Interrupts

Geert's pages - Pin-change interrupts on Arduino

Arduino Pin Change Interrupts | The Wandering Engineer

  • Sign in to reply

Top Comments

  • Workshopshed
    Workshopshed over 10 years ago in reply to balearicdynamics +3
    He sounds like an interesting fellow http://en.wikipedia.org/wiki/Piero_Angela I don't often use story telling as method of explanation but I do like to use " The Blind Men and the Elephant" when discussing…
  • Workshopshed
    Workshopshed over 10 years ago in reply to balearicdynamics +1
    I hope to follow up with an analysis of how the Yún responds to brute force login attempts
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed +1
    Andy, I wrote for years as a technical journalist too - when I was in Italy - and one of the more appreciated teachings, my "heroes", was those technical writers able to tell an intriguing story explaining…
  • Workshopshed
    Workshopshed over 10 years ago in reply to Jan Cumps

    I'm using a standard HTTPS call to the web service and checking that their certificate is valid, I ended up using PyCurl Enchanted Objects Design Challenge - Taming the Python because I could not get the other library to install Enchanted Objects Design Challenge - The snake, the troll and the fighting dwarves

     

    If you are using MQTT you can't go too far wrong reading that series http://www.hivemq.com/blog/

     

    Of course I could always weld the Yún into a steel box too.....

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 10 years ago

    I saw your tweet on secure MQTT. I haven't given security the attention it needs yet. I may be lurking to see how you're implementing it, and steal your design.

    I'm not sending sensitive data, but it would still be nice to implement some security while talking to the cloud (the Yún will have that duty).

     

    At one point I also thought to use the SAMA5D4 internal hardware encryption module (something I've done successful with a Zero Gecko previously for a road test: EFM32Tm Zero Gecko: Encryption with AES), but that's on the backburner for this project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed

    Yes, he is also a very good person. When I worked at university in Turin, there was a group of naturalists and anthropologists that was friends and he was part of this friendly group. I had the opportunity to know him and he was really great. Also if you don't know Italian, only taking a look to some image of his videos you can have an idea of how he was explaining science. There was a great TV series "quark" where he explained tons of complex principles of physics, math and so on in a highly understandable way. (Video Rai.TV - Superquark 2013 - Viaggio alla scoperta del cervello - Speciale Superquark del 19/12/2013  his son is following the same path with the same high quality) image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago in reply to balearicdynamics

    He sounds like an interesting fellow http://en.wikipedia.org/wiki/Piero_Angela

     

    I don't often use story telling as method of explanation but I do like to use "The Blind Men and the Elephant" when discussing how to programme interfaces and I do vaguely remember writing about polymorphism using a courier company with a van, bike and car.

    image

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed

    Andy,

     

    I wrote for years as a technical journalist too - when I was in Italy - and one of the more appreciated teachings, my "heroes", was those technical writers able to tell an intriguing story explaining very complex or unusual things. First of all the scientific books of the beloved Isaac Asimov. In Italy a great technical writer was Piero Angela, able to explain the most complex things in a very fascinating way.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube