SoftwareSerial Rx and Tx in the same pin

Could be possible to use same pin for Rx and Tx over the SoftwareSerial ? Of course it will operate in half-duplex mode.

Not with an off-shelf implementation.
You’d have to create a new protocol, specific to your project that handshakes and switches the pin control on some predefined rules & timeouts.

Not a trivial project, and very dependent on the processor being used.

Go for a more capable processor with more hardware UARTs, or an external hardware UART over I2C or SPI.

The SoftwareSerial library can not do that as it is. The TX pin is always set as output and the RX pin is always set as input.
You would have to change the library, so that the pin changes to a input pin after the writing has finished. That is not easy to do, since the code is optimized to get the right timing.
There might be an other timing issue, because writing disables the interrupts which are needed to read the input.

Of course, extra hardware (diodes and resistors) are needed to avoid that multiple boards are sending at the same time, causing a short circuit on the data line.
There is a solution for that, by using the pin as a open-drain pin. Only write a '0' as output low, and keep a '1' as input high.

It is a interesting question. If there was a "question of the month" award, then you would win it :trophy:

There are solutions. The RS-485 is a good bus. The "VirtualWire" or "RadioHead in ASK mode" can use anything: a wire, a wireless module, light, and more.

I could compile without errors to Arduino Uno the folow statment:

SoftwareSerial Portone(13, 13); // rx,tx ports

But I have not tested comunication yet. Protocol should not be a problem as one end will be master and other slave. Then there are no chance for collisions. A series resistor at both ends also help to protect the pins. My doubt is if it will work in the SoftSerial and if someone already have done. I have made this for PIC processors using PicBasic Pro compiler and it works fine. PIC processors also allow setup pins as open collector .

You should be able to do it, given pull-up resistors and switching the port between INPUT (input mode, or output IDLE or HIGH) and OUTPUT LOW (effectively, implementing "open collector."
But I don't know if any of the the current SW Serial libraries already support this.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.