I like to make a switch between the uart signal lines. The switch should be operated with an output pin of an Arduino.
In this way I want to block or open the serial connection to the Arduino.
Could i use a NPN or PNP transistor and make this into a switch? I wonder if this will work because a the uart signal is only a very small amount of current and most of the time NPN and PNP transistors are used to switch larger loads.
Thanks
Edit:
Ok so i think my below schematic should do what i want.
For resistor 2 i would pick a 330ohms? 0.16mah at 5v?
What would i make R1 and anyone any objections?
For as i gather it, if i make the Arduino pin high, it can source current for the circuit and af the TX is high it will make RX high as well.
1 have 1 serial connection and i need to control 2 Arduino pro's. So i need to cut of the serial connection between 1 of them.
1 of the Arduino's is sending DMX signals over the same UART, the other is maintaining a serial connection.
In this state i need to break the connection between Arduino 1 and 2. So dmx is not interfering with the serial.
In case i want to upload a new sketch to the Arduino 2 (dmx) i send a command to Arduino 1 and it will tell arduino 2 to stop and wait for a new sketch. In this case i need to reconnect the Serial connection.
So basically i need a relay, but I do not like the idea of bounce when it connects.
As I said, RTL - like your circuit - is what you do not want to use!
You need to decide which is the desired "idle" state of your serial link. Usually it is HIGH, so you want an OR gate which will be held high when either input is high, so you could use a 74HC4072 (quad OR gate).
They are however, not as common as a 74HC00 quad NAND gate in which you can use two of the gates - you feed your serial line into both inputs of the first gate tied together, its output to one input of the second gate; then when the second input of that gate is HIGH the output follows the input, when it is LOW, the output is held HIGH.
The only resistor you might need is a pull-down on that second gate input (47k) so that it is held off when the Arduino is in reset.
(Could not for the life of me find a diagram of this on Google!)
But, if you want to control it from the Arduino itself, why not simply call Serial.end()? This disables the serial on the pins just making them harmless inputs.
And by the way, if you add 2 diodes to the Arduino's TX lines and a pull up at the RX it's just fine to connect multiple Serial devices You only have to decide whether or not to do something with the serial data and time when it's save to sent data to the PC/host. Because only one Arduino can transmit at the same time...
I control from within the Arduino's who listens to whatever is said on the Serial.
using Serial.end and Serial.peek
The issue is that Arduino 2 is sending DMX, this is interfering with the Serial. So I want to be able to close off(hardware way) the serial connection between the 2.
I understand my proposal does not work as it will hold the line LOW.
I'm placing a small mechanical relay at the moment.
The issue is that Arduino 2 is sending DMX, this is interfering with the Serial. So I want to be able to close off(hardware way) the serial connection between the 2.
You might explain what that is about. You probably could use 74HC4051 multiplex chip to act as a line switch.