Go Down

Topic: 2 devices on one UART (Read 267 times) previous topic - next topic

ningaman151

Feb 10, 2019, 05:55 pm Last Edit: Feb 10, 2019, 10:49 pm by ningaman151
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.

Power_Broker

#1
Feb 10, 2019, 10:22 pm Last Edit: Feb 10, 2019, 10:23 pm by Power_Broker
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.
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

ningaman151

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?

Power_Broker

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?
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

adwsystems

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.

GoForSmoke

Get a display with SPI interface?
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

ningaman151

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.

GoForSmoke

There's lots of SPI interface displays to choose from. I have no idea which to get.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

pert

Here's a good description of the most common software serial library options:
https://arduino.stackexchange.com/a/34130

Go Up