Present Shake Detector

Introduction: Present Shake Detector

About: I am an application engineer for an industrial distributor. I help to support our sales team in programming of new projects for our customers. I enjoy working on hobby electronics in my free time, mostly wit…

In this project we are going to make a device that will sound an alarm if someone shakes a present/box. I got this idea when we got a package in the mail for Christmas. To try and guess what was in it, of course we shook it just like everyone does to see if they can figure out what's inside. This project we will be creating a fake present to put under the tree and if someone tries to sneak a shake to see what's inside, it will set off the alarm.


  • (1) ELEGOO Mega 2560 Project The Most Complete Ultimate Starter Kit w/Tutorial Compatible with Arduino IDE - Amazon, non-affiliate
    • MEGA 2560 Controller
    • GY-521 IMU
    • Active Buzzer
    • Prototype Shield
    • Small Breaboard
    • Jumper Wire
    • 9V Battery Pack

Step 1: Assembly and Connections

For this project I decided to use the prototyping shield with a breadboard stuck onto it. I opted to use the breadboard instead of the solder points so that I could more easily reuse these components since this won't be a permanent installation. Thought the prototyping shield has labels on the PCB for the headers, once the breadboard was on it was impossible to see these labels. That's when I noticed the silk screen on the side of the headers on the Mega which makes it pretty easy to know where you're making connections at all times.

The wire connections are as follows...

IMU (VCC) - Arduino (3V3)

IMU (GND - Arduino (GND)

IMU (SCL) - Arduino (SCL/pin 21)

IMU (SDA) - Arduino (SDA/pin 20)

Buzzer (+) - Arduino (pin 11)

Buzzer (-) - Arduino (GND)

The IMU has some additional connections that I did not use since I only needed the basic data. There is an address pin that can be used to set a different address for the I2C in case you are using multiple of these devices. There is also an interrupt pin that can be used as well as some pass through for the I2C bus.

These active buzzers are pretty loud and ship with a protective piece of tape over them. If you leave this tape on, the sound from the buzzer is bearable. Once you remove the tape, it is not fun to listen to for very long. I'm not sure exactly how load this buzzer is but it will get your attention from the next room when it goes off. According to a sound meter app on my phone, it's about 70dB.

Step 2: Sample Code

The main piece of this project is the IMU board which is based on the MPU-6050 which is an I2C device. For Arduino ID, these types of devices usually get implemented using the 'Wire' library which handles I2C communications. As I've learned, there is no need to re-invent the wheel, or re-write code that has been used and tested before.

I started with the sample project from the Elegoo kit fore reading the data from the IMU. This program would read all of the accelerometer, gyro and temperature data from the sensor, store it to a variable then display that through the serial monitor. I simply added a threshold value for the accelerometer data and compared the X and Y accelerometer data to this value to decide if a 'shake' had been detected.

Once a shake is detected, the buzzer will turn on/off. The buzzer will continue to go off until the battery dies, or the controller is reset. I thought about adding a routine that would allow you to place the box in a certain orientation for some amount of time and it would reset the buzzer. Then I decided that it would be more annoying to just have no reset and infinite buzzing!

Step 3: Wrap Up and Expansion Ideas

To, quite literally, wrap this project up, I used some double sided foam tape on the bottom of the MEGA to fix it to the bottom of a cardboard box. The foam tape has some thickness to it so the solder joints of the headers won't prevent the board from sticking. The Elegoo kit also came with a 9V battery and a connector that has a barrel jack on the end for connecting directly to the MEGA. This is used so that of course you don't have an obvious power source and nobody would know that this is not a real gift. Once everything is mounted in the box, simply close it up and wrap it like any other gift!

Some other additions to this project that I have thought about was to use a vibratory motor so that the present would 'come alive' in the persons hands and would start to shake. This could provide a better reaction than just a buzzer.

A louder buzzer is always a desired upgrade, but I also think it would be cool to have one of those MP3 sound modules so that you could play some pre-recorded phrases or movie clips if the box is shook.

Wireless connectivity using a WiFi module that could send you a message whenever the package is disturbed.

A modified version with motion sensors around the sides to deter maybe a pet that is getting too nosey with the presents. We have this issue with a dog that likes to steal presents from under our tree and take them outside.

I hope that this Instructable has given you some idea of something that you can do with these sensors. Feel free to reach out with any questions!

Be the First to Share


    • Rice & Grains Challenge

      Rice & Grains Challenge
    • Lamps Challenge

      Lamps Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest