Hello
I'm using a Siemens TC35 module to send SMS with Arduino. I wrote a simple sketch and it works, i can send SMS with analog data from sensors.
Now i want to know when the modem registers on the network, so first of all i send the "AT+CREG=1" command but....how can i see the modem answer on serial monitor? I tried with the following sketch, but it doesn't work. I don't know how serial communication works...
#include <NewSoftSerial.h>
NewSoftSerial cell(7,8);
char inchar;
void setup(){
 Serial.begin(9600);
 cell.begin(9600);
 delay(1000);
Â
 }
void loop(){
 cell.print("AT+CREG=1\r\n");
Â
 if(cell.available() >0){
  inchar = cell.read();
  Serial.print("Answer1: ");
  Serial.println(inchar);
   }
 delay(2000);
}
The Answer1 should be "OK"...but i can't see neither "Answer1:" nor "OK".
You want to send this over and over? If not, it belongs in setup().
if(cell.available() >0){
Tests how many bytes of data there are to read.
inchar = cell.read();
Reads ONE of them.
The Answer1 should be "OK"
No, it should be 'O' or 'K', assuming that the TC35 responded to the request. You'll have to look at the documentation, and confirm that +CREG=1 is a valid AT command, and that it causes the phone to generate a response.
Once you know whether the phone has registered, why would you want to send the same command again?
Hi,
i don't need to send the command every loop, i put it there to check if it works. After i'll need it to send SMS.
You said that i receive "O" and then "K"...what if i use a cycle to store all chars into an array?
   for(i=0;i<max;i++){
    inchar[i] = cell.read();
   }
The command AT+CREG=1 is correct, i used the same command list to send SMS, and it worked.
Thanks for your reply
Ok i found a solution. The following code may seem stupid, but in this way i understood how serial communication works.
#include <NewSoftSerial.h>
NewSoftSerial cell(7, 8);
int i=0;
void setup()
{
 cell.begin(9600);
 Serial.begin(9600);
 Serial.println("Starting communications...");
 delay(5000);
}
void loop(){
Â
 Serial.print("Loop: ");
 Serial.println(i);      //number of this loop
Â
 cell.print("AT\r\n");   //put here the AT command followed by \r\n
  Â
   while(cell.available()>0){
    Serial.print((char)cell.read()); //reading GSM result
   }
  Â
 Serial.println("End loop.");
 i++;
 delay(3000);
}
There's a problem: during the first loop (loop 0) there's no results, i start receiving data from loop 1. I tried to put a delay(5000) in the setup, but it doesn't change:
(Serial monitor)
Because maybe the modem needs time to start, i don't know. However, ignore that line...
I'm reading the manual, maybe i'll find something useful to solve this problem.
I didn't use this method before because the problem appears only during the first loop.
I solved putting this line after the AT command (n is the loop number):