The 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.
After 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.
At 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.
To 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).
As 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.
The 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.
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)
In 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.
On 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.
This 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.http://www.digitalda...nick84/post=222