Pages: [1]   Go Down
Author Topic: GPRS/GSM Shield Time Setting Problems  (Read 1129 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 36
it's time to...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got a GPRS/GSM from http://www.elecrow.com/micro-controllers-c-109/shield-c-109_110/gprsgsm-shield-p-325.html .
Its Schematic is showed http://www.elecrow.com/download/ELE%20GPRSshield%20v1.0.pdf.
it works well when I program it with Serial COM .

but when I program the code to  Arduino, there are some problems.
it seems that it overflowed ,and some data lost.
The following code is what I upload to the Arduino.

Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8 ) ; // RX, TX
void setup()  
{
 // Open serial communications and wait for port to open:
  Serial.begin(19200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
}
void loop() // run over and over
{
mySerial.println( "AT+CCLK =\"12/12/27,10:43:50+08\"");
  if (mySerial.available())
    Serial.write(mySerial.read());
    delay(200);
mySerial.println( "AT+CCLK?" );
    if (mySerial.available())
    Serial.write(mySerial.read());
    delay(200);
}

The result is not acted as expected,the Serial COM shows like this :

AT+CCLK ="12/12/27,10:43:50+08"
OK
AT+CCLK?
+CCLK: "12/12AAAAAAAAAAAAAA


and the following  is a lot  A. That is to say,these data losts. Does anyone have the same phenomenon?
HOW CAN I DO WITH IT?  
Thanks!
« Last Edit: December 31, 2012, 06:41:58 am by Jackman » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
it's time to...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The following is  how did I program it with the Serial COM.
I program the with the following code.
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX
void setup()  
{
  Serial.begin(19200);
   // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
}
void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}
Then I open the Serial COM tool. Program it
Code:
AT+CCLK ="12/12/27,10:49:50+08"
it returns OK,Then I program it
Code:
AT+CCLK?
it returns

+CCLK: "12/12/27,10:49:53+08"
OK


So the question is why I program the GPRS/GSM Shield with the first code, it will lost much data,And I program it through the Serial tool, the GPRS/GSM shield works fine. Is it because the Software library OVERFLOW?
« Last Edit: December 31, 2012, 06:40:01 am by Jackman » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is it because the Software library OVERFLOW?
No. It is because you expect the serial data to get to the shield, to be processed, and the reply to arrive back at the Arduino in just a few nanoseconds. That does not happen, so the reply does not go with the command.

Why you are repeatedly sending a command to set the time is a mystery. That should be done ONCE, in setup().

The response is supposed to end with some kind of value that says "this is the end of the reply". You need to wait, in a while loop, for that character to arrive BEFORE you send another command.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
it's time to...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why you are repeatedly sending a command to set the time is a mystery. That should be done ONCE, in setup().
Thanks for your tips, I will do as you said, setting the time at the setup(). and this program will only be done one time before I upload my  project code. And GPRS/GSM Shield will be on power all time to keep its RTC run.
Quote
The response is supposed to end with some kind of value that says "this is the end of the reply". You need to wait, in a while loop, for that character to arrive BEFORE you send another command.
I changed the wait time to 2000(2s),and it works well . but the result also have a little problem.
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX
void setup() 
{
 // Open serial communications and wait for port to open:
  Serial.begin(19200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
}

void loop() // run over and over
{
mySerial.println( "AT+CCLK =\"12/12/27,10:43:50+08\"");
   delay(500);
  if (mySerial.available())
    Serial.write(mySerial.read());
   delay(500);
mySerial.println( "AT+CCLK?" );
    delay(500);
    if (mySerial.available())
    Serial.write(mySerial.read());
   delay(500);
}
The result shows

AT+CCLK ="12/12/27,10:43:50+08"
OK

AT+CCLK?
+CCLK: "12/12/27,10:43:50+08"
OK

AT+CCLK ="12/12/27,10:43:50+08"
OK
AT+AAAAAAAAAAAAAAAAA


There also are many A .Can you tell me why does this happen?
thanks

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can you tell me why does this happen?
Generally, when someone points out a problem, the thing to do is to fix that problem, first. Then, if there is still a problem, or another problem come up, ask more questions. It is incorrect to say "Yes, I'll fix that later, but why does this follow-on problem happen?". Fix the first problem. The follow-on problem may go away.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
it's time to...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Fix the first problem. The follow-on problem may go away.
Thanks for your advice.
What I asked is that delay more time, and the result is more data to show.
so I don't think it's really done with the first problem.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
it's time to...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have solved this Serial Buffer problem. and I print what I do to solve this
The following code is which works as I expect. The Serial port can print again and again.
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX
int i=0;
void setup() 
{
 // Open serial communications and wait for port to open:
  Serial.begin(19200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
}
void loop() // run over and over
{
mySerial.println( "AT+CCLK =\"12/12/27,10:43:50+08\"");
   delay(50);
  if (mySerial.available())
    Serial.write(mySerial.read());
   delay(50);
mySerial.println( "AT+CCLK?" );
    delay(50);
    if (mySerial.available())
    Serial.write(mySerial.read());
   delay(50);
   i++;
   if (i==50)
   {
   mySerial.flush();
   i=0;
   }
}
hope you find this useful when you meet problems with SoftwareSerial Buffer problem.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
hope you find this useful when you meet problems with SoftwareSerial Buffer problem.
Dumping random amounts of unread data is helpful? Not in my universe.
Logged

Pages: [1]   Go Up
Jump to: