arduino rs232 problems with tc35 gsm modem!!

hello,
i have some problems to comunicate arduino with gsm tc35 module...
i use max232 and a serial cable like show the example in:

When i try to comunicate to hyperterminal or another terminal software, the commands are ok!!!!
arduino -> terminal = OK
terminal -> arduino = OK
terminal -> modem = OK
modem -> terminal = OK
arduino -> modem = NOT WORKS (it does not happen anything)

i try with the simple AT command "AT"
the correct string is:

"at\r\n" or in decimal: 65,84,13,10
if i type this into the terminal and send to modem,
the modem respond with a "ok" message

but if
i send this with arduino, the modem not respond...!!!!

what do you think about this????

this is my code to test the connection!!!

char serInString[100];  

int led1 = 2;
int led2 = 13;

void readSerialString (char *strArray) {
    int i = 0;
    if(Serial.available()) {    
       //Serial.print("reading Serial String: ");  //optional: for confirmation
       while (serialAvailable()){            
          strArray[i] = Serial.read();
          
          //if( (strArray[i] == 'K') && (strArray[i-1] == 'O') )
            digitalWrite(led1, HIGH);
          
          i++;
          //Serial.print(strArray[(i-1)]);         //optional: for confirmation
       }
       
       if (strArray[i] != 0) {     
         while(strArray[i] != 0) {
            //Serial.print( strArray[i] );
            strArray[i] = 0;                  // optional: flush the content
            i++;          
         }
       }

       //Serial.println();                          //optional: for confirmation
    }      
}


void printSerialString(char *strArray) {
     int i=0;
     if (strArray[i] != 0) {     
         while(strArray[i] != 0) {
            Serial.print( strArray[i] );
            strArray[i] = 0;                  // optional: flush the content
            i++;          
         }
     }
} 


void setup() {
  
  Serial.begin(9600);


  pinMode(led1, OUTPUT);  // declare LED as output
  pinMode(led2, OUTPUT);  // declare LED as output


}

void loop () {

  readSerialString(serInString);
  
  digitalWrite(led2, HIGH);
  

  Serial.print(65, BYTE); // 'A'  // first way
  Serial.print(84, BYTE); // 'T'
  Serial.print(13, BYTE);
  Serial.print(10, BYTE);
  
  delay(1000);
  Serial.print("at\r\n");  // second way
 
  
  delay(1000);
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);
  delay(1000);
  
}

and this is my schematic of the shield!!!


thanks,

Alex

That readSerialString() function looks a bit wrong to me. For example, this loop might never end:

       if (strArray[i] != 0) {      
         while(strArray[i] != 0) {
            //Serial.print( strArray[i] );
            strArray[i] = 0;                  // optional: flush the content
            i++;          
         }
       }

I would put a similar check write in your loop, say after the Serial.print("at\r\n"). Add:

delay(1000);
if (Serial.available())
  digitalWrite(led2, HIGH);

followed by the delay(1000) and then the switching off of the two LEDs. If that doesn't work, maybe the Arduino serial communication is not configured properly, what parity, # of stop bits, etc. does the modem expect?

Or, just trying giving the modem a command that will make it do something visible, since it can be hard to debug the responses it gives you without the serial port free to talk to the computer.

hello,
the modem works at 9600 or 19200 !!!
not parity and

data: 8
parity: No
stop : 1
debug hardware: No

this is the configuration in the terminal that works...

i see the preference.txt and this is the standard setup of arduino.
This is not the problem...

more sugestions???

thanks

alex

Did you try the suggestions I made for changing the code or sending different commands to the modem?

thanks,
now it's working!!!
there was a problem with the cable and internal conections...

the modem is DCE and the arduino is DCE !!!!! :slight_smile:
for this reason the two DCE units works ok with computer, because this is a DTE !!!
i needed a null modem converter to cross all the cables!!

alex