A tale of two UART devices

Resolving UART bus conflicts and voltage levels

I wanted to record two potential issues I found with using my custom Atmega328p board with onboard USB FT232 when an HC-05 bluetooth module in introduced, in the hope it may well be helpful to others.

Above:  A small piece of perfboard modifies the Bluetooth socket to include a 5V to 3.3V voltage divider on the Bluetooth HC-05 RX line (10 and 20kohm resistors).  The red wire provides a direct line from the Bluetooth HC-05 TX output and the Atmega328p RX input, thereby granting it preference when the HC-05 module is present.  It's not quite clear from the picture, but the RX input pin is bent up out of the socket and a 1k resistor connects the FT232 TX output (see below).



The problems and solutions identified were:

(1) The HC-05 bluetooth module runs on 5V, but the RX and TX are only 3.3V tolerant.  The HC-05's TX line is fine - it will output 3.3V and the AVR RX will receive the signal as logical '1'  the voltage threshold at 5V on the AVR is sometimes quoted as 0.6*Vcc = 3V.  Although in some circuits you'll find 5V run through HC-05's RX directly from the 5V AVR TX line - this WILL break the module over time.  The solution is simple: Take the 5V TX line from the AVR and use a voltage divider to convert to a 3.3V (or thereabouts) level into the HC-05 RX line.  I used 10k and 20k resistors for this.

(2) There is a potential bus conflict - we have the onboard FT232 USB chip always present, and sometimes the Bluetooth module will be present.  If so, the FT232 chip will fight with the Bluetooth module for control of the AVR RX line (FT232/HC-05 common TX line).  As TX/RX is pulled high when idle, when one of the UART devices goes low, a current will flow, potentially damaging the UART devices.  The solution is elegant and simple;  a resistor in series with the AVR RX line and the FT232 TX line allows the device to work ordinarily as a solo device, but to allow the HC-05 Bluetooth device to take charge when it is connected!  The explanation is here.  Arduinos have this resistor in schematics - but I didn't include in my original board design, an omission  on my part. Thankfully bending the AVR RX pin and soldering a 1k resistor in place did the trick - not pretty but functional. The same trick is not strictly necessary for the AVR TX--> UART device RX line, as both devices passively listen to this line and don't cause a conflict in the same manner. That said, it may still be a good idea from a current protection standard point.

Comments

Popular posts from this blog

Getting started with the Pro Micro Arduino Board

Arduino and Raspberry Pi serial communciation