send SMS with Arduino

hey guys im trying to send a SMS from my SIM548 and arduino and i dont know whats wrong but its like the SMS is send but is not.. i can see in the SERIAL MONITOR this:

AT+CMGF=1
AT+CMGS=8622412396
Hola caracola...

it looks like the sms was send but is not.. and here the Sketch

int led = 13;
int onModulePin = 5; // the pin to switch on the module (without press on button)
int resetModulePin = 4;
int timesToSend = 1; // Numbers of SMS to send
int count = 0;
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
}
void setup(){
pinMode(led, OUTPUT);
pinMode(onModulePin, OUTPUT);
pinMode(resetModulePin, OUTPUT);
Serial.begin(38400); // the GPRS baud rate
switchModule(); // swith the module ON the led on the module starts blinking
for (int i=0;i<5;i++){
delay(5000);
}
}
void loop(){
while (count < timesToSend){
Serial.println("AT+CMGF=1"); // set the SMS mode to text
delay(1500);
Serial.println("AT+CMGS=8622412396"); // send the SMS the number
delay(1500);
Serial.println("Hola caracola..."); // the SMS body
delay(500);
Serial.println(26,BYTE); // end of message command
delay(2000);
count++;
}
if (count == timesToSend){
switchModule(); // switch the module off the led on the module stops blinking
count++;
}
}

How do you have the module connected to the Arduino?

The fact that you can see the data in the serial monitor is no guarantee that the data is getting to the SMS module.

Hello,

I'm trying to solve one problem similar like yours.

I've seen that when su use the follow code,
...
Serial.println("AT+CMGS=8622412396"); // send the SMS the number
delay(1500);
Serial.println("Hola caracola...");
...

in the string of AT+CMGS=..., I think that you are wrong, it should be like this:
Serial.println("AT+CMGS="8622412396""); // send the SMS the

I've sended sms whith the text in format of something like this:

Serial.println("AT+CMGS=8622412396"); // send the SMS the number
delay(1500);
Serial.println("Hola caracola...");

but I would like to send a buffer char in a var and send

Serial.println(smsString); where definition of smsString is:

PString smsString(smsBuffer,sizeof(smsBuffer));

My question is how I must to build the PString in order to have the string correctly.

Thanks
Oscar

How do you have the module connected to the Arduino?

Can "Arduino Uno" TX and RX pins be stright connected to RX and TX pins of a GSM module equipped with a standard serial port?

I'm talking about "modules" like this:

You can see the standard 9-pins port, which I successfully use to control the device using the PC.

If, as I read somewhere, voltages are different, do I really need a dedicated "232" chip to interface the port? Couldn't I just use some resistors to bring down Arduino voltage from 5 to 3.3 V?

If the device is intended to connect to a PC serial port, the device will expect serial data to be +12V/-12V and inverted from TTL levels.

No, you can't just use a couple of resistors. Yes, you need a MAX232 chip.

So the connections are ok?

Here's the code I used with a Sparkfun GSM/GPRS modem shield and a Duemilanove. Hopefully it will be helpful :

#include <NewSoftSerial.h> //Include the NewSoftSerial library to send serial commands to the cellular module.

char r=13; //return character
NewSoftSerial cell(4,3); //Create a 'fake' serial port. Pin 4 is the Rx pin, pin 3 is the Tx pin.
String cellContent=""; //string we're sending
String ctlZ="\x1A"; //the code for Ctrl-Z

String content="Here is my SMS messaage"; //The text I'm sending

void setup() {

// start the serial library:
Serial.begin(9600);
cell.begin(9600);

}

void loop()
{

//add our message to the CellContent string
cellContent+=content;
//add the Crtl-Z hex character
cellContent+=ctlZ;
//put the modem into text mode
textMode();
//wait for a moment
delay(50);
//send message
sendMsg();

cellContent="";
delay(15000);

}

void textMode()
{
//init text mode
cell.print("AT+CMGF=1");
cell.print(r);
}

void sendMsg(){
//This number needs to be replaced with the number you are sending to
cell.print("AT+CMGS="3474226409"");
cell.print(r);
cell.print(cellContent);
cell.print(r);
}

So the connections are ok?

Nope.

As stated above, TTL (5v signals) and RS232(+12/-12v) signals just won't mix. You WILL need a Max232 (or something similar). The software side, you're okay, hardware.. just need an extra chip.

You could purchase a TTL to RS232 converter pre-assembled on a circuit board with the capacitors and such, or go the cheap DIY route, buy a few MAX232, some capacitors (size depends on which chip you purchase) and solder up a cheap-o, or even use it on a breadboard.

You'll only need 3 connections from the "Cell phone shield" and the Max232 though, GROUND, TX and RX. (and I suppose you could find a 5v line to power the 232 from as well)

Here's one from Robotshop. Keep in mind this is fairly expensive with shipping and all, you'll find much better deals on eBay.. especially if you're buying the chip/capacitors in bulk.
http://www.robotshop.com/droids-db9-serial-adapter.html?utm_source=google&utm_medium=base&utm_campaign=jos

