Arduino Two Serial Ports Average ratng: 3,9/5 635 reviews
  1. Arduino Multiple Hardware Serial Ports

Currently the python program must know which port a device (Arduino) is on before Python can communicate the device.

Problem: Whenever the device is plugged out and back in, its COM port changes, so the correct serial port must be given to Python again for it to find the device.

How can Python (using pySerial) automatically search for the correct serial port to use? Is it possible for python to correctly identify the device on a serial port as an Arduino?

NyxynyxNyxynyx

4 Answers

Use the following code to see all the available serial ports:

This gives me the following:

Hi, please is possible modify NewSoftSerial to send two inverting serial signal Tx+ Tx- on two digital pins at the same time? How Serial is Created Now. Luckily, Atmel & Arduino did a really great job with structuring SERCOMs so you can create and assign new ones. You can find the actual code that is used to create the 'Serial' SERCOM in variants.cpp.

To work out if it's an Arduino you could do something like:

Matt WilliamsMatt Williams

Using serial.tools.list_ports.comports, we can find and connect to an arduino with:

If you know you're looking for exactly the same arduino each time, you can filter on p.serial_number instead

Arduino two serial ports
EricEric
Joseph F. MackJoseph F. Mack

Try this code (only for windows users. MAC user can withdraw idea from this concept)

Arduino Multiple Hardware Serial Ports

Pardeep SinghPardeep Singh

Not the answer you're looking for? Browse other questions tagged pythonpython-2.7serial-portarduinopyserial or ask your own question.

Two

I'm using an Arduino mega which has 4 serial ports. On the main serial port continuously sending and receiving data between the Arduino and a computer. The computer is doing some calculations and sending the results back to the arduino.

I'd like to see the data that the Arduino is receiving from the computer but doing a normal Serial.print() will also send that data back to the computer, creating a big endless loop of garbage data.

Is there a way to print to the screen using on of the other serial ports. I'm thinking that I can read/write on port1 and then send the data back to the screen using port2?

JDDJDD

1 Answer

I don't own a Mega myself, so take this with a grain of salt, but as far as i know, the three additional serial ports are not connected to the USB-to-serial port. Serial1-Serial3 can only be used to communicate with other devices by connecting TX(Mega) with RX(device) and vice versa.

Arduino mega multiple serial ports

OK, since i didn't know exactly, i had a look at the Arduino Mega specs.It says:

Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.

Sorry for the bad news.

Klaus-Dieter WarzechaKlaus-Dieter Warzecha

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