Jump to content


Photo
- - - - -

Developing a vehicle tracker with the Telit GM862-GPS module


  • Please log in to reply
2 replies to this topic

#1 BINREV SPYD3R

BINREV SPYD3R

    Live to Hack...Hack to Live.

  • Members
  • 2,297 posts

Posted 18 August 2007 - 09:18 AM

Posted ImageThe GM862-GPS is a hardware module with support for connecting to the GSM (mobile phone) network and receiving GPS position data. It also includes a Python interpreter, this combination makes it the perfect choice for building a tracker.

I purchased the GM862 Evaluation Kit (RS232 version) from SparkFun Electronics, at a cost of $309.60 (if you are in the UK import duty of around £25 may also be due, along with shipping). There are various other suppliers of GM862 based hardware, including Area SX s.r.l., Round Solutions (various development boards available), and Sequoia however unless you really know what you are doing, the cheapest / easiest solution will be to get the SparkFun Kit, which also includes the compatible evaluation / breakout board, antennas, power supply, and serial cable.

I found the SparkFun Electronics website / forums to be lacking any real information on how to actually get started developing on the module / with Python which was somewhat disappointing - I finally managed to piece together enough information to get started thanks to Google, the PDFs from Telit and information at Round Solutions and their forums.

Posted ImageAfter receiving the kit and putting it together (i.e. plugging in the module, antennas, SIM card, and serial cable) the first thing to do is test it is working. To do this check the DTR switch is set to "Low" i.e. program mode ("High" = Run Mode), power on the unit (hold the button for a few seconds until the green light starts flashing), open up a serial port communications program (e.g. HyperTerminal or Poderosa with Serial Port Plugin) and connect to it at 115200 bps, 8 data bits, no parity, 1 stop bits, no flow control. Issuing the command "AT" should result in the message "OK" being received. The device supports standard AT commands therefore it should be possible to e.g. connect a PC to the Internet via GPRS, establish a CSD call, send a fax, use certain PC based SMS application etc through it although I have not tested this.

The next thing to do is check the firmware version, use the command "AT+CMGR" if the result is anything less than 07.02.403, I would recommend download firmware version 07.02.403 and flashing the device. The process will take a good couple of minutes and I would advise not using the PC during this time, along with shutting down all non essential applications (flashing firmware in general can be risky and may result in an inoperable device if interrupted). Other firmware version may not work with the SMS software accompanying this article, also .403 provides extra functionality such as being able to read the GPS without disconnecting from an open socket connection.

There are two main choices available for writing Python code, either the provided Telit Python 1.5.2+ IDE, or your favourite text editor of choice. Personally I chose Edit Plus after adding in support for Python since I am already familiar with it.

When it comes to actually uploading / running / debugging code things get slightly more complicated.

Posted ImageAt first glance the IDE appears to be a deceptively preferable option. The IDE allows you to write code, then immediately run it and see the result in a debug window at the bottom of the screen. It also features a "Tools" menu with a number of utilities for various tasks such as uploading / downloading files from the module. In theory this is a good idea since it saves the time consuming process of uploading code to the module itself, and then waiting for it to compile – a process which may take several minutes for large applications (of 7000 bytes or more), along with debugging on the module. However the IDE appears to work partly by unreliable emulation (some features not supported by the emulator, other features supported by the emulator and not supported by the GM862), and partly by connecting to the real device over serial. I had issues getting this to work correctly (manual editing of the custom modules in "C:Program FilesPythonLib" appears to be necessary depending on the serial ports you use), and found that the IDE actually slowed down the development process (over running code directly on the GM862) since I was constantly dealing with issues caused by the imperfect IDE. Some things worth noting are that the IDE supports floats whereas using floats on the GM862 will result in an exception error being thrown, also even with the (importable) modules that are supported on the GM862 for advanced code you may get different results compared to when run on the PC based IDE). Along with the custom modules described in the manual, the only other built in modules available on the GM862 are imp, marshal, md5, and sys.

