0

I have an EFCom GPRS/GSM Shield http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield and I am using it with a mega 2560. The problem is that the code in the wiki page

//Serial Relay - Arduino will patch a  
//serial link between the computer and the GPRS Shield 
//at 19200 bps 8-N-1 
//Computer is connected to Hardware UART 
//GPRS Shield is connected to the Software UART 

#include <SoftwareSerial.h>   
SoftwareSerial mySerial(2, 3);   
void setup() {   
  mySerial.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);                 // the GPRS baud rate    
}   

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

makes use of software serial but mega 2560 cannot use software serial on pin 2, as in the arduino reference, thus I changed the pins to 50 and 51 and used external female-male headers to connect s_tx to pin 50 "rx" , and s_rx to pin 51 "tx", still no response with the AT command...

code after update is :

#include <SoftwareSerial.h>   
SoftwareSerial mySerial(50, 51);   
void setup() {   
  mySerial.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);                 // the GPRS baud rate   
}

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

Note that I am using the Arduino IDE serial monitor.

1 Answer 1

1

Try to connect "Pin RX on Mega to Pin RX on Shield" an "Pin TX on Mega to Pin TX on Shield":

  • Pin 50 (Rx) on Mega <==> Pin 2 GSM Rx on Shield
  • Pin 51 (Tx) on Mega <==> Pin 3 GSM Tx on Shield

I use an Geeetech Shield with a Mega 2560 and connect RX to Rx and TX to TX. Works fine.

Another solution is to use Serial1 instead of using SoftwareSerial ...

First connect:

  • Pin 19 (Rx1) on Mega <==> Pin 2 GSM Rx on Shield
  • Pin 18 (Tx1) on Mega <==> Pin 3 GSM Tx on Shield

    //Serial Relay
    unsigned char buffer[64];  // buffer array for data receive over serial port
    int count=0;               // counter for buffer array

void setup() { Serial1.begin(19200); Serial.begin(19200); } void loop() { if (Serial1.available()) { while(Serial1.available()) { buffer[count++]=Serial1.read(); if(count == 64)break; } Serial.write(buffer,count); clearBufferArray(); count = 0; } if (Serial.available()) Serial1.write(Serial.read()); } void clearBufferArray() { for (int i=0; i<count;i++) { buffer[i]=NULL; } }

You can use a Arduino IDE's Serial Monitor, Serial Terminals(sscom32) or Bray++ Terminal to send AT commands to the Shield, communicate with it.

I hope this information is helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.