score2sms – DIY football score updates via text message

score2sms is a football (soccer) score notification system.

You may also be interested in checking out my much more recent cellular related project: DIY GSM-enabled Gate Access Control System.

Let’s say you’re favourite football team is playing tonight, BUT you’ve just promised your girl that you’d take her out to that new Indo-Cuban sushi restaurant slash hair salon (hey, it could exist). So what do you do? Now obviously you can access the net using your mobile these days, but that means you have to keep checking your phone every 2 minutes. Or I suppose you could ask a friend to update you, but at the rate your friend is downing those beers at the sports bar he’s probably not going to remember to text you (well my friends anyway). The solution?

score2sms!

score2sms is a system using some Linux software, some electronics and an old Nokia mobile phone which will automatically text you when the score changes for games that you have chosen to monitor. There are three parts to this system:

1. Nokia 3310 mobile phone.
2. Some electronics which allow the 3310 to connect to your computer.
3. The software (Gammu + score2sms).

1) The Phone

I chose the Nokia 3310 as I had one to play around with. (Actually the first one I used was destroyed whilst experimenting, but I then found another one). When I first started researching how to access the phone through the computer I soon learnt about the Gammu project (see item 3). Gammu has lots of support for Nokia phones which just reinforced my choice of the 3310.

The Nokia 3310

The Nokia 3310

2) The Electronics

Usually a phone is connected to a computer with a data cable. For older phones like the 3310 the data cable was not supplied with the phone, and obtaining one now is relatively expensive – whereas if you know how, making your own is reaaaaally cheap! So I made my own. The 3310 is accessed using the serial port. My laptop has no DB-9 serial port, and so I’m using a USB-Serial adapter. This is not all you need however, as the voltage levels of the phone are not the same as that of the adapter cable. I don’t take any credit for the shifting circuit, it all came from an excellent website created by Panu Tuominen. You can find all the information you need to create the circuit at his website. I’m very thankful to him for allowing everyone to use his circuit and so I’m not going to copy/paste anything from his site to this blog. I did the PCB layout in Eagle, and created a single-sided board using the toner-transfer method of making PCB’s. Here is what My finished PCB looks like: The populated PCB (click for larger image)

The populated PCB (click for larger image)

The populated PCB (click for larger image)

Bottom side

Bottom side

The hardest part really is connecting the PCB to the to data contacts on the phone. On a 3310 they are found in a small cavity underneath the battery. Soldering the tiny wires to the tiny pads is probably not a good idea after a cup of coffee. In the end it worked out fine.

Battery, phone and electronics (click for larger image)

Battery, phone and electronics (click for larger image)

The whole shebang (click for larger image)

The whole shebang (click for larger image)

3) The Software

First a word on Gammu. Gammu is software which provides a user with a command line interface (CLI) to your mobile phone (via a data cable of course). It’s quite easy to use if you’re used to using a CLI. For example, to check that my phone was connected and could communicate with Gammu I used the ‘identify’ command and got the following output:

d@dtop:~$ gammu identify
Manufacturer         : Nokia
Model                : 3310 (NHM-5)
Firmware             : 06.07 B (17-06-03)
Hardware             : 1054
IMEI                 : 357966025248960
Original IMEI        : 357966025248960
Manufactured         : 0204
Product code         : 0508935
Simlock 1     : MCC+MNC      65501, CLOSED, user   , counter 0
Simlock 2     : GID1          0000, opened, factory, counter 0
Simlock 3     : GID2          0000, opened, factory, counter 0
Simlock 4     : MSIN    ??????????, opened, factory, counter 0
MSID          : 836d4eca0690bbb71fbbf76ea5
MCU checksum  : 0E3E
DSP ROM       : 6

From there on one would use simple commands to send text messages, call numbers and access the phone book. My Python script, score2sms, accesses Gammu using the subprocess module. So now more on the actual script.

score2sms is a command line based script. A user has the following options:

  • Add a team to monitor for a specific mobile phone number to the notification list.
  • Remove a phone number from the notification list.
  • Clear the notification list of all numbers.
  • Check the status of score2sms.
  • Start the monitoring process.
  • Stop the monitoring process.

How it works is this: A user adds the teams he wishes to receive notifications for. Each team can be assigned to a different mobile number. When the monitoring process is started score2sms creates a entry in the crontab file. Cron is software which executes scheduled events from the shell in Linux, and a crontab file is a list of all the scheduled events. The entry created by score2sms tells cron to execute the score2sms script every 2 minutes with a specific argument. When score2sms is run with this argument it uses a subprocess to execute the w3m web browser, which dumps all the text from the http://www.livescore.com website into a local file. score2sms then runs through all the teams in the notification list and uses grep to locate the team name. Some character handling is then performed to extract the score from the livescore text dump. This score is checked against any previous scores logged for that team. If it is different, the script uses subprocess again to execute Gammu with the sendsms command and the string containing the competing teams and the game’s score. A log of all score2sms activity is written to file for later inspection.

You can take a look at look at the script my clicking here. I’m no software fundi or Linux guru, I’m still learning! – See ‘Notes’ at the end.

Usage

Here is a quick usage example:

This is what www.livescore.com looks like (click for a larger image):

www.livescore.com - live scores for football games around the world.

http://www.livescore.com - live scores for football games around the world.

At the time I’m writing this there is only one game being played, between Bran Bergen and Stromsgodset (never heard of them). So we’ll choose to follow Stromsgodset.

Change to the directory where the score2sms.py script is installed. Make sure it’s executable, or use the python compiler directly. Now run score2sms.py with the correct arguments to set up and enable the monitoring (click the pic to see it full sized):

Using score2sms from the terminal (click for larger image)

Using score2sms from the terminal (click for larger image)

So now cron will wait until every 2nd minute to execute the script. The above screenshot shows a listing of the crontab file. A text message is sent only sent when the score has changed.

Et voila! The image below shows the received text message. Yay Stromsgodset is winning :) (The *HT indicates half-time – it was half-time when I initiated the monitoring).

Received text message (click for a slightly bigger image)

Received text message (click for a slightly bigger image)

Notes:

  • Yes I know there are probably 17 million better ways to do this.
  • I don’t intend to support this for anyone other than myself. It was just a personal project.
  • Please don’t email me asking how to run Gammu or to get your computer to talk to a phone. It’s all on the net. No one told me, I just followed the instructions!
  • I know we use the word ‘soccer’ in South Africa, but I just don’t like it. Football sounds more cultured ;P
  • Special thanks to Tammy for donating her old Nokia on which I did most of the testing – and later destroyed :|

12 responses to “score2sms – DIY football score updates via text message

  1. Pingback: score2sms - DIY football score updates via text message « dinofizz

  2. hala nokia me te keq nuk kam pa

  3. this is a very good handy.i need one set.

  4. Hi there,

    Does it mean we need to do this for each team? E.g. if I want to follow 3 teams I’ll need 3 mobile phones, 3 computers etc? Sorry if the question sounds silly.

    Thanks a lot

    • No, you can specify any number of teams to check for score updates. Each time the crontab entry is executed the script will run through the list of teams checking for changes in the scores.

      – I must add that I havent used this script in over a year, so I’m not sure if the text identification with livescore.com still works! But I have commented the code so you can check how it works.

  5. Hey! Great project! I was trying to read your script but it doesn’t let me to do so…can you please post a link that works?

    Thanks a lot!

    • I have updated the link.

      Just bear in mind I have not checked the script functionality in over a year! I wouldn’t be surprised if the formatting of the livescore.com website has changed, meaning the text lookup in the script probably won’t work.

  6. what a nice system . HAHAHQ!

  7. Wonderful goods from you, man. I’ve be mindful your stuff prior to and you’re just extremely magnificent. I really like what you’ve bought here, really like what you are saying and the way in which in which you are saying it. You’re making it enjoyable and you continue to take care of to keep it sensible. I can’t wait to learn much more from you. That is really a tremendous website.

  8. Hurrah, that’s what I was exploring for, what a information! existing here at this webpage, thanks admin of this site.

  9. A person essentially help to make seriously posts I would state. This is the first time I frequented your web page and thus far? I surprised with the research you made to create this particular publish extraordinary. Fantastic job! kceddgkdcgke

Leave a reply to dinofizz Cancel reply