I need four serial ports on an Arduino Mega and I would prefer not to use software serial
Is there a safe way to use the default Serial 0 interface whilst retaining the ability to upload software via the USB connection?
I need four serial ports on an Arduino Mega and I would prefer not to use software serial
Is there a safe way to use the default Serial 0 interface whilst retaining the ability to upload software via the USB connection?
Unplug what is plugged on Serial when you upload
Alternatively, go back to the initial requirement and determine how hard it is. Do you really need 4 UARTs?
For instance, if it so happens that two or more devices you talk to over UART are never active at the same time, you could use one UART for both and switch between them with e.g. a pair of CMOS switches.
also you could look at the devices. Sometimes you only need Tx for one and Rx for another and they can be configured at the same baud rate. Then they could sit on the same Serial port.
That's right. It all depends on the overall requirements of the project and the hardware used. So at this point only @lateralleap is in a position to determine an appropriate solution...
Many thanks for your replies, much appreciated
Yes I do need four serial connections and no they cannot be multiplexed
I cannot unplug the serial 0 connection because the system will be inaccessible other than the USB connection for software uploads
Sounds like I will have to use soft serial
Thanks
You're welcome, and good luck!
What. Are the 4 devices?
if you have another Arduino around you can use it to upload the program using ICSP
They are Ardunios connected in a graph type topology. The serial interfaces, which represent top, bottom, left and right, are part of how the physical topology is communicated to the different elements. You can think of it as being like smart Lego bricks that understand the topology of the structure they are building
Thank-you. I had forgotten that option which is a great idea
I will also test software serail and see if it fast and reliable enough
Thanks again for your inputs
So there's a few alternatives to get them to talk to each other, aren't there? Make one a master and the other I2C slaves, or if distance is greater equip them with RF modules, or....
It doesn't have to be hardware UART.
Unfortunately not
I2C would not enable the discovery of the topology and there is also the issue of the addresses having to be predefined. I could use separate I2C networks for each interface and multiplex them but having tested this option a while back, it introduces other issues with lost packets and is more complex
Similiarly with RF, no topology discovery as modules can't detect their nearest neighbours and how they are connected
The special nature of the serial connection is that you can discover who your neighbour is and which of the four physical (and serial) interfaces they are connected to
Hope that makes sense?
Depends on how you design the whole thing. I understand you intend to make the blocks reconfigurable? So a module that is south now, can be moved to north later on, for instance? You could sense where you are using additional GPIO's for instance.
How many blocks will you have in total?
I've used I2C a lot for uC-uC communication and it's perfectly stable given good electrical connections and halfway decent programming. Apparently you did something wrong.
Partly; it seems your current solution stems from a failure to implement or conceptualize other solutions. That's OK, perhaps it should be like that in your project, but from my perspective I don't see the inherent limitations you seem to worry about.
I made this cable and it worked for me: https://www.instructables.com/Arduino-ICSP-Programming-Cable/
Just be sure to upload your sketch using this option:
Many thanks, that's very helpful
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.