Posted ImageTo upload / run scripts on the module, the HyperTerminal "Send Text File" option can be used. For a description of the process see page 57-61 in the Telit "Easy Script in Python" guide (rather than rebooting the GM862 to run the script / turning the DTR switch to high, the command "AT#EXECSCR" can be used to run the previously enabled script). It is also possible to use the "Telit GM862 File Upload Utility" (see previous blog entry). However a much faster way is to use the RSterm application from Round Solutions (note if using RSterm the Python IDE is also required). Firmware version .403 appears to have a bug when trying to upload files larger than 7000 bytes, therefore you can either work around this by keeping files under that limit (by importing multiple files to make up your application), or use the "Telit GM862 File Upload Utility" which works around this issue by uploading large files in chunks, pausing in-between.

With RSterm you should choose "Open" on the initial screen, then switch to the "Telit Python" tab. This page allows you to view / upload / download files to / from the module. It also allows you to compile .py files to .pyo on the PC itself (after compiling use the "R" button to refresh the list), then just upload the resulting binary, enable it i.e. set it to run ("AT#ESCRIPT"), and run it ("AT#EXECSCR") this significantly speeds up development. You can not "Enable" a precompiled script, therefore if precompiling, you should "Enable" a non precompiled script which them imports the precompiled script (see SMS code for example). Even developing with RSterm is not perfect, I have had a number of crashes, however after using it you will learn how to avoid most of these. Mainly if you click a button, wait for a response or a timeout before clicking another, also sometimes there are focusing issues with the "ok" message box presented after a successful file upload – making the window width smaller means the message box can not be placed behind the main RSterm window bypassing the issue).

Posted ImageAs far as debugging goes, for simple scripts it is not really required, and you can usually get by however when you are developing complicated applications on an unfamiliar hardware platform, with a language / language version (Python 1.5.2) you do not have any previous experience with it is a must.

The standard GM862 (without GPS option) apparently just sends Python debugging output (and anything "printed") to the serial port which would be just fine on the GM862-GPS also, however this is no longer available since the inbuilt GPS support makes use of the hardware that previously provided this functionality).

There is also functionality called CMUX (which enables many virtual serial ports, including the debug output serial port, over a single physical serial port) however along with the IDE it also has issues. It requires a time consuming, complicated process that must be followed to the letter to get it to work (not ideal since you will be rebooting the GM862 frequently while developing), and frequently crashes, requiring a PC reboot, and that was before I even managed to get it working (which I still have not done).

Without purchasing additional hardware it is also possible to send messages back to the PC via the serial port used to program the device. To do this simply import the serial module "import SER", setup the speed to match RSterm / HyperTerminal e.g. "SER.set_speed(’115200′,’8N1′)", and send messages "SER.send(’Running’)", "SER.send(’Reached code block A’)". This will give you some level of debugging to track down issues with the code, however it is not true debugging so you do not see the actual error produced by the compiler - meaning you have to blindly guess what line the problem was on, and what the issue itself was which is not ideal.

Posted ImageThe only reliable solution I have found is to purchase the hardware based Round Solutions Python-Debugger however this will require an additional PC serial port, and a custom cable. One end of the cable will need to be soldered onto the evaluation board, and the other a 2×5 double row IDC connector (Maplin: JB59P) which then plugs into the debug board.

After setting up a suitable development environment the next thing to do is write the code. I chose to use SMS messages as a transport mechanism. The process works as follows: A mobile phone is used to send an SMS to the GM862. The GM862 checks for new messages every 10 seconds, on finding one it checks the password, and parses out the command, if it recognises a request for a position, it sends the position back to the sender of the message, then deletes the message. The logic is not too complicated, however the code itself is somewhat involved due to the complexities of parsing message data since there are no inbuilt modules for this. The format required for the position request is "mypassword pos" or "mypassword position" (depending on which is easier if you have predictive text turned on). After receiving the position you can either convert the degrees/minutes/seconds to decimal Latitude/Longitude manually or use the provided HTML/JavaScript page which links through to Google/Multimap for displaying the position.

