4
\$\begingroup\$

I have a microcontroller(arduino) connected via its serial output(RX/TX) to a bluetooth module. i want to be able to program the microcontroller when the two are still connected but unless i disconnect controller RX the program will not upload. Question: is it possible to use a transistor to act as a switch between controller RX and bluetooth TX? my attempts have been unsuccessful so far...thanks.

\$\endgroup\$
5
  • 4
    \$\begingroup\$ Would you mind showing us the particular attempts that you tried, so that we can try to help you revise them to work? \$\endgroup\$ – nanofarad Sep 25 '18 at 17:00
  • \$\begingroup\$ I think an analog switch is more in-line with what you want: en.wikipedia.org/wiki/Analogue_switch . It's made up of FETs. \$\endgroup\$ – DerStrom8 Sep 25 '18 at 17:12
  • \$\begingroup\$ with the base as the enable/disable pin i have tried collector to arduino RX and emitter to bluetooth TX and vice verse. i have heard of those analogue switches before but was interested if it was possible to accomplish this with a single transistor.... \$\endgroup\$ – user2105725 Sep 25 '18 at 17:27
  • 1
    \$\begingroup\$ Also: nearly all Arduinos are capable of supporting more than one serial line, if not in hardware then in software. Which Arduino do you have? Do you have any spare lines? \$\endgroup\$ – Reinderien Sep 25 '18 at 18:20
  • \$\begingroup\$ i am using an atmega328p on a breadboard. i dont beleive this chip has 2 serial lines...software serial is not preferable as it conflicts with the servo library which i am using (its a fairly complex circuit in all) \$\endgroup\$ – user2105725 Sep 25 '18 at 19:26
4
\$\begingroup\$

This would work well, MAX4544. Have the default position be COM to NC with a pulldown on IN, when the Arduino sketch wakes up it can drive IN to High to connect COM to NO and enable the BT connection.

https://datasheets.maximintegrated.com/en/ds/MAX4541-MAX4544.pdf

Or one of this if you want to switch both in the same package

https://datasheets.maximintegrated.com/en/ds/MAX4528.pdf

\$\endgroup\$
1
  • \$\begingroup\$ With this maybe you can detect when USB power is present and do the switching (either through hardware or software) to disable your BT communication. If you're using a normal arduino you can take a look at this link [forum.arduino.cc/index.php?topic=120693.0 ] on how to detect power presence from the USB port \$\endgroup\$ – Zy Gan Sep 26 '18 at 2:39
4
\$\begingroup\$

The easiest solution IME to this problem is to avoid it entirely: most arduino boards have a header on them that can be used to connect an AVRisp programmer device, which results in not needing to use the serial interface for programming. The devices are cheap (there are very low cost clones on eBay) and the arduino IDE supports using them. Doing so also allows you to overwrite the arduino boot loader, which can give you a small amount of extra storage for your program, which I often find handy.

\$\endgroup\$
2
  • \$\begingroup\$ thanks for this but i would like to use a single interface for charging, programming and sending commands via serial. \$\endgroup\$ – user2105725 Sep 25 '18 at 19:25
  • \$\begingroup\$ @user2105725 How will you indicate what state the bus needs to be in? If you do not use a timeout (similar to the built in bootloader) it will Most likely be by inventing some kind of ad-hoc side channel. I.e. A second interface! This is more error prone than using dedicated and appropriate interfaces for the individual tasks. If your circuit is complex this extra level of separation takes care of lots of error-prone details and code associated with multiplexing serial communications with multiple "Masters" \$\endgroup\$ – crasic Sep 25 '18 at 23:06
1
\$\begingroup\$

The device which channels two or more signals into the same line is called a multiplexer. You can either get one in IC form, implement it with logic gates, or implement it with transistors.

If you can make sure that both sources don't ever transmit data at the same time, you can use the fact that UART has idle level of logical '1' to simplify the circuit to a single AND gate, which can be reasonably implemented with transistors:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
  • \$\begingroup\$ What is the reason for R4 and R5? \$\endgroup\$ – amI Sep 26 '18 at 3:55
  • \$\begingroup\$ @aml You're right, those can be safety omitted \$\endgroup\$ – Dmitry Grigoryev Sep 26 '18 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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