Arduino Forum

Using Arduino => Networking, Protocols, and Devices => Topic started by: ningaman151 on Feb 10, 2019, 05:55 pm

Title: 2 devices on one UART
Post by: ningaman151 on Feb 10, 2019, 05:55 pm
I'm currently using a DF player mini in my project, which uses UART, and want to add a display. I came across the nextion displays, but they also use UART. A simple solution to this would be to use hardware serial for one module, and software serial for the other. The issue is I assume there would be some noticeable overhead? What I'm currently thinking, after browsing the internet for a solution, is to use a DPDT switch IC to switch between the devices. I can see some potential issues with this solution such as a module sending data while the other is connected. I could also use another display altogether, I'm not fixed on nextion, but they seem to provide good features in terms of size availability, touch, memory, on board processor, and simple interface.
Title: Re: 2 devices on one UART
Post by: Power_Broker on Feb 10, 2019, 10:22 pm
I'm currently thinking after browsing the internet for a solution is to use a DPDT switch IC to switch between the devices.
I wouldn't do that, there is an easier solution:

If you have an Arduino that has multiple hardware serial ports, just use two of the available ports (one for each device). If you only have one hardware serial port, just use softserial.h to make two software serial ports and keep the hardware serial port for debugging.
Title: Re: 2 devices on one UART
Post by: ningaman151 on Feb 11, 2019, 12:34 am
I wouldn't do that, there is an easier solution:

If you have an Arduino that has multiple hardware serial ports, just use two of the available ports (one for each device). If you only have one hardware serial port, just use softserial.h to make two software serial ports and keep the hardware serial port for debugging.
Currently I am using an arduino nano, therefore 1 hardware serial port. I will try having two software serial ports. Would there be any significant performance cuts or interference with features such as timers using this approach?
Title: Re: 2 devices on one UART
Post by: Power_Broker on Feb 11, 2019, 12:51 am
Would there be any significant performance cuts or interference with features such as timers using this approach?
Probably not any noticeable performance cuts, but it might interfere with using timers (DISCLAIMER: I can't say the timers play nice or not with softserial).

There are several softserial libraries out there that might suit your needs.

Is there any reason you're using a nano? Could you use a Teensy 3.5 or a Mega? What is your project about?
Title: Re: 2 devices on one UART
Post by: adwsystems on Feb 11, 2019, 04:36 pm
I would opt for AltSoftSerial as it is (less) non-blocking. You may likely run into issues using multiple software serial ports, so just don't be surprised.
Title: Re: 2 devices on one UART
Post by: GoForSmoke on Feb 11, 2019, 10:12 pm
Get a display with SPI interface?
Title: Re: 2 devices on one UART
Post by: ningaman151 on Feb 12, 2019, 12:35 am
Get a display with SPI interface?
Could do, and I'm searching around, but nextion seems to be the better out of the lot. Please correct me if I am wrong, and link me a contending display.
Title: Re: 2 devices on one UART
Post by: GoForSmoke on Feb 12, 2019, 01:39 am
There's lots of SPI interface displays to choose from. I have no idea which to get.
Title: Re: 2 devices on one UART
Post by: pert on Feb 12, 2019, 02:11 am
Here's a good description of the most common software serial library options:
https://arduino.stackexchange.com/a/34130 (https://arduino.stackexchange.com/a/34130)