Perancangan Alat Sistem Keamanan Rumah Berbasis SMS Gateway Menggunakan Mikrokontroller Arduino Uno
BAB I
PENDAHULUAN
1.1 Latar Belakang Masalah
Seiring dengan perkembangan zaman dan teknologi kebutuhan informasi yang cepat sangat di butuhkan dalam berbagai sektor kehidupan, sehingga menunjang kinerja sektor-sektor tersebut, salah satunya adalah aspek keamanan. Aspek keamanan sangat di butuhkan dalam berbagai sektor kehidupan saat ini, faktor privasi juga turut mempengaruhi akan pentingnya…
La gente de Circuits Digests presenta como siempre un excelente y súper detallado artículo. Vemos cómo lograr que un Arduino Uno pueda controlar luces y cualquier artefacto del hogar a través de órdenes recibidas por mensajes SMS con un módulo SIM900.
In our previous post we used UART signals to connect to Sim900. We also tried to make a call and send a text message.
So far, we didn't consider too much responses to commands which are sent to the module. Today we're going to explore them in detail.
As an example, we'll study getting the module's status. Also, we'll try to get incoming calls and text messages.
Let's start from getting messages from the module. Earlier we used sleep function, as we didn't know for sure when exactly the data is ready to be read. Let's use pool function, so that the thread wakes up once the data is available for reading.
We don't have to wait long as we get a response once the command is processed. By default, the module sends echo of the received command. So this should be taken into account when reading the response.
Echo is followed by newline and status of the command execution - ОК or ERROR. You can disable getting echo of your command by “ATE0” command. The response will be of “+:“ format.
Here are some examples:
Getting info about operator:“AT+COPS?”
We get the response:
+COPS: 0,0,”AT&T”
The response is 0,0,”AT&T”
The first parameter indicates that GSM network was chosen automatically. The third parameter stays for the operator name.
Here's how this command can be sent in Swift:
let cmd = "AT+COPS?\r\n" write(sim900descriptor, cmd, UInt(countElements(cmd)))
Sending all the subsequent commands in this article is similar to this one.
You can see what other commands return:
AT+CSPN? - SIM card's operator
AT+CSQ - signal strength
AT+CBC - voltage, battery level
AT+COPS=? - available operators in the coverage area
In our previous post we learned how to make an outgoing call. When receiving an incoming call, we get “RING” string at certain intervals. We can response to the call by “ATA” command or reject the call by “ATH” command.
In order not to get incoming calls at all, reject them by AT+GSMBUSY=1 command.
AT+CLCC command is needed to get the call's status. Here are the command parameters:
+CLCC: ,,,,
To get the telephone number of the caller, execute AT+CLIP=1. The answering machine will send
RING together with the telephone number:
+CLIP:,...
If you get +CPIN: SIM PIN, it means that working with a SIM card is possible after entering the PIN code via AT+CPIN= command.
OK, so now we know how to get and reject incoming calls and get the status of the call.
In our previous post we learned how to send a text message. Incoming messages are received in +CMTI: "SM", format.
stays for the number assigned to the saved message
We'll use this number to get the contents of the message via AT+CMGR command:
AT+CMGR=,
Now we get the response to CMGR command:
+CMGR: "REC UNREAD","+496967733496","","14/10/24,16:14:17+12"
Message from phone
Clean out your text messages periodically to free space, otherwise you won't be able to send or get a new message. To delete text messages from all folders, execute at+cmgd=1,4
To view all messages, execute AT+CMGL.
So, these are the basic functions of GSM phone based on Sim900 radio module. Here's a code sample in Swift we've prepared for you. Sim900.swift contains more methods to use in your work.
Hi there. Today we are going to get a closer look at Sim900 radio module which we mentioned in our last post.
So here we are with a board with Sim900 radio module, where the main contacts have already been withdrawn into the contact area for SIM card. Also, serial interface connections, as well as outlets for microphone and linear output, are available.
To make sure that the drivers are installed, type in the Terminal:
ls /dev/tty.*
Next we have to find our device. Here's what our device looks like:
/dev/tty.PL2303-00001014
Connect contacts. Rx/Tx voltage of UART signals is 3.3V, which permits to connect contacts to the board directly. 5V power supply is provided by UART as well. Thus, we are using all the UART contacts: Rx/Tx, +5V and GND.
Sim900 module by default requires 115200 bit/s connection speed, 8 bits per symbol and 1 stop bit. All other options should be disabled.
UART is rather simple serial interface, even simpler than Serial Com port, but we can use the same components for work with it, limited only by the data exchange on the specified transfer speed.
OS X lets us work with serial port via tеrmios, which is the part of POSIX. All we have to do is tune port settings and try to transfer data.
For data exchange we'll use Swift programming language. Here's how setting port options looks like:
func openWithDevicePath(devicePath:String, error:NSErrorPointer?) -> Bool { let d : Int32 = open(devicePath, O_RDWR | O_NOCTTY | O_NDELAY) if d == -1 { if let err = error { err.memory = NSError(domain: "could not open device", code: -1, userInfo: nil) } return false } var tty = UnsafeMutablePointer.alloc(1) if tcgetattr(d, tty) != 0 { close(d) if let err = error { err.memory = NSError(domain: "tcgetattr failed", code: -1, userInfo: nil) } return false } if cfsetospeed (tty, 115200) == -1 { close(d) if let err = error { err.memory = NSError(domain: "cfsetospeed failed", code: -1, userInfo: nil) } return false } if cfsetispeed (tty, 115200) == -1 { close(d) if let err = error { err.memory = NSError(domain: "cfsetispeed failed", code: -1, userInfo: nil) } return false } tty.memory.c_cflag = (tty.memory.c_cflag & ~UInt(CSIZE)) | UInt(CS8); // 8-bit chars tty.memory.c_iflag = ~UInt(IGNBRK) // ignore break processing tty.memory.c_lflag = 0 // no signaling chars, no echo, tty.memory.c_oflag = 0 // no remapping, no delays tty.memory.c_iflag &= ~(UInt(IXON) | UInt(IXOFF) | UInt(IXANY)) // shut off xon/xoff ctrl tty.memory.c_cflag |= (UInt(CLOCAL) | UInt(CREAD)) // ignore modem controls, tty.memory.c_cflag &= ~(UInt(PARENB) | UInt(PARODD)) // shut off parity tty.memory.c_cflag |= 0 tty.memory.c_cflag &= ~UInt(CSTOPB) // One stop bit tty.memory.c_cflag &= ~((UInt(CCTS_OFLOW) | UInt(CRTS_IFLOW))) // Disable RTS/CTS if tcsetattr (d, TCSANOW, tty) != 0 { close(d) if let err = error { err.memory = NSError(domain: "cfsetispeed failed", code: -1, userInfo: nil) } return false } sim900descriptor = d return true }
The function should be always called before starting work with Sim900. The data is sent and received via read and write functions, that's why the command execution will be realized via timer. Receiving data from the device is similar to the work of Terminal. In the next posts we'll give a closer examination of Pooling mode, where the data is received.
So let's execute a simple command to test connection to the module - “AT”.
main function in Swift looks like:
var error : NSError? let sim900descriptor = sim900DescriptorWithDevicePath("/dev/tty.PL2303-00001014", &error) if sim900descriptor == -1 { if let e = error { println("Error: \(e.localizedDescription)") } exit(1) } let cmd = "AT\r\n" write(sim900descriptor, cmd, UInt(countElements(cmd))) sleep(2) var buffer = UnsafeMutablePointer.alloc(Int(128)) memset(buffer, 0, 128) let bitesReaded = read(sim900descriptor, buffer, 127) if let response = String.fromCString(buffer) { println("Response: \(response)") }
Data is transferred via write call, as you've probably noticed.
If OK is returned, data transfer settings are correct.
Here's a sample which allows sending an SMS message and making an outgoing call. Let's describe two simple commands.
We are going to dial a telephone number, so we need to pass a command in “ATD;” format, which has the following look:
Making a call is that easy. Sending an SMS message is a little harder and may remind you sending POST request to the Internet. Once the command is received, the module will wait for the body of the letter and 1A symbol.
To do this, we'll use command of “AT+CMGS=” format. Once it is sent, send the body of the message with 0x1A symbol in the end, in case the module didn't return an error.
Eltima team is starting the series of articles about using embedded devices with computers running OS X. Quite often we need to connect to devices remotely. Sometimes we need to send or get data, or to manage the device which is located far away and does not have Internet access.
To avoid inventing a new connection system, one can use already existing mobile coverage. We set our eyes on SIM900 - wireless GSM module, which is quite known on the market today.
The pros are primarily its affordable price (it costs something about USD 10.00) and simple usability. The radio module uses 5V input voltage and features low power consumption. It is stable in work and has operation temperature from -30°C to +85 °C. It is very compact in size (chip-size) and complies to CE, FCC, ROHS, PTCRB, GCF, AT&T and ICASA Certifications.
To get more info on SIM900, go to the manufacturer's website:
http://wm.sim.com/defaulten.aspx
The module uses UART (universal asynchronous receiver/transmitter) for data transmission, therefore it can be easily integrated into any platform via standard serial interface. POSIX library on OS X, as well as on other UNIX systems, lets us use serial ports.
Once serial connection is established, interaction is ensured via AT commands, which we'll study in detail in upcoming articles.
By sending AT commands to the module, one is able to:
make outgoing calls and get incoming calls;
get and send messages;
create TCP connection or send HTTP requests to Internet via GPRS;
send and get DTMF signals;
use sound input/output for work with calls.
Note that there is various supplemented firmware which can expand the functional with additional features, like work with MMS, SMTP/POP3, PING, geolocation, etc..
So how can Sim900 be implemented? There are several variants:
Alarm systems where events are sent via SMS messages or voice call. AT command should be sent in due time to make a call or send a text message to an end-user.
Remote device management. Managing DTMF signals of the incoming call are received and transferred to the computer attached to the module.
Radio module usage is not limited to PC connection. One can connect it via UART to Atmel tiny microcontrollers, which, by the way, can be connected to the module via serial interface as well. In this case, in rather small form factor (2,5 х 2,5 cm).
It's rather hard to find appropriate software to work with Sim900, since the functional should be specifically designed for integration into the definite infrastructure. Besides, advanced versions of Sim900 may differ. However, interaction via the serial interface can be carried out by terminal programs for modem management.
In our next articles, we'll highlight the peculiarities of Sim900 integration in order to implement connection to remote devices. Stay tuned!
<p>New Post has been published on http://tablokar.ir/sim908library/</p><blockquote><p><strong>شماتیک ماژول sim908 برای Proteus</strong></p><p><img src='http://tablokar.ir/Uploads/uploads/2014/09/sim900-library-www.tablokar.ir_.jpg'/></p><p>ماژول سیم 908 یکی از بهترین ماژولهای موحود در بازار برای استفاده از تکنولوژی موبایل توی پروژه های الکترونیکی هست . با استفاده از این ماژول می شه از انواع سیم کارتهای موجود در بازار توی پروژه ها استفاده راه ارتباطی بین این ماژول ها و میکرو کنترلر های دیگه پروتکل Uart یا همون سریاله . برای این ا ...</p></blockquote>
New Post has been published on http://tablokar.ir/sim908library/
Хочу получить ответ от SIM900. Весь входящий поток идет в кольцевой буфер через прерывание.
Процедурка "выгребает" строку. Начинается поиск строки с текущего указателя на чтение буфера. После выполнения процедуры указатель на чтение будет на сл. элементе буфера после строки. Т.е. мы "съедим" и лидирующие символы \r\n и завершающие \r\n.