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?

  • 5
    \$\begingroup\$ So you have a "custom arduino", and we should guess for you how it was built and what features it has and how to access them? \$\endgroup\$
    – PlasmaHH
    Commented Sep 9, 2016 at 11:54
  • \$\begingroup\$ Its an Arduino Uno R3 clone essentially except that that USB to UART is done via a FT232 FTDI chip rather than the atmega16u2 (I guess its more like the Arduino Nano than the Uno). The board can be programmed via the RX, TX and DTR lines running out of the FTDI chip and using the Arduino IDE with Uno selected as the programmer. The digital outputs are connected as per the grbl's connectivity guide has mentioned in their wiki. \$\endgroup\$ Commented Sep 9, 2016 at 12:13
  • \$\begingroup\$ The Arduino designs typically have a resistor between the USB serial and the MCU to allow something else to drive data in; you seem to want the opposite behavior, which will be difficult - you cannot just move the resistor to the bluetooth unless you can get the USB serial to tristate its TX line when there is no host - you may well end up having to add a multiplexer and logic to control it. \$\endgroup\$ Commented Sep 9, 2016 at 13:17
  • \$\begingroup\$ Thanks @Chris! I'm thinking I could use a MOSFET switch such that when the USB is plugged in supply to the Bluetooth module gets cut off. There is another 5V on board anyway that powers the atmega and the motor driver chips. Possibly something like this- i.imgur.com/DdaJqfo.png \$\endgroup\$ Commented Sep 10, 2016 at 14:38
  • 2
    \$\begingroup\$ De-powering devices is not usually a proper way of de-selecting them - most modern ICs have protection diodes that are stressed if an I/O pin is raised above the supply pin. If you are going to pursue that path anyway, at least place a resistor to limit the current. It's probably better to use an actual multiplexer though. \$\endgroup\$ Commented Sep 10, 2016 at 17:16

3 Answers 3


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

  • \$\begingroup\$ You may not need to switch the Arduino's transmit line if having both interfaces receive its transmissions is acceptable. Also, since the DTR is coupled to reset with a capacitor, you may be able to just use a capacitor for each, if you can be sure that the unused one will not cause spurious reset-inducing transitions. But those are optional simplifications - you can design the board with switches and provide optional bypass paths around them to experiment with. \$\endgroup\$ Commented Sep 11, 2016 at 15:24
  • \$\begingroup\$ Let me experiment with this setup for now. Good point about the DTR being connected to Arduino's RESET via a capacitor. I missed mentioning that the capacitor is present on the Arduino side and the outputs from the FTDI-DTR or the BT-STATE multiplexers eventually connect to one side of that 01.u cap. Thanks again for the idea! \$\endgroup\$ Commented Sep 11, 2016 at 15:48
  • \$\begingroup\$ @electrophile please could you reupload the image? \$\endgroup\$ Commented Dec 11, 2017 at 10:34

When USB cable is plugged into host PC, your port will see VBUS=5V. If no cable, VBUS=0V. You can feed this signal into one of GPIO (with proper voltage translation, resistor divider should be OK), and use the logic signal to switch between USB and BT (turn BT off).

  • \$\begingroup\$ And how do your propose to "turn BT off"? \$\endgroup\$ Commented Sep 10, 2016 at 2:07
  • \$\begingroup\$ I don't know. The OP presented a table making an impression that he has apparently independent control for both interfaces as ON or OFF. Maybe using another GPIO to disable the BT module? \$\endgroup\$ Commented Sep 10, 2016 at 2:38
  • \$\begingroup\$ What OP presented is a table of their experience, which seems to be caused by the resistor in the stock Arduino design, and is contrary to their wishes. \$\endgroup\$ Commented Sep 10, 2016 at 3:17

There is one option also if you want to use two UART in Arduino there are support of Softwareserial() which library help to create you second uart. then you can use both USB and Blutooth in single time and easy way without changes in hardware. please read how o use Softwareserial() library and which pins are supported.

  • \$\begingroup\$ I think I've mentioned that the board runs grbl which connects via the Arduino RX and RX. Also both the FT232 and Bluetooth eventually talk to one program which is grbl. Having two open serial communication methods that can be operated at the same time would be disastrous. This also means that I'll need to tweak the grbl code itself which is not what I want at all. \$\endgroup\$ Commented Sep 12, 2016 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.