GPS Tracker Arduino with your hands

After a few experiments with Arduino decided to make a simple and not very expensive GPS tracker with sending coordinates via GPRS to the server.
Uses Arduino Mega 2560 (Arduino Uno), SIM900 GSM/GPRS module (to send information to the server), a GPS receiver SKM53 GPS.

All purchased ebay.com in the amount of about 1500 R (about 500r of arduina, a little less — GSM module, a little bigger — GPS).

GPS receiver


GPS reciever

First you need to understand with working with GPS. The selected module is one of the cheapest and easiest. However, the manufacturer promises a battery to store data about the satellites. According to Datasheet, a cold start should take 36 seconds, however, in my conditions (10th floor from the window sill, flush against the buildings there) it took a whopping 20 minutes. Next start, however, is already 2 minutes.

An important parameter of devices connected to Arduino — energy consumption. If you overload the Converter Arduino, it can burn. For the receiver the maximum power consumption — 45mA @ 3.3 v. Why in the specifications to indicate the current strength on the voltage different from the required (5V), a mystery to me. However, 45 mA Converter Arduino survive.

Connect

GPS is not controlled, although it has a RX pin. Why — is unknown. Basically what you can do with this receiver to read the data in the NMEA Protocol from the TX pin. Levels — 5V for Arduino, speed — 9600 baud. Connect VIN to Arduino VCC, GND to GND, TX to RX of the corresponding serial. Read the data first manually, then using the TinyGPS library. Surprisingly, it read. After the transition to Uno had to use SoftwareSerial, and then the problems started — the lost part of the message characters. It is not very critical, as TinyGPS cuts off the invalid message, but it's pretty frustrating: o frequency of 1 Hz can be forgotten.

Small comment on SoftwareSerial: Uno no harderner ports (also connected to USB Serial), so you have to use the software. So, it can receive data only on the pin where the card supports interrupts. In the case of the Uno it is 2 and 3. Moreover, the data can simultaneously receive only one such port.

Here is the "test bench".

Test

GSM receiver/transmitter


GSM Shield

Now begins the more interesting part. GSM module — SIM900. It supports GSM and GPRS. Neither EDGE nor 3G are not supported. To transmit information about the coordinates it is probably good — no delays or problems when switching between modes, plus the GPRS is almost everywhere now. However, for more complex applications this may not be enough.

Connect

The module is also controlled via the serial port, with the same level of — 5V. And we will need RX and TX. Module — shield, that is, it is installed on Arduino. And is compatible with both the mega and uno. The default baud rate is 115200.

Collect at Mega, and here we are waiting for the first nasty surprise: the TX pin of the module gets to the 7th pin of the mega. On the 7th Pina Megi unavailable interrupts, and therefore will have to connect the 7th pin of, say, 6m, for which interruption is possible. Thus, spend one Arduino pin for nothing. Well, mega is not very scary — all the same pins missing. But for Uno it's more difficult (remember, there are only 2 pins that support interrupts 2 and 3). As a solution to this problem, you can not offer to install the module on Arduino, and connect it to the wires. Then you can use Serial1.

