Some weeks ago I met Thilo and he showed me twibble, his GPS enabled twitter client for the N95. Nice little and smart application. It sends messages with geo positions to twitter. The postion can then be tracked and viewed within Google Maps.
I was impressed and decided immediately to try to post the same messages with my mobile tracker and use the same, twitter, twibble and GM, to track my positions.
Using Builtin Python instead of the AVR controller
Actually I switched to use the builtin Python interpreter as some on the comments already suggested. So the external microcontroller is superfluous. That should make the setup smaller, cheaper and easier. By now I don’t have a new board, I just bypass the controller. Communication is done via serial port directly connected to the Telit module.
How to develop in Python for the GM862
To develop python scripts you need to download the python package from roundsolution’s techdocs page. Next write a “hello world” script and upload it with your favorite terminal application. Note, that using print statements for debugging will not work as expected. You have to redirect stdout to the serial port to be able to see them in your terminal. Joe pointet out that solution.
According to the documentation, it should be possible to get seperate output for debugging, stdout, etc. but I didn’t manage to get that up and running so I was stuck in trail and error. After uploading the script and starting the execution, the module takes some time to compile the python code. If it fails, it fails silently, what is a bit nasty. Nick has a nice writeup of how to develop with python for the GM862 in his blog. Developing and debugging turned out to be not that easy but it works.
Posting twibbled tweets
To piggybacking on twitter and twibble, I created a twitter account. I wrote a test script that uses HTTP over GPRS to post messages to twitter. As posting to twitter is secured with HTTP basic authentication, I hard wired my script to post my auth value. curl is very handy to test HTTP communication on the command line of your PC. Using the -v switch shows the encoded auth value, that you need.
Next I fetched the position from the GPS and formatted the message accordingly. To enable twibble to grab the position, it must be formatted like this: “<message> L:<lat>,<lon>:”.
The script now just fetches the position and posts it to twitter every two minutes. This can be improved by posting the position only if the module was moved.
Tracking
Now I can use Google Maps to fetch a kml file, which is generated by the twibble service out of my twitter messages. With the new feature to embed Google Maps without an API key, it’s even easier.
Links and downloads
- twibble, a location aware twitter client for smartphones
- source: tracker-python-001.zip



