Tutorial: Send SMS from your Arduino using an old Motorola cell phone

Sending text messages from your Arduino can be a bit of a hassle. In this tutorial, I’ll show you a simple way to send text messages with your Arduino for around $20.

If you want to send a text message from your Arduino, you’ve got basically three options:

  • Use a GSM shield
  • Use an ethernet shield to send emails to a wireless carrier’s email-to-SMS gateway
  • Plug your Arduino into a computer via USB and have a script running on your computer that uses the aforementioned email-to-SMS gateway method.

Unfortunately, these methods are either expensive, require somewhat complicated code (depending on your coding abilities), or both. The last two options also require you to be within range of an internet connection or a computer, which isn’t always possible.

Fortunately, there is another option that is cheap, requires only basic code, and allows you to use it anywhere you’ve got power and cell service: use your Arduino to interface with a cell phone over a serial connection. In this tutorial we’ll be using the Motorola c168i, which can be found on Craigslist or eBay for less than $20. You may also be able to use Motorola’s C257, C261, V175, V176, V177, C168, W220, and W375, as they share the same serial connector. You might be able to use another kind of phone provided it has a serial connection (very uncommon in newer phones), but it will likely have different serial pinouts and / or a different set of supported commands.

What you’ll need

  • An Arduino (obviously)
  • Motorola C168i with working SIM card
  • Small breadboard + jumper wires
  • 3/32″ headset plug (TRS)
  • 10K ohm resistor
  • Pushbutton

Steps

1. Set up your C168i. 

You’ll need to make sure that your Motorola C168i is working properly and that you can send text messages from it. If you browse the phone’s settings, you can choose to do a master reset as well as initial phone setup.

Set up your C168i according to your carrier’s settings, and ensure you can send a text message from the phone itself before continuing.

2. Solder wires to your connector. 

You’ll want to solder one wire to each of the three connectors on your 3/32 headset plug. The tip connector will be our serial TX connection, the ring connector will be our serial RX connection, and the sleeve connector is our ground connection. In this photo, my blue wire is TX, white-blue wire is RX, and green is ground. Use a multimeter to figure out which pin connects to which part of the connector if you’re not sure.

3. Make the connections. 

Connect the TX to pin 2 of your Arduino, connect the RX to pin 3, and connect the ground connection to GND. Connect your pushbutton to pin 8. Make sure to use the pull down resistor, or you may get false readings. See the image below for a wiring diagram.

4. Modify & upload the code. 

Substitute the phone number for your own in the example code (found at the bottom of this post) and upload it to your Arduino.

5. Plug it in and test it out. 

Plug the 3/32″ headset plug into the headphone jack on the top of the phone and push your button. The on-board LED (13) should blink when the message has been sent. You can verify this by going into the phone’s outbox. If the message doesn’t send, or the message doesn’t appear in the phone’s outbox, double check your wiring and ensure there are no broken or shorted out connections, especially in your headset plug. You can also try unplugging and re-plugging the headset plug.

Demonstration

Example Code

The example code is fairly basic. It uses the SoftSerial library (included with the Arduino IDE) to set up a software serial connection on any pins that we want. Once we establish the serial connection, we use AT commands to wake the phone up, enter text mode (as opposed to data mode), create a new text message, and then send it to the appropriate phone number. We then wait 10 seconds, giving the phone enough time to send the message, and then delete the message from the phone’s outbox.

/*
Application Name: Arduino Send SMS
Description: Send SMS messages using a Motorola C168i
Author: Jeff Murchison
Contact: jeff@jeffmurchison.com
Date: September 17, 2012
Version: 1.0
License:

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

http://creativecommons.org/licenses/by-nc-sa/3.0/

Attributions / Special Thanks:

- Matthew Sheffield. This code based on his example, but updated to use Arduino IDE 1.0.1
and SoftwareSerial.

http://sheffiel.blogspot.ca/2011/02/remote-car-starter-controlling-motorola.html

*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(3, 2); // RX, TX pins

void setup() {

pinMode(13, OUTPUT); // Initialize pin 13 as digital out (LED)
pinMode(8, INPUT); // Our button pin
mySerial.begin(4800); // Open serial connection at baud rate of 4800

}

void loop(){

if (digitalRead(8) == HIGH){ // On button press
digitalWrite(13, HIGH); // Turn LED on.
mySerial.println("AT"); // Sends AT command to wake up cell phone
delay(500);
mySerial.println("AT+CMGF=1"); // Puts phone into SMS mode
delay(1000); // Wait a second
mySerial.println("AT+CMGW=\"+14165551234\""); // YOUR NUMBER HERE; Creates new message to number
delay(1000);
mySerial.print("Sent from my Arduino."); // Message contents
delay(1000);
mySerial.write(byte(26)); // (signals end of message)
delay(1000);
mySerial.println("AT+CMSS=1"); // Sends message at index of 1
digitalWrite(13, LOW); // Turn LED off
delay(250);
digitalWrite(13, HIGH); // Turn LED on.
delay(10000); // Give the phone time to send the SMS
mySerial.println("AT+CMGD=1"); // Deletes message at index of 1
digitalWrite(13, LOW); // Turn LED off.
delay(250);
}

}

Links

Note: I have disabled comments for this post because people are mostly asking questions that I have already answered in the post itself, in the comments, or that I can’t answer at all – mainly about what phones will and will not work for this project (the only ones I know that will work are listed above). If you’ve read through the post and all the comments and still have an issue then feel free to send me an email.

76 Responses to Tutorial: Send SMS from your Arduino using an old Motorola cell phone

  1. This is pretty awesome. Do you know if the phone can send SMS back to the Arduino over Serial? That way you could interact with the Arduino over SMS?

    • I believe it’s possible, but I haven’t looked into it yet. It appears, according to page 3-70 of this document that there is an AT command that’ll let you read messages. I know that Matt Sheffield was working on that functionality, so maybe give him a shout? If you figure it out, I’d love to see the results.

  2. So, in practical terms, you have an Arduino watching something- maybe a sensor on a garage door so you know when your spouse comes home- something. The event happens and the Arduino texts you that it has.

    That part I get. The phone part I do not. Warning! Stupid questions follow!

    “A working SIM card”. There is one in my phone- but that is the phone I want to receive the text on. Do I have to have service for two lines? Can I duplicate the SIM in my current phone, put the duplicate into my e-Bay cheapie and more or less text myself? I’m not clear how the phone end of it works in a day to day sense. Additional service sorts of busts your $20.

    • As far as I know, you can’t duplicate a SIM card. A SIM card can only be registered on a network once, and that’s to keep people from duplicating their cards and sharing them with their friends so they don’t have to get their own service.

      If you can’t use your existing SIM card, then yes, you’ll have to get a new one. Your options entirely depend on your carrier. Personally, I use a pay-as-you-go account, which cost me $10 for the SIM card. Some carriers give them away for free. You might also see if you can set it up as a family plan or something, where the cheap new phone draws from your existing text message package. The $20 was a startup materials cost. It’s impossible to predict how much it’ll actually cost everyone, there are too many variables; location, carriers, carrier rates, how many messages people will send, how long they’ll keep it going, etc.

      • by way of example, you can get a pay-as-you-go phone at W*lmart for about $15. Veriz*n has a pay-as-you-go plan that runs $30/month, but you can pre-pay $100 and you are good for a year, or until you use up all your credit. Typically, accessing the network costs $2 each day and calls and text messages are some nominal amount comparable to other plans. So, for example, if you set up the Arduino to send a text message only every 3 or 4 days with the tempreature in your cabin, or if it dropped below 40 degrees F, you could monitor the cabin for about half a year, so about $16/month. I think there are strictly SMS plans that might cheaper.

  3. is it possible to use in place of arduino peak 16F877

  4. Very interesting work, but i would like to know if someone could help me to adjust this code for Motorola V360V, because i can’t find any of this models you mentioned?

  5. Hi
    Thanks for this wonderful page. I am building a SMS based temperature alert system based on this page.
    Excuse my poor knowledge in embedded programming, but I have a doubt.
    The temperature sensor is an analog input right?
    So how do we replace the “if (digitalRead(8) == HIGH)” expression so that it will serve my purpose.
    I want an alert SMS to be sent when temperature crosses 25 degree celsius which corresponds to 250mV output from the sensor.
    Do we need to initialize the pin as analog?

    Thanks in advance.

  6. Thanks Jeff!
    Now that I came to know about the examples page of arduino website, I think I can tackle almost any problem I get on my way. Appreciate the help.

  7. By the way, the phone I acquired for this project is Motorola C168, not C168i.
    It will still work, right?

  8. I used the following code:

    #include

    SoftwareSerial mySerial(3, 2); // RX, TX pins

    void setup() {

    pinMode(13, OUTPUT); // Initialize pin 13 as digital out (LED)
    pinMode(8, INPUT); // Our button pin
    mySerial.begin(4800); // Open serial connection at baud rate of 4800

    }

    void loop(){

    if (digitalRead(8) == HIGH){ // On button press
    digitalWrite(13, HIGH); // Turn LED on.
    mySerial.println(“AT”); // Sends AT command to wake up cell phone
    delay(500);
    mySerial.println(“AT+CMGF=1″); // Puts phone into SMS mode
    delay(1000); // Wait a second
    mySerial.println(“AT+CMGW=\”+1919447786559\”"); // YOUR NUMBER HERE; Creates new message to number
    delay(1000);
    mySerial.print(“Sent from Arduino.”); // Message contents
    delay(1000);
    mySerial.write(byte(26)); // (signals end of message)
    delay(1000);
    mySerial.println(“AT+CMSS=1″); // Sends message at index of 1
    digitalWrite(13, LOW); // Turn LED off
    delay(250);
    digitalWrite(13, HIGH); // Turn LED on.
    delay(10000); // Give the phone time to send the SMS
    mySerial.println(“AT+CMGD=1″); // Deletes message at index of 1
    digitalWrite(13, LOW); // Turn LED off.
    delay(250);
    }

    }

    Although I can see the LED blink, No SMS was sent. I am powering the board using usb from computer.
    Is that the problem?
    There was also one more difference in what I did. I did not use a resistor, I just connected pin 8 to 5V of the arduino for a second directly.

    What do you think the problem is?

    • Check out step 5 above.

      It also appears that the Include line is missing the SoftwareSerial. It should be:

      “#include < SoftwareSerial.h >” (remove the spaces between the < and > )

  9. if I want to do a simulation, what software can I use?
    thank you

  10. i want to ask..if i use nokia 3310…i can use the same code as above?

    • Depends if the Nokia has a straight serial connection available, and if it accepts AT commands.

  11. Hi Jeff,
    I copied your sketch on my arduino uno and connected a Motorola C261 as you descibed.
    Besides some beeps it produces nothing.

    I also tried to read out any data from the software serial, without any success.

    Any Ideas?

    • Make sure you have your set to the correct baud rate. Other than that, I don’t know what to tell you other than make sure all the connections are correct.

  12. can i use anothor phone (samsung, nokia) to replace motorola 168i ?
    thank you.

    • Some people have gotten other phones to work, yes, but you’ll have to do a bit of research. This tutorial is only for a select few phones by Motorola.

  13. Hey Jeff,

    Thanks so much for posting this! It’s going to (hopefully) save my ass as I’ve been trying to use SMS for my thesis. Can’t wait to try this out :)

  14. is this not require rs232 to ttl converterl like MAX232?

    • Nope.

      • I’m pretty sure that there should be a 3.3V levels at data lines. USB data lines operates at 3.3V as C24 module inside the phone does.
        Nice article BTW.
        Thanks for that idea.

  15. Hello Jeff,
    thanks for this nice post. I just copied your example code and used it. The messages with the correct contents appear in the outbox, but it seems like the phone isn’t sending them. The wiring is correct and the number to which the message should be send is correct too. If i go to the outbox, “click” on one of these messages and hit “resent”, the message is send and appears at my other phone after a few seconds. I don’t really know what i am doing wrong. If you have any idea what the problem could be, would be nice if you could reply to my comment.

    • Did you try the last line of part 5? (“You can also try unplugging and re-plugging the headset plug.”)

      I encountered this issue as well and unplugging the headset and plugging it back in seemed to work.

  16. Everything works now, thanks for the great help. I have one last question: Is it possible to send the message to more then one number?
    Thanks again.

    • Jeff Murchison

      You can put the serial parts in a for loop, store your numbers in an array, and do it that way, otherwise I don’t know.

  17. Hello I wish I can ask you some questions about your code. Could you give an email address that I can contact you? Thank you

  18. Here is a code that I am trying to work on:

    #include

    SoftwareSerial mySerial(3, 2); // RX, TX pins

    void setup() {
    mySerial.begin(4800); // Open serial connection at baud rate of 4800

    }

    void loop(){

    mySerial.println(“AT”); // Sends AT command to wake up cell phone
    delay(500);
    mySerial.println(“AT+CMGF=1″); // Puts phone into SMS mode
    delay(1000); // Wait a second
    mySerial.println(“AT+CMGW=\”+19097060544\”"); // YOUR NUMBER HERE; Creates new message to number
    delay(1000);
    mySerial.print(“Sent from my Arduino.”); // Message contents
    delay(1000);
    mySerial.write(byte(26)); // (signals end of message)
    delay(1000);
    mySerial.println(“AT+CMSS=1″); // Sends message at index of 1
    delay(250);
    delay(10000); // Give the phone time to send the SMS
    mySerial.println(“AT+CMGD=1″); // Deletes message at index of 1
    delay(250);
    }

    However, it does not go to messaing screen, but it goes to “Calls Made” screen. Could we discuss how we can fix this?

    • Sorry, I never ran into that issue myself so I can’t really suggest anything other than maybe factory reset the phone and make sure it works by sending a test text message from it manually.

    • It appears your include line is wrong. Use this instead:

      #include < SoftwareSerial.h >

      (remove the spaces around the < and > )

  19. Hi thank you for such a great project!! i just had mine working and boy am i excited lol… I have a question though (and excuse my poor knowledge, im a newbie ).
    Is there a way i could modify this circuit so that i doesnt use a pushbutton. Let’s say i want to have the entire system self controlled and i want the arduino to send me a text message when and only when something happens (i.e. the phone runs on low battery.) how can i do that. do i need sensors, etc….
    Thank you so much you are my new hero lol.

  20. nice job. plz can you help me on how to receive sms and pass it to arduino using motorola c168 so that it can perform task which I want it to do

    • Jeff Murchison

      Unfortunately I don’t know how to read text messages from the phone, only send them. But if you figure it out, let me know!

  21. Thank you for the very useful article Jeff and sharing your knowledge. I can confirm that it works with the Motorola W375, which is available used for about £10 or less in the UK.

    • Thanks for confirming!

    • Hi, can I ask you if you had to lower voltage for motorola W375? Mine sometimes calls the number I inserted into the code if I press the button…i copied exactly the connections shown into the article but it doesn’t work with motorola w375 … Please can you help me? Thank you

  22. Hi, I from Colombia, I have nokia X2-00, I just copied your example code and used it. The messages with the correct contents appear in the outbox, but it seems like the phone isn’t sending them. The wiring is correct and the number to which the message should be send is correct too. If i go to the outbox, “click” on one of these messages and hit “resent”, the message is send and appears at my other phone after a few seconds. I don’t really know what i am doing wrong. If you have any idea what the problem could be, would be nice if you could reply to my comment.

  23. Crash Space » Blog Archive » Found @ CRASH Space: Too Many Phones!!!

  24. Hi Jeff,

    Just wondering if it is possible to have the cellphone sending two sms at the same time?

    thanks

    • I’m not sure to be honest. Some phones have the ability to send SMS to more than one number, but I haven’t tried doing this.

  25. Hi sir..
    It is possible to connect a numeric keypad to audrino gsm and set by SMS for ex. I press 1234567890 when you press = equals it will be send to my cellphone

  26. Why did you use, the pines 2,3 ? my arduino have the tx,rx in the 0,1 pines. Thanks.

    • I’m using software serial on pins 2 and 3. The hardware serial pins are 0 and 1. The software serial is for communicating between the phone and the Arduino, while the hardware serial is so that I can monitor the output from the Arduino.

  27. Can i use this model w395 SONY ERICCSON ?

  28. is it possible from motorola C123???

    • I don’t know. I listed models that should work in the post, and other than that I have no idea.

  29. Great…….
    It was really helpful
    Thanks for sharing to all.

  30. This is pretty awesome. I haven’t tried the project, but I’m curious about why this works? I suppose the commands “AT” etc. are specific for this Motorola phone (and some others)? Do all phones have commands like this? As is, can the code be modified to do this through the headphone/mic jack of any old phone? I had no idea phones could be programmed through the headset jack. I guess you need insider knowledge about how the phone works?

    • AT Commands are actually fairly standardized. You can control most modems with them (even modern 3G or GSM modems).

      The reason I used the headphone jack in this phone was because that’s where the serial connection to the phone is. The only other jack on the phone was for power. Modern phones typically won’t have a serial connection, let alone use the headphone jack for anything other than mic / headphones.

      If you find a phone that has a serial connection, then you can probably modify this project for that phone.

  31. hi jeff, it’s already possible to read sms with arduino?

  32. i’m trying to send sms with w375 and its not working.
    i have a mega 2560, and i changed the tx rx ports to 10 11 and nothing.

  33. Hello! Thank You very much. I ordered a Motorola W375 for 1 Buck at eBay and 2,50€ shipping. It’s without battery, but I test out:
    The 5 volts from the Arduino powers a cellphone. I hope that the phone will work
    with external power. I’m planning to use
    this as temperature monitor, giving statements
    via SMS.

  34. Hi, nice work..

    I wanna ask you if I can use this code for Nokia mobiles? if not, do u know the code for Nokia mobile phones?

    Thank you in advance..

  35. hey , i have been trying to setup this on my nokia N70 , unfortunately nothing till now working . any suggestions !

  36. Nokia Phone Serial Commands | wer bastelt mit?