Go Down

Topic: Transmitting SMS from a GSM modem (Read 707 times) previous topic - next topic

lmkaasa

Nov 13, 2012, 02:41 pm Last Edit: Nov 13, 2012, 02:49 pm by AWOL Reason: 1
Hi!

Ive got an project going on bout trying to send an text-message from my arduino to my mobile-phone using an GSM. The program im now using is this:
Code: [Select]

#include <SoftwareSerial.h>

SoftwareSerial cell(2, 3); // RX, TX
char mobilenumber[]="99497322";  // Replace xxxxxxxx with the recipient's mobile number
char textmessage[160]; // used to hold contents of message to send
int b=0;
void setup()
{  //Initialize serial ports for communication.
cell.begin(9600);
delay(35000); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
pinMode(13, OUTPUT); // use the LED for status
randomSeed(analogRead(0));
}
void startSMS()
// function to send a text message
{
digitalWrite(13, HIGH);
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");
cell.print("AT+CSCA=+4790002100");
cell.write((byte)34); // ASCII equivalent of "
cell.print(mobilenumber);
cell.write((byte)34);  // ASCII equivalent of " HOME MADE.
delay(500); // give the module some thinking time
}
void endSMS()
{
cell.write((byte)26);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
digitalWrite(13, LOW);
}
void loop()
{
b=random(0, 99);
for (int a=0; a<100; a++)
{
if (a==b)
{
startSMS();
cell.print("The random number is: ");
cell.print(b);
endSMS();
}
}
do
{
delay(1);
} while (1>0);
}

And I got som problem with getting it working, hope that someone maybe would be able to help me ;)


Moderator edit: CODE TAGS

AWOL

Quote
And I got som problem

...and?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

HazardsMind

does the mobile number need to have 9+ 949-7322, or does it need area code 9+(XXX) 949-7322 ?
your original number: 99497322

What problems are you getting?
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy