251Views9Replies

Author Options:

hye everybody.. im new in Arduino.. i want to make a program which can print value of AT+COPS? as a sms body? Answered

Actually AT+COPS? will return an available network and i want to make the available network from AT+COPS? as sms or message body.
here is a code that i try but it is not working

Serial.println("AT+COPS?");
if (Serial.available())
{
     Serial.println(AT+COPS?);      // This is a sms body that will print the network available
}

Discussions

0
None
steveastrouk

Best Answer 8 years ago

Does your hardware work, so you CAN get comms to the phone ? What interface are you using ?

0
None
teddycutesteveastrouk

Answer 8 years ago

 yes. my hardware are working and i can get the comms to the phone (just work when i send simple message such as "Hello") but i cannot get the available network as the message to send via phone.
im using Arduino Duemilanove. what do you mean by interface?

0
None
steveastroukteddycute

Answer 8 years ago

How does the phone connect to the Arduino. The connection is called an interface.

So you can send AT commands to the phone  ?

Your code sends "AT +COPS" and should then wait and READ the reply from the phone. Your code has no read command

0
None
teddycutesteveastrouk

Answer 8 years ago

 is it something like this?

void setup()
{
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  Serial.begin(115200;
  Serial.println("AT+CMGF=1");
}

void sms()
{
  Serial.println("AT+COPS?");
  if (Serial.available())
  {
     msg = Serial.read();
  }
}
void loop()
{
  while (count < timesToSend)
  {
     delay(1000);
     Serial.print("AT+CMGS=")
     Serial.print(34,BYTE);
     Serial.print("**********");      // where ********** is the phone number
     Serial.println(34,BYTE);
     Serial.print(msg);                // the sms body that will send message of the                                                       // available network
     Serial.println(0x1A,BYTE);

     count++;
}
if (count == timesToSend)
{
   Serial.println("AT+PSCPOF");
   count++;
}
}

0
None
steveastroukteddycute

Answer 8 years ago

What HARDWARE are you using to talk to the phone ? Are you tying up the serial port on the Arduino, or have we got something we can use as a debug port ? 

Can you talk to the phone at all ? 

I would want to see the message from the phone after
{
  Serial.println("AT+COPS?");
  if (Serial.available())
  {
     msg = Serial.read();

  }

0
None
teddycutesteveastrouk

Answer 8 years ago

- im using Sagem Communication MODULE Hilo (GSM Module).

-i already can make a missed call and send a simple message to the phone.

- the above coding maybe not working because i got nothing message from the phone..


0
None
steveastroukteddycute

Answer 8 years ago

What does the manual say about the at+cops command ? There are only approximate standards for the AT commands.

0
None
teddycuteteddycute

Answer 8 years ago

 can you help me to correct the coding if there are any errors..
the above coding actually will send an empty message..
thanks a lot for the help