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.