In short: I developed a portable, battery powered device that sounds an alarm when your bag or purse is moved. Once armed, can only be turned off by your secret code.

The device is built off an Arduino compatible Trinket Pro, using an off-the-shelf project box with PCB.


Problem I had:

When I go to a happy-hour or a cocktail party, I often have my computer bag with me. But I do not want to carry it around with me, so I put it down somewhere, hoping that no one takes it. I may check on it periodically, or stand so that my bag is in my view, but I am still concerned someone may take it. Or I may be traveling, taking a nap at an airport or when waiting for train and be concerned that it might disappear while I am sleeping. Or any number of circumstances in my life where I need to protect my bag from being stolen.

Solution I built:

I built a small, portable alarm to warn when my bag has been moved. It is 9V battery operated, but without an on/off switch, otherwise the potential thief could just hit the off button. As a result, I have an 'arm' button, and then you have 20 seconds to but the bag/purse + device stationary. After being armed, if the bag/device is moved for more than 5 seconds and above a threshold level, it sounds an alarm until the correct code is entered. The secret code uses a 4 button interface, but the code can be any length.

Genesis / special motivation:

My parents were recently traveling abroad, and their bag (with their camera) was stolen while they slept. I decided to build this for them for a Christmas present, so that they would not have to go through that again. I was thus forced to build this over the course of December, which was great motivation.


If you want more info on how I made this:

I also blogged about making this (and the challenges I faced along the way) on my personal blog at MakerSelf.com.


Improvements are coming! Improvements are coming!

