Go Down

Topic: GSM 1.05 Library on Arduino Mega ADK doesn't work (Read 274 times) previous topic - next topic

PeerVincent

May 21, 2018, 04:47 pm Last Edit: May 21, 2018, 05:24 pm by PeerVincent
Dear community,

recently I got myself an original GSM v2 shield from Arduino for my Mega ADK board, and now I am about to do my first steps on communication to and from the Quectel M10 chip onboard the shield.

In preparation I followed user guide on the Arduino site to adapt the ADK board (Pin 10 instead of Pin2) for GSM TXing and bended the Pin2 on ADK board as proposed.

https://www.arduino.cc/en/Guide/GSMShieldLeonardoMega

Then I opened the Example Sketch /GSM/Tools/TestModem for checking if the M10 responds on any request by the software. Additionally I attached an oscilloscope on GSM RX/TX line verifying the data online.

After compiling and starting up the sketch "ModemTest" there are some things to remark:
First, if I compile any of these GSM sketches, the compiler brings up a lot of various warnings like "typedef was ignored" or other "deprecated String issues". It doesn't matter which Sketch to be opened, I can't get rid of these warnings. Even if I try it on "Sloeber 4.6", same scenario and a lot of warnings after opening a default sketch.

So - have these libraries (in this case GSM 1.0.5) never been fully tested and qualified before publishing them or has a user accept these warnings and just ignore them? (which I wouldn't prefer)

Well, if I upload the copiled software it comes up with the message "Starting modem test..."
After approx. 12 seconds something happens on the TX line of the Arduino.
As I activated my UART decoding on oscilloscope, it tells me that Arduino prints an "A and <CR>"

The Quectel M10 doesn't recognize this /corrupt/ command and thus does not respond.

Next try, using the "SMS Messages Receiver" Sketch...
Compiler brings up a lot of warnings like:
"deprecated conversion from string constant to 'char*' [-Wwrite-strings]"
"passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]"
etc.

Arduino starts with "AT<CR>" Command, M10 responds with something like "AT  OK<CR>"
then
Arduino continues dataflow with "AT+CGREG?<CR>", M10 responds with
"AT+CGREG?<CR>  AT+CGREG 0,0  OK<CR>"

But then....nothing happens anymore and the system state remains or hangs at "SMS Messages Receiver".

It's the same for various other GSM applications, software hangs at startup.

Just tried other sketches like "BandManagement.ino" or "ReceiveSMS" - no success.

So - my question is:
Does anybody know how to download and run i.e. the "TestModem" application without warnings and returning a feasible IMEI number, in other words, a working app?

Or is there a newer GSM 1.0.x lib release (without tons of warnings) available?

It is real hard to debug the system as Arduino IDE doesn't support such things, so software with its library has to run - and if not - you're screwed up.

After a bunch of hours and a lot of reasearch I decided to post this issue to an Arduino forum.
I'd like to run it but I apparently fail at the "plug and play" concept of Arduino World.

Regards, Peer.





PeerVincent

#1
May 24, 2018, 08:15 am Last Edit: May 24, 2018, 08:16 am by PeerVincent
Switched to "Atmel Studio", actually I didn't know that Atmel Studio can be combined with the Arduino World. Loading an .ino File, Studio creates the required environment and the library structure automatically.

Instead of progamming the CPU via USB I use JTAG and the Atmel Dragon as Interface. Works pretty well except some low frequented crashes by Atmel Studio.

In Atmel Studio compiler warnings cannot be detected, so everything seems to be allright and you can implement your application using instanced objects from library.

xartefact

When you receive +CREG: 0,0 , it means that your modem isn't registered and is not currently searching a new operator to register to.
In other words, you can't do anything...

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial gsm(10, 3);
void setup()
{
  Serial.begin(19200);
  gsm.begin(19200);
}

void loop()
{
  if (gsm.available()) Serial.write(gsm.read());
  if (Serial.available()) gsm.write(Serial.read());
}


On serial monitor, send AT commands to the modem (Quectel_M10_AT_Commands_Manual_V4.0.pdf
AT -> must return OK
AT&F   -> to reset to factory default ->must return OK
AT+CGATT?
// if +CGATT: 0   send AT+CGATT=1

let me know.


PeerVincent

#3
May 26, 2018, 12:01 am Last Edit: May 26, 2018, 12:06 am by PeerVincent
Thanks for your reply.
In the meantime I got it running, the M10 responses to all requests from the Mega ADK Board.
I connected a double FTDI232 chip to trace GSM RX and TX on 9k6 Baud.
SMS Receive- and SMSSend are working quite well, sometimes the software gets stuck in the middle of a dial-up phase where +CREG:0,1 is received showing that M10 searches for a network and actually the host keeps on sending +CREG Commands until CREG:0,2 (=connected), however in some cases software stops and a HW reset is the only way out.
The GSMScanNetworks and TestModem Sketches don't work. The first AT Command is wrong (it emits an A<CR> instead of an AT<CR>, and just nothing happens there.
Don't know if I'll keep on using Arduino Environment and its cpp Library or to switch back to normal C due to software stability issues. I need to rely on the application. My goal is to create an SMS Terminal for old people who i.e. have problems with softkeys.

xartefact

Indeed, GSM Library is surely powerful, but very heavy and using a lot of memory. I'm using my own code to send commands to my GPRS shield (seeedstudio v3) and check back the responses.

PeerVincent

Yeah thats true, it seems to be very large for one special purpose or app. So I'll fetch what I need... First of all I have to figure out some things about the dial-up sequencing / handshaking btw. M10 and host.
Or, maybe you like to share your code?
What setup do you have got?
Regards, Peer

xartefact

#6
May 26, 2018, 07:28 pm Last Edit: May 27, 2018, 12:57 am by xartefact
I use the SeeedStudio GRPS shield v3 with Arduino UNO or MEGA (HardwareSerial or SoftwareSerial)

Below 2 sketches very similars but who don't use the same method to handle modem responses.

In the first sketch, the at_recv function reads data until the response is read and timeout if not.
In the second one, the at_recv function reads data until the number of lines given in parameter is read. When we send an  AT command, we know how many lines the modem will give us back and we never timeout even if the modem response is not the one we wait for.

I've also written a complete library which use PROGMEM storage for all the strings, but I have not yet documented enough to publish it and it exists some like tinyGSM wich are very complete.

Code: [Select]

int at_recv(const char* resp, char *buff, int len, unsigned long timeout) {
  unsigned long rxstart = millis();
  int rxmatch = 0, rxlen = 0;
  while (1) {
    if (gprs.available()) {
      char c = (char) gprs.read();
      if (buff != NULL) {
        buff[rxlen++] = c;
        if (rxlen == len) break;
      }
      rxmatch = (c == resp[rxmatch]) ? (rxmatch + 1) : 0;
      if (resp[rxmatch] == '\0') break;
    } else delay(10);

    if ((millis() - rxstart) > timeout) return 0;
  }

  return rxlen;
}



Code: [Select]

int at_recv(char* buff, int len, int clf, unsigned long timeout) {
  unsigned long rxstart = millis();
  int rxlen = 0, rxclf = 0;
  do {
    if (gprs.available()) {
      byte c = gprs.read();
      buff[rxlen++] = c;
      if (c == 10) rxclf++;
    }else delay(10);

    if ((millis() - rxstart) > timeout) break;
  } while ((rxlen != len) && (rxclf != clf));
  return rxlen;
}

PeerVincent

#7
May 27, 2018, 03:54 pm Last Edit: May 27, 2018, 03:57 pm by PeerVincent
Hi back,
thanks for your info and sketches. Don't know anything about Seedstudio, but in fact, there are some tools using AT commands on the web.
In the meantime I decided to switch to to Arduino DUE using SAM 3X8E core, FREERTOS and implementing another library I found:

https://github.com/renzbagaporo/quectel-m10-sms-lib

The original Ardunio GSM library seems to be too big for my purpose, and furthermore, sometimes the dial-up just doesn't work, so after reset dial-up finally does its work. But frankly, this is not my goal.
I need a lean software library that reliably operates as requested, without "dead lock" or similar.

First I have to re-pin the GSM TX/TX connections to a real UART (in this case UART1) and no "software UART".

Greetings, Peer

Go Up