how to make an alarm system with arduino - new car alarm system

by:Kingcobra     2019-11-09
how to make an alarm system with arduino  -  new car alarm system
With Arduino, especially through the Internet, you can achieve complex projects with a variety of Shieldscontroller.
In this article, we will learn how to make a professional alarm system using Arduino.
This system will be able to record every move detected at home and will be saved in the database, using a simple browser to remotely access the database, or a dedicated application, from any device.
Project software 1x Arduino Mega 1 x Ethernet shield n x Arduino Uno n x Wireless 433 MHz kit n 1 x PIR sensor PC/raspberry software MySQL Connector requirements arduino wireless 433 MHz from my gitub in the repo alarm system, my code is based on the use of some kind of central station that connects to n clients.
Each device is equipped with a PIR sensor that is able to detect a human channel by detecting heat changes.
All kinds of clients have a wireless TX that sends a signal to the central station warning that a person is detected.
The main server is just an Arduino Mega that is officially connected to the Internet through the Ethernet card, which contains PIR sensors, wireless RX, and can receive signals sent by the client.
In order to figure out which client sent the signal, it will be equipped with some kind of identifier, set by the user when registering the client.
As for the recording/saving of the readings, you will use a database that can be installed on a PC or even on a Raspberry Pi.
Uploading will be done directly from the central station, which is the only central station connected to the Internet.
Retrieve information related to the survey, which you can retrieve via a web page or an application built into Java.
In addition, the central station is equipped with a web server that you can use to disable/enable the alarm system.
We will learn how to automate the activation/disabling of alarm systems using Android phones.
The first step in using the alarm system is to install the MySQL server on the PC.
You should specify that the computer must maintain Arduino access so that you can complete the correct storage of the detection.
To do this, install the DB board on the Raspberry Pi, thus greatly reducing the power consumption.
Windows/Mac/Linux, you can install the server and download the package from the MySQL official website.
In order to complete the subsequent steps of the project, such as creating login credentials, and so on, you must install the workbench.
The latter is a program that makes it easy for you to interface with your MySQL server.
Workbench, you can download it from this web page. To install a MySQL server on a Raspberry Pi, you must type: sudo apt-in the terminal-
Install mysql-
Server for installing client Workbench: sudo apt-
Install mysql-
During the server installation, you are prompted to enter your username and password for accessing the database server through the workbench.
By default, the server is set to access the connection on the machine, that is, the local host mode.
To be able to perform insert or select remotely, also create a new account that can even be opened outside of the device.
To do this, open the Workbench menu Raspberry Pi.
Select new server instance and next page, select local host and type the login credentials I created when I installed the MySQL server.
Now that you have created a connection to the database, we can create a user who can even remotely access the Raspberry Pi.
To do this, we double
Click on the connection you created and it will open a new page where we will see some statistics about server usage.
We select by clicking user and permissions and create a new account.
It must be noted that in "from host" it will be % in order to allow all types of incoming connections.
Now that we have the MySQL server installed and set up access credentials for accessing the database from any device, we can create our "scheme" for the alert system ".
This plan is nothing more than a series of relationships that make up our project.
Attributes are included in each report.
In our example, the pattern is as follows:
IdDispositivi, Luogo, Heart King)
Relazione2 Rilevamenti (ID,DATA,ORA)
In the first "table", all the devices that exist in our alarm system are collected.
For example, we can install Arduino Uno with PIR sensors in the living room, while another Arduino Uno can be installed in the bedroom.
In the second "table", various surveys, including dates and times, were recorded.
ID is used to identify various devices in the home.
In order to create various "tables", simply open the connection to the MySQL Workbench through "MySQL connection.
The data contained is the data created in the previous step, such as the user name and password.
IP can also leave the local host (127. 0. 0. 1).
Then it opens a page where we can control the database.
The thing to do is to select "create new mode" at the top and give the name of sistem _ allarme.
After creating the schema, we can create the "table" as our relationship ".
To do this, select sister _ allarme in the lower right corner and select create table ".
The next steps are used to enter the data that has been previously reported.
The only item to be added in this regard is to insert idDispositivi as the primary key of the relational/table device.
In this way, there will be no two devices with the same identifier.
As mentioned earlier, on the basis of the project, there are two types of devices, a server/Central station consisting of Arduino Mega, which allows you to upload data to the database using an Internet connection, while the client is composed of Arduino Uno and is able to send detected motion to the server using PIR sensors and wireless components.
Server/Central station PIRVCC-> 5V OUT -> PIN 4 GND -
> Gnd rx wireless 433 MHz GND-> GND DATA -> PIN 11 DATA-> None VCC -
> 5 v ClientRIP VCC-> 5V OUT -> PIN 3 GND -
> GND wireless 433 MHz tx atad-> PIN 11 VCC -> 5-12 V (
Increase the signal Port, increase the voltage)GND -
> GNDAs has previously reported that in order to compile the code successfully, I realize that you need to download libraries that do not exist by default in the IDE Arduino.
The installation is really simple, you just need to download the file.
Compress, decompress, and move them into the Arduino/library on your computer.
The following is the program code of the alarm system version 1.
0 server you can find the Arduino code of the server here/* This code should be installed for every client who wants to detect motion through the sensor PIR.
If the motion is detected by PIR, the client will send a message to Master wirelessly and Master will insert MySQL DBVersion 1.
Copyright of month author Jacomo Bellazzi (C)
2014 Giacomo Bellazzi (
** This program is free software: you can redistribute and/or modify it under the terms of the GNU General Public License issued by the Free Software Foundation, version 3 or * of the license *(at your option)
Any higher version.
* This program is distributed in the hope that it will be useful, * but there is no guarantee;
There is even no implied guarantee of * Marketable or suitable for a particular purpose.
For more details, see * GNU General Public License.
*/Include the baud rate = 800 including const int; int pinPIR = 3; int led = 13;
Int timeLed = 800; int pinTX = 12; int ID = 2;
/Clientvoid settings for this ID (){Serial. begin(9600);
/Debug serial only. println("setup");
SetupRFDataTxnLink (PinTX); }void loop(){if(motionDetected()){
float outArray[1];
/This array reserves the data of sending the output array [0]= ID;
/Send the ID of the client joint RFData outDataSeq;
EncodeRFData(
OutArray, outDataSeq);
TransmitRFData(outDataSeq); ledOnOff(led,timeLed); while(motionDetected()){
/Keep this state and do not send two movements}}}
/This method detects the existence of people Boolean motion (){if(digitalRead(pinPIR)){return true; }else{return false; }}
/This method is time void ledOnOff (
Int led, int timeLed){digitalWrite(led,HIGH); delay(timeLed); digitalWrite(led,LOW); }
From the mechanism of motion detection, this code is completely understandable.
If the client detects a conversion, it sends a value that identifies the server, and the server knows when and where to send an insert in the database and where it has moved.
As for the traditional alarm system, this can also be deactivated. for example, it is normal for us to move at home!
To do this, it makes a web server inside the train station from which you can manage the system.
Enter the IP address of the server, which will open the web page protected by the user name and password.
In the case of this code, the credentials are: user = admin password = adminThe encoding used is base 64 and has been implemented using excellent library webcleaner, using Arduino can simplify the process of creating web pages.
To change the credentials to access the protected page of the alarm system, you can modify the code and replace the string = ywrtaw46 ywrtaw4 with the desired one.
To create its string, you can use the online tool, for example.
For example, if you want to create the following credentials;
User = nomeuttepassword = enter the password in "encoding" nomeutente: password e and the result will be bm9tzxv0zw50ztpw
In the protected page of the web server, you can enable and disable the alarm system by pressing the center button, which will change the color depending on the status.
It should be noted that by default, when you start the Arduino, the system is active even if the system was previously disabled.
This is because Arduino is the memory of variable static variables and then the device is restarted and data is lost.
However, it is available in the program repo that solves this problem, and it stays in the selected state even after restarting the Arduino.
However, there is a small problem with the memory that holds the data, but there is a "life" at the bottom of the Arduino RAM you call EPROM ".
Therefore, excessive use of writing can harm writing.
Therefore, I recommend the use of standard procedures.
Alternatively, you can disable the system via the switch, however, this will ensure lower security as anyone can turn the system off.
However, in future releases, I will introduce the ability to enable manual systems through a secure web page.
The easiest way to retrieve data is to perform a query on the database we have installed.
The query is nothing more than a query that returns tuples, and tuples are nothing more than our observations.
To do this, we type this query in the Workbench: select DI. Luogo,DI. Citta, RI . DATA, RI.
Stories from sisters
When RI joined sister _ allarme, Rilevamenti.
2 of Dispositivi (RI. ID = DI. idDispositivi)
To access this detection list from your smartphone, you can install a workbench on your device and enter the previous query.
How to activate/deactivate the automatic system?
Since programs available for Android Llam can be downloaded from this link, the system provides the ability to automatically activate/deactivate the alarm system. kebab. Llama .
This requirement is due to the fact that when we are in the room, the alarm system loses its function. if the system is active, the alarm system will be detected in the room, there will be many unnecessary measurement records.
To automate the system, we can decide to turn it on when the GPS location is away from home or turn it off when we enter the house.
To set what is said, you need to open the application LLama and go to the event you added. The function to activate is: in the area-short run app -preferred ()
I leave this area. short run app -preferred ()
In addition to logging/viewing various surveys using the workbench, the Java application for the Pc can also use the Java application I made.
The first program to do is enter the username and password of the MySQL server.
Through the menu, you can select two actions that allow clients to be registered in the area and to view the survey, filtering by ID, date, and time.
If you want to turn the alert on/off with Android, you can download the app from the Play store by typing AlarmON, or by downloading the app through the link after the download, you must set the username, password, and the IP of the Arduino from the preferences.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...