Baud Rate & Hardware Serial programming steps

Hi frndz,

I'm using the Arduino Uno board and I'm trying to interface a GSM module whose required baud rate is 115200.I tried to run the program with pin 2 as Rx & 3 as Tx with baud rate 115200 but i'm not any response( these pins are software configured for serial communication ).
I tried the same with 9600 baud rate with different GSM module which support 9600 baud rate , it works for that.So i'm confused whether we can use software serial for more 9600 baud rate?? If No, then I hv to go for the UART1 i.e pin 0 & 1 .So I will be glad if you guys can tell me hw to code for UART Rx & Tx pin.

thanks in advance
Santu

Can you please post the code? It would make it much easier to help you if we knew what we were dealing with...

Here is the code :

#include <SoftwareSerial.h> //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h> //Used for string manipulations
char incoming_char=0; //Will hold the incoming character from the Serial Port.
SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
int on=5;

void setup()
{
pinMode(on,OUTPUT);
//Initialize serial ports for communication.
Serial.begin(115200);
cell.begin(115200);
Serial.println("Starting GSM Communication...");
}

void loop()
{

//Making GSM Module ON
delay(500);
digitalWrite(on,HIGH);
delay(7000);
digitalWrite(on,LOW);

while(1)
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}
//If a character is coming from the terminal to the Arduino...
if(Serial.available() >0)
{
incoming_char=Serial.read(); //Get the character coming from the terminal
cell.print(incoming_char); //Send the character to the cellular module.
}
}

}

I'm then using a terminal program to view my serial data.

Thnks for the reply

This is just a guess, but I've had problems like this before with the SoftwareSerial library. Try adding a delay (Try 500ms first then trial and error to get it as down low as possible) between the
if(cell.available() >0)
and

incoming_char=cell.read();    //Get the character from the cellular serial port.

Koop

Do you think the SoftwareSerial will support for 115200 baud rate, the same code worked for me with different GSM module which support only for 9600 baud rate.

I do think that the library will be able to handle that baud rate, so perhaps its the module? If the library works with a 9600 baud rate, it should be able to work with a faster one. Try replacing the 112500 baud GSM module with another one (if you have one).

Koop

Sorry, I only have two GSM module one which support 9600 bps & another 115200bps. Do u think I shd go hardware serial?? Though I'm not sure abt the coding steps for Hardware serial.

Santu

Well whether or not you want to always have the data from the GSM module always go to the terminal program on your computer will determine whether or not you can use hardware serial, because hardware serial can only have one connection at a time (USB counts as one connection)

Koop

Do u think this command works

Serial.begin(115200);

because I hv seen there is another command

Serial1.begin(115200);

for using at high baud rate.

The

Serial1.begin()

command is only used on Arduino Megas, and has nothing to do with baud rates. If you're using an Uno, you should use the

Serial.begin()

command.

Koop

The Serial1.begin() command is only used on Arduino Megas, and has nothing to do with baud rates.

What do you think the argument is, then?

It most certainly DOES have to do with baud rates.

Do u think that the code which I hv posted earlier can be used for all the GSM module ( I found that my 2nd GSM module also support 9600 bps). Becoz its only reading the transmitted data,which i think is common for every GSM module.

Do u think that the code which I hv posted earlier can be used for all the GSM module ( I found that my 2nd GSM module also support 9600 bps). Becoz its only reading the transmitted data,which i think is common for every GSM module.

SoftwareSerial sometimes works at 115200, but, many devices do not play well with software serial at that speed.

The stuff you have before the infinite loop in loop() belongs in setup(). The infinite loop belongs in the bit bucket.

You really need a Mega with it's multiple hardware serial ports, if you are going to communicate with that device at 115200.

PaulS:

The Serial1.begin() command is only used on Arduino Megas, and has nothing to do with baud rates.

What do you think the argument is, then?

It most certainly DOES have to do with baud rates.

Sorry PaulS and santu0111, clearly my statement was far too ambiguous. What I was attempting to say was that when you do or do not use Serial1.begin() has nothing to do with how fast your transmissions are, and only has to do with whether or not you're using a Mega.

The stuff you have before the infinite loop in loop() belongs in setup().

I agree with PaulS. You should put

//Making GSM Module ON
  delay(500);
  digitalWrite(on,HIGH);
  delay(7000);
  digitalWrite(on,LOW);

In the setup() function, because you only want it done once. Even though moving it has nothing to do with the functionality of the code, it just makes it look nicer.

Koop

Hi Guys,

I'm still stuck with the data Tx & Rx part.

while(1)
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

says that i shd receive some data but i'm not receiving anything.Any suggestion on this.

Try adding Serial.println("Incoming Data"); at the start of that if() statement. Then try sending some more data to your Arduino from the GSM module. Watch the terminal program and tell us the results.

Koop

I tried that nothing is displaying in the terminal except "Incoming data".

hi Guys,

while(1)
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

its not going in this loop at all. For testing purpose I just shorted the Tx & Rx , that means watever data I enter shd display in terminal but even this is not working. Wat's going wrong ??? Help me out guys.

says that i shd receive some data

No, it doesn't. It says that IF you receive some data from the cell instance that you should read the characters and send them to the serial port.

It does NOT make data appear. Correctly attaching the device to the Arduino, correctly configuring it, and sending it the proper commands will cause it to respond with data, if appropriate.