I have been blown away by the interest in this project.Thanks to all the helpful comments I have received here and other inputs I have received, I intend on making an improved version of this project. Right now, I am thinking about adding a rechargeable battery and RF/Bluetooth. If you would like to be updated when that project is done feel free to sign up for updates (I can't embed a form here, so that is a direct link to a form to sign up to get updates). I don't intend on sending out very many updates: I am fairly lazy and hate email!

Putting this up publicly and having a signup is in part to give me motivation to complete the improvements: if there is a lot of interest, I will find the time!

Step 1: Gather Your Components

Obtain or purchase the following components:

Core components:

  1. A Trinket Pro as the brains of the show. You can get one from Adafruit or Hackaday.
  2. An accelerometer to tell when the device is moving. You can use a variety, but I used the GY-521 available from Amazon or Deal Extreme (or many other sources). The GY-521 is a bit overkill, as it also includes a gyro that I did not use in the product, but it was relatively affordable compared to commonly available accelerometers.
  3. A speaker/peizo to act as an alarm. You can use various depending on your preference for sound, but I used this one from RadioShack. I chose it based on the loud sound but low current consumption, and that it takes a broad range of voltages (3V-28V) so I wouldn't need to be too fussy about battery voltage.
  4. Four buttons to input a code
  5. One button to turn the device on, paired with a power circuit that allows the device to be turned on by hardware (the button), but off by software (by putting a pin to low)
  6. Two LEDs: one green LED to tell status, and one yellow LED as a low battery warning

Other components include:

  1. Project box. I used a project box with an integrated PCB and battery compartment, available from Amazon.
  2. Piece of perf board (doesn't need to be very big, just enough to cover one end of the project box)
  3. 2x P-Channel MOSFET transistor. From Mouser here. These are TO-92 packages, so fairly small. The max current is below what I anticipate would ever be needed to power all the components.
  4. 2x N-Channel MOSFET transistor. From Mouser here.
  5. 2x 330 ohm resistor (for current limiting on the LEDs). This does not have to be the exact resistance value, but in the general ballpark.
  6. 12x 10k ohm resistor (for ground ties, battery monitor pin voltage divider, etc.). The ground ties don't have to be exactly 10k, but just high enough, and the voltage divider just needs to be two the same value. I also tried 1k for these and it worked just fine.
  7. 1x 47k ohm resistor (for current limiting for the battery monitor pin). Also doesn't need to be exact.
  8. 1x 100nF capacitor (for dealing with any spikes on the battery monitor pin)
  9. 1x 6 pin female header
  10. 2x 12pin male headers (for the Trinket Pro, and may come with your Trinket Pro)
  11. 1x 9V battery clip
  12. 1x 9V battery
  13. Hook up wire (multi color if you want to keep things straight for yourself)
  14. Some thin foam padding (e.g. from envelope padding). This is optional, to make the battery fit more snug.

Step 2: Gather Your Tools

To complete this project you will need:

  • Soldering iron and solder
  • Hot glue gun
  • Dremel or similar saw (for cutting the perf board)
  • File (for filing the cut perf board)
  • Helping Hands and tweezers, for helping to hold and place the components
  • Wire snips
  • Wire stripper

Step 3: Plan How to Lay Out the Components on the PCB

I had prototyped this on a breadboard, so to make this an actual project I had to think about how to lay out the PCB. The PCB I used is the board that came with the project box, which you can see in the photo of the project box and components.

I put the schematic, fritzing wiring diagram, and the diagram of the layout on the PCB in the pictures.

For the Fritzing wiring diagram: I have used orange to indicate 9V rail (stripped indicates that it is only sometimes on), and red to indicate 5V rail. Ground is consistent as black. Yellow connects to the LEDs, Cyan to the push buttons, purple is the input to the battery monitor pin, blue is the SCL and SDA for the accelerometer, and green are the two switching pins (to turn the power circuit on and the speaker on.

For the layout on the PCB: I laid all the components out on the board by drawing it out on a piece of paper (just made it easier). The end result is in the picture, and some comments to explain how it works:

  • The two headers for the Trinket Pro are marked in the light blue boxes, with the USB port for the Trinket Pro pointed to the left. The headers I used on the Trinket Pro had enough space so I could run wires underneath it (you can see the gold, green, pink, red wires all underneath the board. These components and wires are actually placed on the OTHER side of the board, with the soldering on this side. For the GY-521, I actually soldered on a header, and then put the GY-521 into the header. I had enough head room (barely) in the project box to do this and it made it easier to fit the wires underneath the GY-521.
  • The grey lines are passive components, and are marked as what they are (e.g. 10k is a 10k ohm resistor).
  • The black, red and orange squares are ground, +5V and +9V rails. You will need to solder all connections in this square together.
  • The transistors are in an arrow head pattern, allowing the drain of the N-Channel MOSFETS to go directly to the gate of the P-Channel MOSFET. The top of the arrow head is the common source (+9V) for the two P-Channel MOSFETs. With the TO-92 packages, the P and N MOSFET pairs should either face each other or have their backs to each other. The left ones should face each other (rounded part towards rounded part) and the right ones should have backs to each other (flat part towards flat part). Confirm the pin layout for your transistors.
  • The five buttons and the two LEDs go on a piece of perf board that would replace the end piece of the project box was removable (see the small black rectangular piece in the project box picture above. Where those connections are (buttons and LEDs) are marked on the diagram above. Additional external connections are the battery + and - from the battery clip, and the speaker would just hang loose and be stuffed in on top of the Trinket Pro when closing up the box.

Step 4: Cut the Perf Board

The easiest way to mount the buttons is to cut a piece of perf board the same size as the end piece for the project box. To do this:

  1. Trace out the piece from the project box on a piece of perf board (see pic 1)
  2. Then cut it with a Dremel (see pics 2 and 3)
  3. Then file the perf board (see pic 4) so it matched the piece from the project box pretty exactly (see pic 5)
  4. Finally, make sure the perf board fits nicely in the project box before proceeding (see pic 6)

Step 5: Solder the Perf Board

It is easier to solder to the components on the perf board first, and then solder the other end of the wire to the project board.

After laying out the buttons and the LEDs on the perf board to get a sense of where they will go:

  1. Solder the LEDs (excuse the abundant and poor quality soldering in the pics 1 and 2!).
  2. Solder on the buttons. The easiest way is to loop the wire into the perf board (through a hole under the button), and then out the hole where the leg of the button would be coming out. This way, they are both coming out the same direction and it made it a lot easier to solder. You can see the loops in pic 3. Make sure that you put the loops on opposite sides of the button, so that they are not connected normally. Then place your button on top of the loops (pic 4) and squish it down (pic 5).
  3. Solder wires to the two ends of the button on the opposite side of the perf board (pic 6) I also put a little solder on the unused legs, just for additional physical support. Complete this for the rest of the buttons (pic 7 and 8).

Step 6: Solder the Project Board

It takes a fair amount of time to solder the board. Start with placing all the passive components and wires on the board, and then turning it over and soldering all of those components.

The board that comes with the box is a one-sided board. Place all the components on the side that does NOT have the plating, and then solder on the side that does have the plating. In many cases, there are multiple things that go into the same hole (e.g. resistor and a wire) so make sure you get both in there before soldering it up.

  1. First, do the transistors, resistors for the power circuit and wires that run to them from the Trinket Pro pins (pic 1). I used little loops of wire to run the ground link from the source of the N-Channel MOSFETs (pic 2), and then the wires that would come from out from under the Trinket Pro go through them. Always be conscious that you need to put the Trinket Pro overtop of these wires.
  2. I had red and black hook up wire, so the red was power and the black was ground and logic wires (pic 3 is clearest on this).
  3. Periodically (when done a section), flip it over and solder those components (see pic 4).
  4. Then add the other components and wires in a step by step fashion (pic 5), following the PCB layout from earlier. Pic 6 shows it nearly complete, but still a few wires to add in the above (e.g. from SDA and SCL to the Trinket Pro).

NOTE: do not complete soldering on this board, as you still need to connect the perf board wires to the project board. Where there are holes that the wires from the perf board will come in or holes where the Trinket Pro will be added, hold off else you will not be able to make the connection if you do the soldering already.

Step 7: Solder the Connection Between the Perf Board and the Project Board

Connect the two boards by soldering the wires from the perf board to the right spot on the project board. You should not have soldered these connections yet.

  1. Start with one button (in pic 1, the power button).
  2. Then complete the rest of the connections (pic 2). Note: in this pic, I had temporarily removed the header for the the GY-521 while doing this soldering, and soldered it on later.

Step 8: Add the Trinket Pro

In order to add the Trinket Pro to the board:

  1. Insert the Trinket Pro over top of the wires in the center of the board. This is why you needed to keep the wires low profile and tight to PCB for those that will end up under the Trinket Pro. The Trinket Pro has some space under it with the headers, but not a lot.
  2. Then flip it over and solder the remaining pins.

Step 9: Insert Accelerometer and Finalize Soldering

Finalize any soldering (e.g. ground rails) and insert the GY-521 accelerometer into the header. I made the accelerometer fit into a header as it made it easier to have the wires underneath it (it did not have as much space as the Trinket Pro under it if directly on the PCB). I would have done the same for the Trinket Pro, but the room above the Trinket Pro was not enough inside the project box, so I needed to put it directly on the PCB.

Step 10: Upload the Sketch to the Board

Really, you could upload the sketch first, but you will possibly need to upload a revised version to the Trinket Pro here anyway to do some modifications (e.g. flip the pins for the LEDs if they are connected to the wrong ones).

The Trinket Pro requires you to take a few steps to get code to upload. You can read about it at Adafruit, or you can also read more at MakerSelf (my personal blog) as to how to do this.

The sketch is attached (alarmbox.ino).

IMPORTANT: Before you upload the sketch, set your secret code in the sketch. This is in the section marked " --SECRET CODE-- " along with all the other user changeable parameters. If you change the length of the code (eg. 4 digits instead of 7 digits), make sure you also change the "secretCodeLength" to reflect the new length.

You can also change all the other parameters, such as sensitivity or how long upfront you have to put the device stationary (starts as 20 seconds).

Step 11: Test the Device and User Interface

The project should work now. Test it out. Make sure it works and the user interface is working fine and that the different elements of the user interface make sense for you. Now is the time to change any of these elements, as once you put it into the project box it will be very hard to make the changes.

You can see a video of the test above.

The user interface is as follows. The [x] indicate changeable elements (hard coded in the top of the sketch).

(1) Device is normally off. Press and hold power button for 3-5 seconds to turn device on; wait for the Status LED [green LED] to turn on.

(2) After powering up, Status LED will blink for [10] seconds. During this time the user must enter the [secret code]. This is to ensure against turning on accidentally as well as to ensure that user remembers what the code is before the device gets armed. If the user does not successfully enter the secret code during this time, the device turns itself off.

(3) After successfully entering the code, the Status LED will turn solid on. This indicates that the device is giving the user time to put the device stationary, in this sketch [20] seconds.

(4) The Status LED turns off, indicating that the device is now armed and listening to the accelerometer. If there is movement, the Status LED blinks slightly to indicate movement.

(5) If there is movement for more than [5] seconds and above [threshold], the alarm goes off and turns the Status LED solid on. The alarm stays on until the user enters the secret code.

(6) Once the device is on, if the user enters the secret code after or during the settling time, the Status LED will blink once long, then three short, and then then the device will turn itself off without turning the alarm on.

(7) If the battery is low voltage, set as below [6.5] volts, then when the Status LED is turned on in step (1) or in (5) or (6), the Battery Low Voltage LED [yellow LED] will turn on solid on.

Step 12: Put the Project PCB Into the Project Box

Insert the screws into the holes of the project board (I could only get three in there, which was good enough, see pic 1), and then insert the project board into the bottom box and screw the screws in (see pic 2).

Then add some hot glue to the battery connection wires, so they don't get pulled on at the connection to the project board (pic 3).

Step 13: Put the Perf Board Into the Project Box

The perf board was cut to fit the end piece exactly, so slide it in were the end piece would have gone. You can discard of the end piece for the project box.

Step 14: Close Up the Project Box

Squeeze the wires into the box and close the box, placing the buzzer (which up to now has been hanging loose) on top of the Trinket Pro. This can be a bit of a challenge, and will likely required bending the wires a fair amount to fit it all in, particularly the wires to the buttons from the 5V rail on the close side of the project board (in pic 1).

Then screw in the screws for the project box, and attach the battery (see pic 2).

Step 15: Add Padding for Battery (optional)

If the 9V battery is not quite snug, you can add some padding to battery compartment.

Use some thin foam padding and hot glue it into the box. When doing this, put the hot glue in the project box, and then wait a few seconds to let it start to cool down. On the first time, I did not and the hot glue melted the foam a bit.

Step 16: Put the Battery Cover On. You're Done!

Add the battery cover, and now it is ready for use.

Final, completed device in action in the video.

<p>Hey dude what amount of watt has everything to be?</p>
<p>Depends on the component!</p><p>You probably need to pay attention to the voltage (not watts) of the power supply to the accelerometer, trinket, etc and they will most likely be 5V (or 3.3V depending on what components you select).</p><p>For the speaker, well you could have a range of potential watts. This is controlled by a MOSFET so you can have various watt speakers depending on how loud you want to go and how much power (e.g. from the battery) you are willing to supply.</p>
<p>I need a something similar but for my car.</p><p>In the city where my parents live, it is usually that car tires are stolen at midnight. So I think that a similar device could be useful, with a minor modifications.</p><p>Modifications:</p><p>1) Add WiFi to connect to the house AP, and then send an alert to a smartphone.</p><p>2) The device itself has no sound and/or alarm.</p>
<p>Nice! But this circuit could be much simpler. Without arduino, the same functions, smaller, less consumption, and cheapest.</p>
<p>can you show how it works with arduino ?</p>
It works with Arduino now!<br> <br> The Trinket Pro is an Arduino-compatible device, and that is what this is built off. There are a few minor modifications in the code (e.g. you can't use pin 7) necessary to move from say an Arduino Uno to a Trinket Pro, but I programmed this using the Arduino IDE.<br> <br> Read more at: <a href="https://makerself.wordpress.com/2014/12/23/replacing-the-uno-with-the-trinketpro/" rel="nofollow">https://makerself.wordpress.com/2014/12/23/replacing-the-uno-with-the-trinketpro</a>/<br> <br> You can download the .ino file in this instructable.
<p>I think, today, the microcontrollers cards are used for simple circuits that could be made with digital or analog components. This is caused for the low cost of this products.<br>For complex circuits, Arduino is fine for his prototypes. But, for the &quot;final product&quot; should be built directly only with the microcontroller chip. In this case with ATtiny is enough, no need the ATmega:<br>https://www.instructables.com/id/Backpack-Anti-Theft-Alarm/</p>
<p>I think the Arduino got past a lot of barriers quickly; rather than implementing logic in other discrete components it takes care of the timers, passcode and outputs.</p>
<p>A well designed piece of discrete logic could, I'd guess, potentially last longer on battery and also be less susceptible to coding bugs. It's really less of a better/worse though than it is a matter of practical implementation.</p>
<p>Thanks! Would be interested to know exactly how you would make this simpler, without the arduino as brains. Maybe another instructable? Or comment/message me?</p>
<p>Arduino pro mini only costs 1.60 euro :-)</p>
Hello can you this build this ir jammer device this send information to the bill acceptir wrinting me on email rewe.dekra@web.de
<p>I wonder if you could add a proximity key to the board much like those found in modern vehicles. If you could, it would allow you to move your bag without having to set off the alarm and/or key in the code, but if anyone not carrying the RFID device (which could easily be attached to a key chain) tried to move it, the alarm would sound. Of course you'd have the key pad as backup, but it might make it a little more user friendly.</p>
<p>Thanks! A proximity measure (either RF or bluetooth) could be useful, and an interesting challenge if I make any improvements to this.</p>
<p>Did you know if you warm up the perf board over a stove flame, you can clean cut it with scissors? I use this method and looks better than cutting with dremel or hacksaw. Just be careful when manipulating it over the flame. 10&quot; above it will do. Use pliers to hold it. Works like a charm. :)</p>
<p>Neat! I didnt know that about heating perf board! tnx ..</p><p>I guess that suggests they should never be part of any</p><p>fire-alarm system ;))</p><p>This is a nice 'structable and has inspired me to go crazy tracing wires in conversion from breadboard ;)</p>
<strong>FR4</strong> <em>does not work</em> with the heating, though. Only phenolic, like that on this instructable, and the light-beige ones. I learned it from a professor when I was in college. I've done this to cut perfboards so the pattern is diagonal relative to the board dimensions. Also, if doing it very carefully, you can make circular boards. Perfect for light fixture development. Cheers!<br> PS: Use strong scissors, like those &quot;kitchen&quot; models with thicker blades. An office paper-guillotine can also be used so the cuts are square.
<p>Gotta try it! =D</p>
<p>Thanks! Will try that next time.</p>
<p>Incredible Ible...</p>
<p>Nice project. You should add a small cable lock that you can loop around a closed strap on the bag to make it more difficult for someone to just discard the alarm. Also, making the alarm louder would probably improve the deterrent effect. Nobody is going to want to be walking around with a bag emitting a loud alarm. </p><p>The only problem I can see is that this would probably either get confiscated by the TSA or at least cause you get extra scrutiny during security screening.</p>
<p>That would be cool. Will look at that if I make a next version.</p><p>Any suggestions on how to make the alarm louder?</p><p>As for TSA, I actually took this through my hand luggage in January, and had no problems!</p>
<p>I suspect the TSA gives a pass to things that appear to be intentionally designed and don't appear to be threatening or obviously questionable. You might consider making a design that you could make part of the bag in question as a more permanent fixture. Would also be interesting to incorporate some open/close sensors (something that involves conductive thread?) to discourage people from peeking in it too.</p>
<p>Cool idea!</p>
<p>Nice! Cool project and great finished product :)</p>
<p>It was fun to make!</p>
<p>Wow, pretty cool project! I can imagine this being very handy for somebody who travels a lot.</p><p>Good pictures and documentation too! Thanks for sharing!</p>
<p>Thanks! My pleasure :-)</p>
<p>This is Awesome!, Might Consider Building one myself one of these days... :P Thx</p>
<p>Did you think about securing the battery before you developed the passcode system? I would recommend putting a screw through the battery cover, or putting a large capacitor inside to keep it running when the battery is pulled.</p>
<p>Yeah, the battery being removed is one weakness. I figured the idea is to make it a quick notice: by the time the would be thief realizes what it is and opens up the box and removes the battery, you will also have noticed.</p><p>That said, if I build a next version I would probably put in a rechargable battery (e.g. lithium) that is screwed into the box (so not battery access panel).</p>
<p>Wow, this is awesome! I like how you managed to get everything so snug, and nothing rattles or anything, if i made it i would probably just use a key switch, but this is much better for travel. You would sell these for quite a bit :)</p><p>Nice! </p>
<p>Thanks! It was a squeeze to get it in, but it worked out great in the end. It took me a while to figure out how to fit it all on the the PCB I had, with the arrow head arrangement for the transistors being key.</p>
Pick up a Screaming Meany alarm clock at a truck stop &amp; wire that in for noise. Those things will wake the dead.
<p>Thanks! Just checked it out and looks awesome. Any idea what the alarm part in it is?</p>
<p>I kinda agree with both. Arduinos are cool but I love simple machines. The simpler the better. The timer could be a simple 10-second delay or maybe have no delay (set the bag down, push the Arm button and gently back away. Whew!). <br><br>The Disarm/Silence passocde could be pressing two (or three) particular buttons at once but no others (the four or five code buttons would be a combination of NO and NC buttons) to arrive at the Disarm &quot;code&quot;.<br><br>Nice Instructable!</p>
<p>very handy</p>
Nice idea and very useful

About This Instructable




Bio: Rediscovering my inner maker! I used to build things, and am rediscovering electronics, coding and other 'real' things. If you want to know the challenges ... More »
More by micahmelnyk:Replace battery for Motorola Moto G (possibly Moto X as well) Bag movement alarm for theft prevention 
Add instructable to: