Send SMS Messages from Raspberry Pi

The back story to this article is pretty simple. I have a Raspberry Pi, what is a raspberry pi, it is one of those super small ARM computers that cost about $35 (more information on the raspberry pi can be found at I use the Raspberry Pi to run Nagios and monitor my servers (a tutorial on that will be coming later). I wanted to be able to have my Raspberry Pi send me an SMS message should specific alert happen on my servers, but I really did not want to pay a SMS gateway for this luxury (email works find I would just prefer SMS). So I started looking for a solution. The following is how to text from computer allowing you to send a text message.

2014-02-10 09.32.19

I stumbled upon which allowed me to use a simple python script to send SMS messages. The following is how to get your Pi sending text messages with ease.

Step 1: Ensure your Raspberry Pi is setup with your distro of choice and has internet access.

Step2: Sign up for a google voice account
a Gmail account will be needed to do this.

Step3: Enable 2-step verification of your google account.
a link can be found on the following page.

Step4: Create an Application Specific password.
Navigate to scroll to the bottom and in the name field put “Raspberry Pi” (or whatever other name you want to identify the device). Click on Generate password.

You will then be given a one-time use password.

Step5: Log into your Pi and open the terminal or SSH using Putty
Next cd to your home directory in my case its /home/pi

cd  /home/pi


Step6: Clone the git repository.
First run the following command to prevent SSL errors:



Next run the following command to clone the git repository:

git clone


Step7:  Authorize your Raspberry Pi with Google.
cd to the newly created folder pygvoicelib
run the following command:


You will be prompted for your Gmail account and your Application password you got in step 4. After entering the information you will see a number of variables show up in the terminal. Make note of the following variables you will need them in the next step:

Step8:  Create a script to send a text message.
Run the following command (you can use nano if you wish):


Place the following code in the file we just created:


import pygvoicelib
number = raw_input('number:')
txtmsg = raw_input('message:')
client = pygvoicelib.GoogleVoice(username,apppass,auth_token,rnr_se)


Replace username, apppass, auth_token, and rnr_se with the variable values that were displayed with step 7

import pygvoicelib
number = raw_input('number:')
txtmsg = raw_input('message:')
client = pygvoicelib.GoogleVoice('[email protected]','asdfahrwsthjtrh','4k3EozF_Qmrg3tD2_m56nQtFHCVSaTdUxb7HvcaN6g3PV929VH0eH4GGVOVpbVK2O6EaGFzMDYA6PhPjaEHr0ZGjO1GQN3RGhQLXqePWfglbXnA2n7XpUophOk5qztQyv2fYM7eYgtVCYeO6txTqbDQAAANsAAABZ7d0GTL2pJsUauPkH4Z3cpbJFqjfLZYfhok1b11pIMDnEOypZgIcOVdPEt8jEMx7oY9hHJeJoDQZYndDJDu8uoDbDWgxl87GMy990snKWR8iy8VIB17769eVWboa3224U8DLZLUWMpP0d4hfsDK5MQ','L6tph126BjmNjDcfTZGaWYeb+sk=')



Step8: Send a text message.
Run the following command:


It will prompt you for a phone number and then for the message you wish to send.

Step9: Celebrate

Open a beer and relax

11 comments on “Send SMS Messages from Raspberry Pi
  1. Hi Damien. Is this code Pi specific or should it run on Linux/OSX too? It looks like there are no Pi specifc elements to the process. That said I’m getting errors at step 7..

    • Ensure you are signed up completely for a United states google voice account. I have gotten feedback that it doesn’t work outside the US and possibly Canada. It is not Pi specific i also got it running on my CentOS server.

      Let me know what the error output is and I will try to duplicate it.

      • Hey Damien. Just retrying now and it does actually seem to work through without error! However sadly no message comes through, but thats probably as I’m in UK. Humbug 🙁

        • I have gotten feed back that it only works in the US and possibly in canada. A work around might be to setup a US Googlevoice for your cellphone and install the Googlevoice app then you would be able to get it.

          • Thanks for the tip. Its specified in the Google Voice T&Cs. I think UK might have been included with Canada by now if it weren’t that our telecomms companies rely too much on PAYG sms fees.

  2. Pingback: Citycorpse | Build your own instant messenger server Part 1

  3. Hi, nice work. I’m getting error trying to send SMS.
    Traceback (most recent call last):
    File “”, line 13, in
    File “/usr/local/bin/tide/pygvoicelib/”, line 341, in sms
    ‘_rnr_se’:self.rnr_se}, mode=’raw’)
    File “/usr/local/bin/tide/pygvoicelib/”, line 224, in get_auth_url
    raise ServerError(err_code, resp)
    pygvoicelib.ServerError: (500, ‘\n\nInternal Server Error\n\n\nInternal Server Error\nError 500\n\n \n’)

    • Ensure you are signed up completely for a United states google voice account. I have gotten feedback that it doesn’t work outside the US and possibly Canada.

      What step are you having the error?

  4. Hi,

    I am trying to use this setup, but get a HTTP 404 error. After investigating further, i camme across Google site ,which said ClientLogin has been deprecated and that is the reason why I am getting 404 error. Did you update your code/steps to support OAuth as mentioned below:

    Important: ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible.

Leave a Reply

Your email address will not be published. Required fields are marked *