After the connection is trying to "talk" with the module (don't forget to turn it on). Select port speed — 115200, while well, if all the built-in serial ports (4 on the mega, 1 uno), and all software operate at the same speed. So you can achieve a stable transmission performance. I don't know why though I guess.
So, write primitive code for forwarding data between the serial ports, send the atz, in response to the silence. What is it? A, case sensitive. ATZ received OK. Cheers, the module can hear us. And not to call us for fun? ATD +7499... Calling landline phone from Arduino there is smoke, the laptop dies. Burned Converter Arduino. It was a bad idea to feed its 19 volts, although it is written that it can work from 6 to 20V, recommended 7-12V. Measurements in the GSM module does not say anywhere about power consumption under load. Well, Mega is sent to the warehouse of spare parts. With a sinking heart, include the laptop, has received +19V +5V line from USB. Working and even USB is not fading. Thank you Lenovo for protection.

Burnt transformer

After burnout of the Converter I looked up the current consumption. So, peak 2A, typical — 0.5 A. This is clearly beyond the power of the transmitter Arduino. You need a separate power supply.

Programming

The module provides a broad opportunity of data transmission. From voice calls and SMS and ending with the actual GPRS. And for the latter it is possible to perform the HTTP request using AT commands. Have to send a few, but it's worth it: to form the request manually is not very desirable. There are a couple of nuances with the opening of the data transmission channel GPRS — remember the classic AT+CGDCONT=1,"IP","apn"? So, there is the same need, but slightly trickier.

For obtaining a page at a specific URL, you need to send the following commands:
the
AT+SAPBR=1,1 //Open carrier (Carrier)
AT+SAPBR=3,1,"CONTYPE","GPRS", connection type - GPRS
AT+SAPBR=3,1,"APN","internet" //APN for t - mobile internet
AT+HTTPINIT //Initialize HTTP 
AT+HTTPPARA="CID",1 //Carrier ID to use.
AT+HTTPPARA="URL","http://www.example.com/GpsTracking/record.php?Lat=%ld&Lng=%ld" //the Actual URL, after the sprintf with coordinates
AT+HTTPACTION=0 //Request data with GET method
//wait for a response
AT+HTTPTERM //to stop HTTP


As a result, when connected, will receive a response from the server. That is, in fact, we are now able to send coordinate data, if the server accepts them for GET.

Power

As to feed the GSM module from the transducer Arduino, as I found out, a bad idea, it was decided to purchase a Converter 12v->5v, 3A, on the same ebay. However, the module does not like the food at 5V. Go to hack: connect 5V to the pin, which comes with 5V from Arduino. Then the built-in Converter module (significantly more powerful transducer Arduino, MIC 29302WU) will make 5V that is needed by the module.

Server


The server wrote primitive — storage of coordinates and drawing on Yandex.maps. In the future, it is possible to add different features, including support for many users, the status "guard/not guard", the state of the car (ignition, lights, etc.), maybe even control systems of the vehicle. Of course, with appropriate support for the tracker, gradually turning into a full-fledged alarm.

Field tests


Here is the assembled device, without housing:

Assembled device

After installation of the power Converter and placing in the body of a dead DSL modem the system looks like this:
housing

Soldered the wires, I removed a few contacts from pad Arduino. Look like this:
image

Hooked up the 12V in the car, drove to Moscow, got track:
Track
Track point far enough away from each other. The reason is that sending data over a GPRS connection takes a relatively long time and at this time the coordinates are read. This is a clear programming error. Treated first, sending from packs of coordinates over time, and secondly, an asynchronous operation with GPRS module.

Time to first fix in the passenger seat of the car — a couple of minutes.

Conclusions


Create a GPS tracker on Board, with their hands possible, although it is not a trivial task. The big question now is how to hide the device in the car so that it is not exposed to harmful factors (water, temperature), it was not closed by the metal (GPS and GPRS will be escaped), and was not particularly noticeable. While just lying in the cabin and plugs into the cigarette lighter socket.

Well, still need to fix code for a smooth track, although the major task tracker and so fulfilling.

devices Used


the
    the
  • Arduino Mega 2560 [compatible]
  • the
  • Arduino Uno [compatible]
  • the
  • GPS SkyLab SKM53
  • the
  • SIM900 based GSM/GPRS Shield
  • the
  • DC 12v- > 5v 3A converter


Literature


    the
  1. Of. the Arduino website (contains details about the boards and their programming)
  2. the
  3. TinyGPS (download link in the middle of the page)
  4. the
  5. GPS SKM53 Datasheet
  6. the
  7. Description GSM/GPRS Shield SIM900
  8. the
  9. SIM900 AT Commands
  10. the
  11. the Documentation of Yandex.Cards


Code


Published code can be used in any lawful purpose by any person. The code quality is terrible, because it is still a test version. When it's finished to something more beautiful update.

To compile the code to Arduino you need to import the tinygps library.

code
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

ODBC Firebird, Postgresql, executing queries in Powershell

garage48 for the first time in Kiev!

The Ministry of communications wants to ban phones without GLONASS