Pages: [1]   Go Down
Author Topic: Sending AT commands and reading response  (Read 886 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I have a SM5100b that I have successfully connected to a host manually via the Arduino Serial window and passthrough sketch.

I'm brand new to Arduino coding, but I do have limited coding experience in Matlab primarily. I'd like to write a function that connects the module and reads each of the responses that the Module outputs. Here is what I have, but it's not working:

Code:
#include <string.h>         //Used for string manipulations
char incoming_char=0;      //Will hold the incoming character from the Serial Port.

void setup()
{
  //Initialize serial ports for communication.
  Serial.begin(9600); // for terminal communication
  Serial1.begin(115200); //  for GSM module communication
  Serial.println("Starting SM5100B Communication...");
}

void loop() {
  //If a character comes in from the cellular module...
  
  if(Serial1.available() >0)
  {
    incoming_char=Serial1.read();    //Get the character from the cellular serial port.
    Serial.print(incoming_char);  //Print the incoming character to the terminal.
  }
  
  Serial1.print("AT+SATT=1,0");
  Serial1.print("AT+CGATT?");
 
}

Pretty basic I know but it doesn't return any of the loading data (+SIND: 11 etc) nor the module response after it sends the AT commands. Any help is greatly appreciated.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try :  Serial.print(”AT+CGATT=1");  //GPRS attach
Serial.print(”AT+CGATT=0");  //GPRS detach

read the AT command set data sheet, lots of info to go through, but it will make sense eventually
Logged

http://dduino.blogspot.com all my Arduino/electronic projects!!!

{NEW} Getting Started, Learning, Reference + FAQ PDF!!:
[url]http://ar

UK
Offline Offline
Full Member
***
Karma: 4
Posts: 173
The red wire is ground, right ???
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

shouldn't you be using println instead of print?
Logged

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

How many times per second are you jamming data at the device? How long are you waiting for a reply? The poor module can't get a word in edgewise.
Logged

Pages: [1]   Go Up
Jump to: