📜 ⬆️ ⬇️

Moto alarm based on Arduino UNO with accelerometer MMA7361

Hello to all habrauser. I present to you my first project on the Arduino, entitled “Motor-alarm based on the Arduino UNO paired with the accelerometer MMA7361”.

The principle of operation is as follows: Arduino interrogates the accelerometer, reads data on the X, Y, Z axes and if there are deviations from the values ​​that were when the alarm was turned on more than the allowable value, the siren turns on. Those. no data need to be entered, no matter at what angle you left your motorcycle, even if you put it on your side - after turning on the alarm, the current coordinates appear at the X, Y, Z axes and if at the time of the survey the current coordinates are at least along one axis different from previous by an amount greater than that set by us (a potentiometer is used for this) —the alarm goes off. In other words, if your motorcycle is touched, tilted, trying to move, in general, create movement - the siren turns on.

imageimage

For the implementation we need:
')
Arduino uno
Accelerometer MMA7361
Potentiometer
Siren - I took 110dB DC 6 ~ 16V
Connecting wires
On / Off button
Bracket for mounting the accelerometer - did it yourself
Power supply - I took the Krona, you can also be powered from the on-board motorcycle network
The case in which all this place - I took from the dead power supply

Connection of accessories to Arduino UNO
Accelerometer MMA7361Arduino unoPotentiometerArduino unoSirenArduino uno
XPin A5Left contactGNDMinusGND
YPin A4Central contactPin A2A plusPin 11
ZPin A3Right contactPin 7
SL3.3V
5VPin 8
GNDGND


imageimage

imageimage

I will explain the connection a bit. You probably have a question, why do I connect the power of the 5V accelerometer to Pin 8, and not directly to 5V? Made it to save. Power to the accelerometer is supplied only at the time of the survey. In order for the accelerometer to always produce values, it must be forcibly removed from sleep mode by applying 3.3V power to the SL (Sleep) output.

Now about the potentiometer, what is it for? We need it for the convenience of selecting the sensitivity of the alarm. Rotating it, you select the deviation value for the coordinates at which the alarm will be triggered. In the sketch, this parameter is called changelvl and has a range from 2 to 20, i.e. if you turn the potentiometer counterclockwise until it stops, it will be 2, and clockwise until it stops, respectively 20. The sensitivity is selected individually. For example, the alarm system works steadily for me (without false alarms) with changelvl equal to 4. You can find out the value of changelvl in the “port monitor” by rotating the potentiometer.

A few explanations to the sketch, which you can download at the end of the article.

defaultn = 2; // number of operation cycles - i.e. if during two cycles (two times in a row) there is a deviation of coordinates by the value selected by the potentiometer, an alarm is triggered - I do not recommend changing it.
delay (6000); // delay after power on - i.e. You have 6 sec. after turning on the alarm to close the seat and put the motorcycle motionless, after 6 seconds. Accelerometer polling will begin.
delay (3000); // siren time when triggered - i.e. the siren will scream for 3 seconds.

Small video:



Links for downloading as promised: a sketch and a library for working with an accelerometer.

PS Many thanks to MooM_IYD for their help in the project.

Source: https://habr.com/ru/post/252153/


All Articles