Arduino Multiple Software Serial Ports And Cables

  1. Software Serial Finder
  2. Free Software Serial Numbers

I am using an arduino ethernet. The devices I am trying to get data from include a GPS and an IMU both from sparkfun. I can get data from either devices using just on software serial port but as soon as I add the second software serial port, neither ports will work. I can't use the hardware serial port because that is being used byt another device. The local port relates to the pc and the remote port relates to the port the arduino will use for serial debug. Please note that some arduino boards have a single hardware Serial port, such as the Arduino Uno. Others such as the Leonardo have Serial, Serial1 and some such as the mega2560 have Serial,Serial1-4. SoftwareSerial Library Download: SoftwareSerial is included with Arduino Real UART Serial The hardware UART Serial port should always be used, if possible, before considering SoftwareSerial. On Teensy, the hardware UART serial port completely separate from the USB port. On Arduino boards, the main hardware serial port is used for programming and sending messages to the Arduino Serial Monitor.

Use Serial Communications with Arduino Hardware

Arduino® hardware has serial ports, also known as UARTs,that can communicate with other devices that have serial interfaces.

Hardware

You can use serial port 0 to communicate with other devicesthat have serial ports, or to communicate with a computer over theUSB port. Each serial port supports one Serial Transmit and one SerialReceive block, one block per pin. You can run your model in the Externalmode for all the Arduino boards.To know pin mapping for different Arduino boards,see Pin Mapping Table in: Pin Mapping on Arduino Blocks.

Arduino Multiple Software Serial Ports And Cables

Warning

Do not connect the serial port pins to an RS-232 serial interface,such as the DE-9M connector on a computer, without limiting the voltage.The RS-232 standard allows higher voltages that can damage your hardware.For details, read the documentation for your Arduino hardware.

Transmit Serial Data

Software Serial Finder

To transmit data through a serial port or USB port on the Arduinohardware:

  1. Add the Serial Transmit block to your model.

  2. Connect a data source to the block input on the SerialTransmit block.

    If the data type is not uint8, use a Data Type Conversion blockto convert it to uint8.

  3. In the Arduino Serial Transmit block,select a Port number.

  4. Click the Tools menu in the model, and select Run on Target HardwareOptions.

    In the Configuration Parameters dialog that opens, on the HardwareImplementation > Serial port properties, set the baud rate forthe serial port you selected in the Arduino Serial Transmit block.

  5. Connect the appropriate digital transmit pin to thehardware that receives the data.

  6. Run the model, as described in Run Model on Arduino Hardware.

  7. If your model uses the Arduino USB port (Serialport 0) to transmit data to a device that is not your host computer,reconnect the USB cable to that device and press the RESET button.

Receive Serial Data

To receive data through a serial port or USB port on the Arduino hardware:

  1. Add the Serial Receive block to your model.

  2. On the Arduino Serial Receive block,connect the Data block output to a block thatuses the data.

  3. Open the Arduino Serial Receive blockand specify the Port number.

  4. Click the Tools menu inthe model, and select Run on Target Hardware > Options.

    In the Configuration Parameters dialog that opens, on the HardwareImplementation > Serial port properties, set the baud rate forthe serial port you selected in the Arduino Serial Receive block.

  5. Connect the digital receive pin to the hardware thattransmits the data.

  6. Run the model, as described in Run Model on Arduino Hardware.

  7. If your model uses the Arduino USB port (Serialport 0) to receive data from a device that is not your host computer,reconnect the USB cable to that device and press the RESET button.

Related Topics

Active7 years ago
$begingroup$

I have obtain 2 shield from Itead; GPS Shield & IComSat GSM Shield. I have a requirement todevelop an Arduino Uno prototype and used a serial interface to communicate with this two shield. My sketches using SoftwareSerial but it seem not working properly, is there any optimal way to combine these two shield?

Arduino GPS Shieldhttp://imall.iteadstudio.com/im120417017.html

IComSat GSM/GPRS Shieldhttp://imall.iteadstudio.com/im120417009.html

Arduino Multiple Software Serial Ports And Cables
wajatimurwajatimur
$endgroup$

Free Software Serial Numbers

1 Answer

$begingroup$

Are you running afoul of any of the restrictions of Software Serial?

Arduino
  • If using multiple software serial ports, only one can receive data at a time.
  • Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
  • Not all pins on the Leonardo support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Given that you're using the shields, you'd have trouble with my favorite trick. I've occasionally used relays, analog multiplexers, or transistors to switch the functionality of pins on-the-fly. By using one digital pin to select which serial device you want to talk to, you can have both of your communication pipelines taking place on pins 0 and 1. However, that's not an option with off-the-shelf shields.

user30997user30997
$endgroup$

Not the answer you're looking for? Browse other questions tagged arduinoserialgpsgsm or ask your own question.