22 responses so far ↓
1 A home made twibble device :: DAS ZENTRALORGAN // Sep 23, 2007 at 13:46
[...] can track the position of Alex’ device via the twibble API. Just open this link. Check out Alex’ blog how it works. Alex, this is really awesome! Tags:GPS, mobile, N95, twibble, [...]
2 Orb // Jan 8, 2008 at 05:49
Ditto on the great project.
A question about your one subroutine though :
def sendTwit(message):
why does “MDM.send(’AT#SKTD…” get sent in every loop. I thought the whole idea of having a socket was that it would remain open - and you just “pump” data down the line to the open port.
Is there a way to say “if socket not open… then open it”
Then send data to the port.
I’m a fashinable newbie, so am asking this to learn… not criticise!
Cheers
3 Alex // Jan 8, 2008 at 09:13
Hi Orb,
it depends on the delay between the messages you want to send. If it is fast enough, you can leave the socket open. Otherwise you will hit the timeout and you have to reopen the socket.
On the other hand, you could modify the settings for the socket timeout.
I haven’t tried that many different settings after I found one that works. It is a bit hard to debug python on the module.
Cheers,
Alex
4 Harald Naumann // Jan 15, 2008 at 08:14
Hi Alex,
Please be so kind and come back to me, because I would like to help you with details on latest Python based GSM/GPS modules listed here:
http://www.roundsolutions.com/aarlogic/index.htm
Maybe you can a few smaller GPS related jobs for me, if you are interested in.
Regards
Harald
5 Diana // Feb 16, 2008 at 05:50
Hello Alex!!!!!!!
I love your site, and I think that you are very smart.
Please, this girl needs yor help. Can you please tell me how to programm in python for the GM8862-GPS?? I want that the module send every 5 minutes or an hour a SMS to a cell phone with the information of the GPS position.
Pleaseeeee baby!!! yes???? Know I have the module and just need your, very important to me, help!
6 Alex // Feb 16, 2008 at 10:38
Hi Diana,
check out this link http://www.desantix.it/index.php?page=show_articles&cmd=show_article&id=214&cookie=1
They use python on the GM862 to send SMSs with GPS positions.
Cheers,
Alex
7 Diana // Feb 16, 2008 at 21:54
Thank you for your fast answer!!! Im studying the code, thanks a lot!!!
I m studying your python code too because I want to do the same you did. I hope I don’t bother you with my questions
Im trying to understand the twibbled tweets stuff so in a futute i will make quiestions
hehehe
Well first of all: Can I use a wall adapter switcher power supply of 9V to the EVK V3 for the GM8862-GPS of sparkfun??
Really thank you so much!!!!!! Please tell me if I bother you!!
8 Anton Hernández // Feb 20, 2008 at 11:31
Dear Alex,
Congratulations for your great web
I’m testing GM862 module for TCP UDP data communications.
I can send data to any IP using communication port 80 (or any other) using HyperTerminal and it works perfectly.
When I try to do the same using Python the GM862 opens the connection with the remote IP machine but the data send by the command MDM.send(’test\r\n’,0) never arrives.
I had used an sniffer and test it in different machines and different IP and the result is always the same:
HyperTerminal works perfect but Python only connect but do not send any data.
I show you the easy python code that is able to make the connection but not to send the data:
import SER
import MOD
import GPS
import MDM
SER.set_speed(’115200′,’8N1′)
MOD.sleep(30)
MDM.send(’AT\r’,0)
MDM.send(’AT+CPIN=6969\r’,0)
res=MDM.receive(10)
SER.send(res)
MDM.send(’AT&k0\r’,0)
res=MDM.receive(10)
SER.send(res)
MOD.sleep(30)
MDM.send(’AT+CGDCONT=1,”IP”,”movistar.es”,”0.0.0.0″,0,0\r’,10)
res=MDM.receive(50)
SER.send(res)
MOD.sleep(10)
MDM.send(’AT#USERID=”movistar”\r’,10)
MOD.sleep(10)
MDM.send(’AT#PASSW=”movistar”\r’,10)
MOD.sleep(10)
MDM.send(’AT#PKTSZ=300\r’,10)
MOD.sleep(10)
MDM.send(’AT#DSTO=50\r’,10)
MOD.sleep(10)
MDM.send(’AT#SKTTO=90\r’,10)
MOD.sleep(10)
MDM.send(’AT#SKTCT=600\r’,10)
MOD.sleep(30)
MDM.send(’AT#GPRS=1\r’,150)
res=MDM.receive(150)
SER.send(res)
MOD.sleep(30)
MDM.send(’AT#GPRS=1\r’,150)
res=MDM.receive(150)
SER.send(res)
MOD.sleep(100)
MDM.send(’AT#SKTD=0,80,”213.060.170.198″,0,0\r’,0)
res=MDM.receive(50)
SER.send(res)
MOD.sleep(60)
MDM.send(’test\r\n’,0) #instruction that never arrives
SER.send(’Program end’)
Please can you help me in order to do not stack the project in this simple steep.
Looking forward to hearing from you
9 Alex // Feb 21, 2008 at 08:42
Hi Anton,
hmm, hard to say.
I assume you have checked the returned output of all AT commands and all commands succeeded.
Maybe try to do a sleep after sending the test string. And you could read the output after you send the test string. Maybe an error occured.
Another try could be to skip the sleep(60).
HTH, I’m just looking for things that I would try.
Cheers,
Alex
10 Medina // Mar 9, 2008 at 03:07
Do you know how to adapt a battery and a battery charger to the Telit GM862-GPS module?
I’m designing a small pcb to simply plug the module once programed. In that mode you can have a small tracker.
When I finish the design, if you want I can give you a copy of the pcb.
11 Alex // Mar 9, 2008 at 10:44
Hi Medina,
I am sorry, I haven’t looked into battery charging. But have a look at the Aarlogic modules, they have a battery charge on board.
http://www.roundsolutions.com/aarlogic/index.htm
Cheers,
Alex
12 Medina // Mar 9, 2008 at 20:04
Well, just to tell you that the Telit Technical department told me that the module has their own battery charger built in.
And you just need to connect the battery to the charge pin of the module. (It’s recommended that you use a protection circuit module on your battery. This just for an extra protection of the gm862).
They told me too that you can have connected an external power source and at the same time a battery. In case that the external power source fails the module automatically switch to the battery power.
Just like a cell phone.
Very cool isn’t it?
Kind Regards
Medina
13 Henda // Apr 26, 2008 at 15:04
hi..alex..im henda from indonesia….i really impressed with your project…now i’m doing the same project like you..i’m using the ATMega 8535 for the uController n using the SIM508 GSM/GPRS+GPS modul for the GPS receiver…my problems are : the GPS connector is too small so i cant build the PCB…i have another GPS modul but still I’m stuck in the C program…it will pleasant for me if you e-mail?send me the C code for atmega8 interfaced to your GPS module/your project…coz my deadline is 2 weeks again….big thanx Alex
14 Alex // Apr 26, 2008 at 17:42
Hi Henda,
for the c code, please have a look at
http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/
Cheers,
Alex
15 Henda Maulana Yusuf // Apr 28, 2008 at 15:47
hello alex…big thanks for the C code….i’m studying it right now…were u use the win avr for programming??can u send the “make file” for me……the last question..if im planning to build a delphi program to receive the data from the GPS by PC..then the delphi programm will automatically send the GPS data to the google earth..so i dont need to send the data to google earth by myself…can u give some advice about how to connect with the google earth…
big thanks Alex…keep fightin
16 Pauly // Oct 23, 2008 at 12:23
What represent the auth value? is the password for authentification on twitter.com? I don’t understant what represent “auth”. Can anyone help me? Thank you very much!
17 Alex // Oct 23, 2008 at 22:20
Yes, it’s the user and password, base64 encoded.
18 Pauly // Nov 14, 2008 at 11:13
Hello Alex!
Thank you for your answer!
Your program is a good example for me and i want to understand it very good, because i want to make something similarly, i want to send data to a server via GPRS (in fact a database). But before i want to test your program and i want to see how is working.
What is the format of the user and password?
Is something like this:
MDM.send(’Authorization: Basic \r\n’, 0) ? It is in this format? How is made the base64 encode in program? I read about this in the documentation of python. I’m new in python and i want to learn new things about this language and for that i need your help.
Thanks!
19 Alex // Nov 15, 2008 at 10:47
Hi Pauly,
try this:
import base64
user=’alex’
password=’secret’
base64string = base64.encodestring(’%s:%s’ % (user, password))
Cheers,
Alex
20 Pauly // Nov 15, 2008 at 12:01
Thank you very much for your answer!!!
I understood what you show me, but i don’t know now what is the form of value in the
MDM.send(’Authorization: Basic \r\n’, 0) ?
How i must to write the value, what is his form?
Is something like this: = , it is in this form?
Or i put directly in that sentence = and the instruction is like this form: MDM.send(’Authorization: Basic \r\n’, 0) ?
I don’ speak very good english, but i hope you will understand what i want to ask you.
Thanks!
21 Alex // Nov 16, 2008 at 08:54
Ok, try this: http://en.wikipedia.org/wiki/Basic_access_authentication
It explains how basic authentication works and how the header fields look like.
22 Pauly // Nov 16, 2008 at 10:41
Thank you!!!
Leave a Comment