From the sample code
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
What is the difference between, why use 2 types of calls to make AT command calls.
SoftwareSerial mySerial (10,11) mySerial.begin(10,11)
and
Serial.begin(9600)
Edit, this answers my question in my own words based on @jfpoilpret response.
- It is important to initialize both Serial and SoftwareSerial, since SoftwareSerial is used to send the actual commands to the GSM, and Serial is used to
view
all the commands and their responses on the debug port of the GSM - The pins on the GSM and Arduino are used to connect the the 2, and pass on actual commands. While the RS232 is only used for debugging. We can however connect a RS232 to USB connector so as to connect the GSM to the desktop(or laptop)
- The code in the loop is essential to help convert all actual commands to the debugging RS232 port, and the other way around, so as to enable us to use a tool like
cutecom
(on ubuntu) to pass commands to the GSM serial input pins.
Important Note : When using cutecom ensure that you select CR line end to send commands.