by

Arduino based Car Alarm with Accelerometer

Inspiration for a car alarm, what could that be? Around the beginning of 2018, I came into the prospect of buying a 2006 Jeep Liberty. I had been happily driving my 1998 Toyota Camry for years prior, and hadn’t really thought about acquiring another vehicle, but something about 4WD, and driving a big powerful vehicle seemed intriguing. I decided to go for it, as the price seemed about right. However, I didn’t know what I was in for. It seems that these vehicles are sought after by thieves; something I would become well aware of in the near future.

I think almost immediately after buying the Jeep, the rear vent window was broken out. I decided I should buy a “Club”, or possibly the thought occurred to me to buy the club before it the window was broken; in any case, I had not purchased the club, and the window was broken. This led to me buying the club, which dissuaded further break-ins for a little while; this was until I forgot to put the Club onto the steering wheel one day, boom, another vent window broken. If there’s something that irritates me, it’s breaking my property, and trying to then steal it. But I digress, now that the motivation of the Alarm should be clear, let’s get back to making it!

Screenshot-2019-02-23-11-03-50

Back just prior to all of these break-ins, the Radio Shacks in the area were going out of business, and they were practically giving away everything in the store. So, needless to say, whenever there was a closing, I was there, raiding the inventory. Among the inventory, there were some Accelerators that before the closing of the store, were going for something like $40, but were now on sale for a fraction of that, or just a few dollars; I do not remember anymore the precise amount. Without a clear use in mind, I decided to buy one anyway. Now, thinking about what I could use to create a car alarm, an accelerator seemed like a great piece of hardware. Someone manhandling the vehicle would surely create some movement that would be detectable.

2018-02-21-15-07-36

With the help of some test code for the Memsic 2125 Dual-axis Accelerometer, I was reading values that would change upon moment of the Accelerometer. Because I was not interested in the orientation of the device, but solely if there was some slight movement, I could just compare the numerical output from one of the axes. If it varied enough, I could create some sort of alarm. Since this would be a one-off project, I decided to etch a custom circuit board, and use the Atmega328p, along with a RGB LED, to indicate the state the alarm was in.

2019-02-22-13-14-47

I decided that the RGB would flash red and blue when in alarm, and if enough alarms had been achieved in a set amount of time, an additional alarm type would be added, such as a buzzer, or car horn. If everything was normal, a green light would blink. I added a few potentiometers and a push button to vary basic values, such as sensitivity, time between alarm cycles, and number of first alarm cycles until type two alarm is activated. The programming this alarm helped me learn about programming timers and loops, as there cannot be any delays where information would fail to be processed.

Link to code