Do-it-yourself online vehicle monitoring


    I always liked the idea of ​​monitoring something on the map online. And now I had the opportunity to do something similar.
    I want to share the process and result of development with the community.

    A little background
    The fact is that the guys from our project gathered for a motor rally in major cities of Russia, in connection with this I had an idea: it would be great if the site could always see the current location of the expedition.
    The search began on this topic, an analysis of existing solutions.
    I came to the following scheme: you need a device that after a certain period of time sends information about the current location via GPRS somewhere to the Internet, and later on our site will show on the map a line (track) from all points.

    Device selection
    The search began for suitable devices. The assortment is quite wide: starting with small personal trackers and ending with devices that are installed directly inside the car. Basically, all the devices are Chinese, but sometimes even domestic ones were met :)
    In the end, I settled on the Astron GT-102 model : compact, the cheapest, has all the necessary functions.
    imageimage
    I will say a few words about the purchase. I found a site where this model was sold for 3999 rubles, immediately called and tried to order.
    However, here I was in trouble: the seller said that they were not available, and the current batch was waiting for customs clearance at the border.
    As a result, I waited a whole week, calling every day, waiting for this very customs clearance.

    Meanwhile, I found the same model on the DealExtreme website , known to many , and at a price of $ 79.96 (~ 2400 rubles). I wanted to order, but I did not want to take risks, because the deadlines were running out, and the package could go a week, and it could go a month and a half (there was an experience of ordering in this store).
    The complete set and packing of goods in the Chinese online store and from our huckster entrepreneurs completely coincided :)
    By the way, a little about the complete set. She surprised me with pleasant snacks: a second battery, an additional back cover (with magnets, for attaching to the body), a protective case. The only thing missing was a car charger.

    So, the device lies on the table, bought a new SIM card with a special "Internet" tariff plan.

    Tracker setup
    There was a small booklet with instructions (even in Russian). The tracker, despite the presence of USB, is configured via SMS.
    The algorithm is simple: we send a message with a command and password from the phone and we get the result of the execution in response. And in response, you can only get a message of the form <команда> ok, <команда> erroror not get anything at all (which does not mean that the team did not apply).
    The tracker has two modes of reporting: either sends information via SMS to trusted numbers, or sends via GPRS. Moreover, the tracker initially sends data on a call to the SIM card that is inserted into it, but there is also the possibility of automatically sending data after a specified period of time.
    As a result, the settings for accessing the Internet via GPRS (apn, user, pass), the address and port of our server were driven.
    But how to understand what this mysterious device sends and in what format?

    Receiving the information

    When I started this idea, I spent a long time looking for any servers for these devices that receive signals from trackers and somehow display them.
    Nothing was found. No, of course there is one service that provides a vehicle web monitoring system for free, and you can add your tracker to it by pre-configuring it on their server, but this option did not suit me.
    Of course, in a pinch, one could write some parser of pages of this service that would save all the information in our database ... But still I wanted to try to raise my server.

    He opened the port, which he indicated in the settings on the server, and began to listen. After a long setup of the tracker, I managed to get him to send packets to our server.
    As I suspected, the tracker sent the information in the form of plain text.
    Example of a ping packet (sent by the tracker every 20 seconds):
    ##,imei:572776984948029,A;
    In general, IMEI is contained in each packet from the tracker, so it’s very convenient to filter connections: there is no IMEI - disconnect.

    By calling the tracker, I provoked the sending of the following information:
    imei:572776984948029,tracker,1007180132,+7926*******,F,173215.000,A,5453.2762,N,05850.6135,E,51.16,;
    An interesting line, is it not? But what is written in it and in what form?
    The device sent information to the server, which was already pleasing :)

    Next, the process of understanding what was in this line and in what format went.
    Naturally, the attached instructions did not say a word about this.
    There was some kind of instruction for the Chinese TK-102 (our device has many synonyms :), in which there was information of interest to me.

    Apparently, some abbreviation GPRMC is involved here. Google helped me find information on what it is .
    As a result, a line parsing function appeared, which pulls out coordinates, time and speed (by the way, I did not immediately understand that it is indicated in nodes).
    An example of a parsed line: A server has acquired connection filtering (via IMEI), logging messages from the tracker, discarding excess points and something else, but the main thing was to achieve the goal: the tracker sent coordinates every 20 seconds and they were saved to our server.
    raw: imei:572776984948029,tracker,1007180132,+7926*******,F,173215.000,A,5453.2762,N,05850.6135,E,51.16,;
    gps date raw: 17:32:15.0
    gps unix date: 17.07.2010 17:32
    degree: 54°53.2762'N 058°50.6135'E
    decimal: 54.887937 58.843558
    speed: 94.74832




    Information Display
    The most difficult part is passed, it remains to show the route to users.
    It was entrusted to Yandex.Maps to display points and connect them in lines. Their API is well documented, so I won’t give any code or comments, I’d better show a screenshot (clickable).

    The last 50 points on the map are highlighted by triangles that show the direction of movement, and by clicking information about the speed at this point and the fixation time.


    disadvantages
    The resulting system still has drawbacks, in my opinion it is exclusively hardware: the tracker after rebooting (changing the battery) “forgets” that it needs to send information to the server every N seconds, sometimes it hangs strangely (it is impossible to turn off without removing the batteries).
    Probably affected by the fact that this is the cheapest tracker that I found on sale in Moscow.

    What I forgot to mention
    - this tracker also has a monitoring function: you can call him and hear what is happening around the device;
    - The charge of one battery lasts about 20 hours;
    - in the process of use it consumes very little traffic;
    - in the process of searching for examples of implementing the display of tracks on the map, I found almost the only article in which the task is examined in some detail using the example of Google Maps;
    - the system came out very budget: 4000 rubles for the device + 300-400 for a new SIM card with the desired tariff;

    Also popular now: