Declare more than 2 pins for arduino

Hi ,

  1. I have one GPS module which is connected to arduino board RX=2 pin TX=3 pin.
  2. One GSM module which is connected to arduino board pin 9[TX of GSM], pin 10 [RX of GSM].

At my sketch I am including the above four pins like below:

#include <SoftwareSerial.h>
SoftwareSerial mygps(3,2)
SoftwareSerial mygsm(10,9)

I am getting compilation error. Am I doing any mistake?

Thanks-
Pokhraj

Missing semicolons

Do you intend to listen to the GPS or the GSM? Both is the wrong answer. Only one instance of SoftwareSerial can listen at a time. Data sent to the pins that the other instance is monitoring evaporates in the ether.

I am listening from GSM . I want to send the NMEA data received from GPS by using GSM shield to the TCP server.

Please advice.

Thanks-
Pokhraj

I am listening from GSM . I want to send the NMEA data received from GPS by using GSM shield to the TCP server.

If you are listening to the GSM, and it receives a request for GPS data, you will have no data from the GPS to give it.

You REALLY need an Arduino with multiple hardware serial ports. One for the GPS, one for the GSM, and one for debugging. That means a Mega or a Due.

I found the information under the "Serial Port Options" section of this page helpful:
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html