Electrical – Switch a custom Arduino between wired and wireless connection

arduinobluetoothuartusb

I have custom 5V 16MHz Arduino that runs grbl and I was hoping to use one of the HC-05 bluetooth modules to control it wirelessly. This Arduino can be connected to a USB port through a FTDI chip. I'd like this to work with either of them and not both of them. This works for the most part and here is the 'truth table' I've experienced:

USB  Bluetooth  Works over  Works over
ON   ON         USB?        Bluetooth?
---  ---------  ----------  ----------
Y    Y          N           Y
Y    N          Y           N
N    Y          N           Y

I'm guessing when both are ON the USB does not work because they both share the same RX and TX lines of the Arduino and it seems priority is being given to the bluetooth connection. Is there a way such that when the USB cable is plugged in to the host PC the bluetooth module cannot be used and priority is given to the wired connection?

Best Answer

Following Chris' suggestions, here is a multiplexer solution that I intend to try out. When the USB is unplugged, the select lines are low and the Y0 lines are selected which is the BT module. When the USB cable is plugged in, the select lines go high and the FTDI chip gets selected. VBUS and 5V are two separate 5V sources. Only the FTDI gets powered from the USB bus.

ADDED: While I was at it, I thought I could turn off and isolate the BT module entirely when the USB is plugged in. Used a p-mosfet which can handle about 130mA which is sufficient since the BT module itself does not consume more than 50mA.

enter image description here