Boxing up the tracker for use in a vehicle I used the following parts:

  • ABC Plastic Box H2851 (Maplin: H2851)
  • Car DC Power Supply (Maplin: A61FJ)
  • Red 12v current limited LED (Maplin: CJ63T)
  • 2-Core 3A Flat Cable Black (Maplin: XR47B)
  • Straign Relief Grommet 5R2 (Maplin: LR48C)
  • 5mm Black LED Holder (Maplin: N89AX)
  • Stick On Feet Square (Maplin: FD75S)
  • DC 2.1mm Plug (Maplin: HH60Q)
  • DC 2.1mm Socket (Maplin: JK11M)
  • 3A Term Block 3 Pk (Maplin: L96AR)

Posted ImageIn order to get the GM862 to automatically turn on when power is applied the on/off power button should be tied to ground. This is not the ideal solution since it compromises other features such as power saving however it is simple and works for this project. A better solution would be to design a circuit to ground the on/off switch for a few seconds only after power is first applied, e.g. using a capacitor etc.

The 9V car power supply adapter was set to 9V (be sure to use 9V since this particular adapter only provides regulation on 9V and under (setting it to 12V could result in 13+V being received by the evaluation board which may damage it). The adapter was also taken out of its case to fit in the project box. I chose to solder on a longer power cable to the cigarette lighter connector, and use some rubber stick on feet to keep the board from moving in the box, along with some stripboard to hold it in place, and separate the evaluation board from the power supply.

Posted ImageOn my second design (shown in pictures above) I chose to add two extra LEDs which were linked to two free GPIO pins on the GM862 (via a 47KOhm Resistor, and 2N222 transistor) to provide GSM (GPRS) / GPS connection status however these were used in a later code revision and are not required / used by the SMS code. Original project box shown to the left / below, initially the power supply was external to the unit.

Posted ImageThis article focused on using SMS text messages to transmit back position data on request. This is perfect for applications where it will have only occasional use, however if you are looking for a more advanced real time tracking / logging system with multiple units, requesting the position from each via SMS would quickly get tedious. A better solution is to use the GM862s socket / GPRS support to send back position data to a web server running e.g. a Google Maps based application every 1 minute or so when the vehicle is moving. It will depend on your provider however I found GPRS costs on the Orange UK PAYG network (£4 for £4MB with Orange World Multibundle Option) to work out significantly cheaper than 10p per SMS message). I may publish another entry describing the more involved processes for using GPRS at a later date.

I had been planning to write up this entry for a while, but in the mean time Alex at Tinkerlog beat me to it - all be it with a slightly different solution using an additional microcontroller which was not strictly necessary given the onboard Python interpreter.

Unless otherwise stated any mentions of GM862 in this article refer to the GM862-GPS.

[Download SMS Code]

http://www.digitalda...nick84/post=222

#2 PurpleJesus

PurpleJesus

    Dangerous free thinker

  • Members
  • 1,578 posts
  • Gender:Male
  • Location:800

Posted 18 August 2007 - 08:09 PM

That's cool... the antenna does it have to be open to the sky or will it pick up, if stuck under a car like in the movies?

#3 nick84

nick84

    Member

  • Agents of the Revolution
  • 1,680 posts
  • Gender:Male

Posted 19 August 2007 - 03:00 AM

In my experience the GPS antenna needs a relatively unobstructed view of the sky to work - however that is slightly odd since apparently the SiRFstarIII chipset (which it uses) is meant to be one of the better ones. Perhaps a different antenna would perform better, e.g. under a car.

According to wikipedia:

Reviewers have praised the SiRFstarIII chipset for its superior sensitivity and tracking capabilities.[1] GPS receivers based on this chipset have routinely performed better than receivers based on other chipsets.[2]






BinRev is hosted by the great people at Lunarpages!