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++;
}
}
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.
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?
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);
}
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)
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)
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.
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)
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 )
#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()':
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... :