But another thing to note, this particular converter has all the Handshaking pins brought out for use, most don't. ( I don't believe you need to use them, but it's good to know before you buy :P)

Here's a cheaper version, without the extra pins brought out:
http://www.nkcelectronics.com/rs232-to-ttl-5v-converter.html

If the device is intended to connect to a PC serial port, the device will expect serial data to be +12V/-12V and inverted from TTL levels.

No, you can't just use a couple of resistors. Yes, you need a MAX232 chip.

What about connecting the arduino directly to the GSM module mounted on the board? The board would provide circuitry/firmware to the GSM module, needed to connect to GSM network, while the GSM module would communicate directly with the Arduino.

A better imiage of GSM module mounted on a board:

Modem datasheet:
http://www.sendsms.cn/download/WMOi3_UG_10.pdf

Hello all,

I've just resolve my problem, like this way..

myString.print("Lat: ");
//myString.println(flat);
printFloat(flat, 3);
myString.print("\n");
myString.print("Long: ");
//myString.println(flon);
printFloat(flon, 3);
myString.print("\n");
myString.print("Date: "); myString.print(static_castday)); myString.print("/"); myString.print(static_cast(month)); myString.print("/"); myString.print(year);
myString.print("\n");
myString.print("Time: "); myString.print(static_cast(hour)); myString.print(":"); myString.print(static_cast(minutes)); myString.print(":"); myString.print(static_cast(second)); myString.print("."); myString.print(static_cast(hundredths));
myString.print("\n");
myString.print("Fix age: "); myString.print(fix_age); myString.print("ms.");
myString.print("\n"");

Thanks to all,

Oscar

Nope.

As stated above, TTL (5v signals) and RS232(+12/-12v) signals just won't mix. You WILL need a Max232 (or something similar). The software side, you're okay, hardware.. just need an extra chip.

You could purchase a TTL to RS232 converter pre-assembled on a circuit board with the capacitors and such, or go the cheap DIY route, buy a few MAX232, some capacitors (size depends on which chip you purchase) and solder up a cheap-o, or even use it on a breadboard.

You'll only need 3 connections from the "Cell phone shield" and the Max232 though, GROUND, TX and RX. (and I suppose you could find a 5v line to power the 232 from as well)

Here's one from Robotshop. Keep in mind this is fairly expensive with shipping and all, you'll find much better deals on eBay.. especially if you're buying the chip/capacitors in bulk.
http://www.robotshop.com/droids-db9-serial-adapter.html?utm_source=google&utm_me...

But another thing to note, this particular converter has all the Handshaking pins brought out for use, most don't. ( I don't believe you need to use them, but it's good to know before you buy )

Here's a cheaper version, without the extra pins brought out:
http://www.nkcelectronics.com/rs232-to-ttl-5v-converter.html

but i use the GPS part with out any problems... so thats mean the the GSM its different comunicanion?

NewSoftSerial cell(4,3); //Create a 'fake' serial port. Pin 4 is the Rx pin, pin 3 is the Tx pin.

you can really use pins 3 and 4 as RX and TX??

you can really use pins 3 and 4 as RX and TX??

With the appropriate soft serial library you can...

#include <NewSoftSerial.h> //Include the NewSoftSerial library to send serial commands to the cellular module.

char r=13; //return character
NewSoftSerial cell(4,3); //Create a 'fake' serial port. Pin 4 is the Rx pin, pin 3 is the Tx pin.
String cellContent=""; //string we're sending
String ctlZ="\x1A"; //the code for Ctrl-Z

String content="Here is my SMS messaage"; //The text I'm sending

void setup() {

// start the serial library:
Serial.begin(9600);
cell.begin(9600);

}

void loop()
{

//add our message to the CellContent string
cellContent+=content;
//add the Crtl-Z hex character
cellContent+=ctlZ;
//put the modem into text mode
textMode();
//wait for a moment
delay(50);
//send message
sendMsg();

cellContent="";
delay(15000);

}

void textMode()
{
//init text mode
cell.print("AT+CMGF=1");
cell.print(r);
}

void sendMsg(){
//This number needs to be replaced with the number you are sending to
cell.print("AT+CMGS="3474226409"");
cell.print(r);
cell.print(cellContent);
cell.print(r);
}

hey i was using this one but it get me this error

error: 'String' does not name a type In function 'void loop()':
In function 'void sendMsg()':

#include <WString.h>

What about using the USB port to communicate with a GSM modem? Currently the USB port can be successfully used to get the arduino communicate with PC in serial-simulation.

My problem is I can't find any max232-like chips in electronic shops around here... >:(

But I can easily find an USB2serial cable/converter: is it suitable to connect Arduino to a GSM phone? But it has USB connector on PC and serial connector coming out... ::slight_smile:

Or maybe this schematic can be reversed?

(But who knows if I'd ever find the IC...)

Or maybe this?

I eventually found a schematic to build a serial/TTL converter without ICs, just using transistor, capacitors and resistors:
https://web.archive.org/web/20210506195922/http://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/

check out this thread on the merits of the transistor trick vs. a real hardware solution.

-j