Beaglebone Black RS232 and UART setup

How to setup the Beaglebone Black RS232 and UART for serial communications.

Overview

Today we are going to be setting up the Beaglebone Black RS232 and the UART ports, giving us the ability of serial communications. This method will work for Beaglebone’s running the Debian or Ubuntu Operating System. We will first set up the UART’s in the uEnv.txt boot file, so the UART’s will automatically be enabled during boot. Second, we will be installing a program called Minicom to test that our UART’s are functioning properly. Concurrently with installing Minicom, we will be wiring up the Beaglebone Black’s UART’s #1 and #2 to use with Minicom to test the functionality. Finally, we will incorporate a RS-232 Interface IC Dual EIA-232 Driver into our circuit, and wiring it up to the Beaglebone Black. The chip that we will be using in our example is a Texas Instruments MAX232IN chip. We will then run the same Minicom commands to ensure proper functionality and wiring of the MAX232 chip.

Usage

RS232 is a serial communications port used to connect devices to a computer. Today, many serial communication devices have been converted to the updated USB standard. However, there are still many devices and uses for the RS232 standard. The RS232 chip that we are using in this post works as a voltage converter. The chip takes in the voltage of your device (ie a 5V signal device), and steps it down to 3.3V, the voltage the UART port on your Beaglebone Black requires.

Parts Needed for this Tutorial

1. Beaglebone Black with Ubuntu or Debian OS.

2. Solderless Breadboard

2. MAX232 chip. I am using Texas Instruments P/N MAX232IN. You can find these online for less than 2 dollars each.

3. Jumper wire kit. We will be using a total of 8 wires in this tutorial.

Section 1: Setting up the UART’s on the Beaglebone Black

2. Using a text editor in your terminal (vi, nano, etc.), edit the following file: /boot/uboot/uEnv.txt

root@beaglebone:~# vi /boot/uboot/uEnv.txt

3. Scroll down until you see this section of lines:

##Example
#cape_enable=capemgr.enable_partno=

NOTE: your line might look like this: #cape_disable=capemgr.disable_partno= . If this is the case, write the code in step 4 below underneath this line, or edit this line to be the exact same as the step 4 code.

4. You have 2 options for this step. They will both work, and it’s just a matter of your personal preference. Option 1. Edit the line of existing code above in step 3 as it is shown below. Option 2. copy and paste the line of code below, underneath the line of code in step 3. In either option, add the line of code below into your boot/uboot/uEnv.txt file.

NOTE: For this tutorial, we are only going to be using UART 1 and UART 2. We therefore do not need to include in the script BB-UART4 or BB-UART5. I just wanted to show how to turn on all 4 UARTs. Also, UART3 is a transmit only UART, and will not turn on via this method.

5. Save and quit the uEnv.txt file. Run the following command in the terminal: ls -l /dev/ttyO* #(Letter O, not zero)

You have now successfully enabled your UART ports, which will automatically enable at boot, until you go into the uEnv.txt file and modify/delete/comment the line we just added.

Section 2: Installing Minicom and testing the functionality of the UARTs.

In this step, we are going to be using Minicom to test the Transmit and Receive UART ports. Minicom is a program that acts as a modem controller, and functions as a terminal emulation program. The first part of this step will be installing Minicom, and the second part will consist of wiring UART1 TXD to UART2 RXD, and UART2 TXD to UART1 RXD.

1. Install Minicom. Below is what you should see after entering the sudo-apt-get install minicom command:

2. We are going to physically wire up the UART ports on the Beaglebone. we are going to connect UART1 TXD (P9_24) to UART2 RXD (P9_22) AND UART2 TXD (P9-21) to UART1 RXD (P9_26). I have included a picture below to visually depict what we are doing.

WARNING: Unplug your Beaglebone Black before plugging any wires into it. Inadvertently putting the wires in the wrong pinhole could lead to damaging your Beaglebone Black.

3. Now we are going to start Minicom. We will need to open up a second terminal so that we can communicate between the two UARTs. First though, we will have to configure Minicom. If you try to run Minicom for the first time, you will get this error:

root@beaglebone:~# minicom
minicom: cannot open /dev/modem: No such file or directory

We instead have to set up our UART devices in Minicom. In the first terminal, we are going to set up Minicom to be UART1. If you recall above, in Step 5 of Section 1, we ran the command ls -l /dev/ttyO* to list the available ttyO devices, aka the UARTs. After we set the device to UART1, we are going to set the baud rate to 9600. This rate can be anything, as long as it is the same rate for both Minicom terminals. On the command line, type the following command:

root@beaglebone:~# minicom -D /dev/ttyO1 -b 9600

In the second terminal, we are going to run the same command, only changing the device from ttyO1 to ttyO2, as shown below:

root@beaglebone:~# minicom -D /dev/ttyO2 -b 9600

Your screen should now resemble something like the screenshot below:

To test that your UART setup is working, type anything into the screen on the left Minicom screen. You should see it print out on the second terminal, such as the screenshot below:

Now try to type something into the right (second) terminal. You should see your text appear on the left (first) screen. If everything works, you have sucessfully set up and tested your UART ports. Next, we will incorporate the MAX232 chip, which you will need for many devices. I am currently using this chipset for the Garmin GPS 15xH/15xL.

Section 3: Incorporating a MAX232 chip into your UART design.

1. Once you have obtained a MAX232 chip, plug it into a breadboard. Make sure that the leads on each side of the chip goes on each side of the channel on the breadboard.

2. Pull up your MAX232 chip’s datasheet, and find the circuit schematic for your chip. The TI chips schematic is shown below. Be advised that I have come across MAX232 chips, made by different manufacturers, that have different pin layouts.

3. Set up the circuit on your breadboard according to your datasheet’s schematic. Note the orientation of your capacitors if you are using electrolytic capacitors. If you are using the TI MAX232IN, or have verified your chip’s pinout is the exact same as the one I am using, you can copy the breadboard layout design below.

3. Open two seperate terminals again, and run Minicom like we did in section 2; one with /dev/ttyO1 set as the device, and the other with /dev/ttyO2 as the set device. Run the same test as you did previously. If you get the same results as before, where you type in one terminal, and it prints in the second terminal, congratulations, you have successfully wired the circuit using a RS232 serial communication chip.

Section 4: Connecting your MAX232 circuit to a RS232 connector.

Now that we have successfully tested our MAX232 circuit, we need to connect it to a RS232 connector for use in a practical situation. For this section, we are going to use a DB9 connector. After searching online and locating the DB9 pinout, we see Pin 2 is the Receive pin (RXD), and Pin 3 is the Transmit pin (TXD). Therefore, we are going to connect pin 14 from the MAX232 chip (T1OUT) to the Transmit pin (Pin 3, TXD) on the DB9 connector, and connect pin 13 from the MAX232 chip (R1IN) to the Receive pin (Pin 2, RXD). Reference the following schematic for a pictorial depiction of how this should be wired up to the DB9 connector.

That’s all for now. You should be able to now plug your MAX232 circuit into a secondary device via the DB9 connector. In a later post, we will be connecting our Beaglebone Black to our HAM Radio via the RS232 communication port located in the back of our radios. Be sure to sign up and leave a comment below on what project you are using the MAX232 circuit on, or a project you would like to see us write a post on.

3,923 Responses to Beaglebone Black RS232 and UART setup

Brian, this was a well written and useful article. However, I couldn’t get the loopback test to work with the 232 chip (the first breadboard diagram). I believe the diagram has the UART2 connections between the BBB and the MAX232 reversed. I’m actually using an old Sipex SP232A I had around, but I think it conforms to the MAX232 pinout. In any case, P9_21 is TX and should be connected to 10 and P9_22 is RX and should be connected to 9. After I connected the pins this way (reversed from the diagram), the loopback works like a charm. Of course, in the final breadboard diagram, it’s only using UART1 for the DB9, so that would work as shown.

Thanks again for posting this. I’m working on connecting an RS232 barcode scanner to my BBB. I don’t have the scanner with me tonight, but I’m now confident it will work when I try it out tomorrow.

[…]Wonderful story, reckoned we could combine a handful of unrelated data, nonetheless really really worth taking a search, whoa did 1 find out about Mid East has got additional problerms at the same time […]

[…]Wonderful story, reckoned we could combine a few unrelated information, nonetheless actually really worth taking a search, whoa did one particular master about Mid East has got extra problerms at the same time […]

[…]Wonderful story, reckoned we could combine a few unrelated information, nevertheless really really worth taking a search, whoa did one particular master about Mid East has got extra problerms as well […]

[…]Wonderful story, reckoned we could combine several unrelated information, nevertheless genuinely really worth taking a search, whoa did a single understand about Mid East has got much more problerms as well […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nonetheless genuinely really worth taking a look, whoa did one particular study about Mid East has got additional problerms also […]

[…]Wonderful story, reckoned we could combine a number of unrelated data, nevertheless seriously really worth taking a appear, whoa did one particular discover about Mid East has got much more problerms too […]

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nonetheless genuinely worth taking a search, whoa did a single study about Mid East has got much more problerms as well […]

[…]Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless actually really worth taking a appear, whoa did one understand about Mid East has got additional problerms also […]

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless actually really worth taking a appear, whoa did one study about Mid East has got more problerms as well […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nonetheless really really worth taking a search, whoa did a single study about Mid East has got additional problerms at the same time […]

[…]Wonderful story, reckoned we could combine a number of unrelated data, nevertheless seriously really worth taking a look, whoa did one particular find out about Mid East has got more problerms at the same time […]

[…]Wonderful story, reckoned we could combine several unrelated information, nevertheless genuinely really worth taking a appear, whoa did a single discover about Mid East has got additional problerms too […]

Wonderful story, reckoned we could combine a few unrelated information, nevertheless genuinely really worth taking a appear, whoa did one particular find out about Mid East has got much more problerms also.

[…]Wonderful story, reckoned we could combine some unrelated information, nevertheless seriously really worth taking a search, whoa did a single study about Mid East has got additional problerms too […]

[…]Wonderful story, reckoned we could combine some unrelated information, nonetheless truly really worth taking a search, whoa did one particular discover about Mid East has got far more problerms too […]

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless really really worth taking a look, whoa did one particular study about Mid East has got far more problerms too […]

[…] Beaglebone black rs232 and uart setup tinkernow. How to setup the beaglebone black rs232 and uart for serial communications. Overview. Today we are going to be setting up the beaglebone black rs232 and the. […]

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless actually really worth taking a appear, whoa did one learn about Mid East has got a lot more problerms at the same time […]

[…]Wonderful story, reckoned we could combine a few unrelated data, nevertheless actually worth taking a search, whoa did one particular learn about Mid East has got more problerms at the same time […]

[…] Beaglebone black rs232 and uart setup tinkernow. How to setup the beaglebone black rs232 and uart for serial communications. Overview. Today we are going to be setting up the beaglebone black rs232 and the. […]

[…]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless actually really worth taking a look, whoa did 1 master about Mid East has got additional problerms at the same time […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nonetheless actually really worth taking a search, whoa did one particular understand about Mid East has got additional problerms as well […]

[…]Wonderful story, reckoned we could combine several unrelated information, nevertheless seriously really worth taking a look, whoa did one particular find out about Mid East has got additional problerms at the same time […]

[…]Wonderful story, reckoned we could combine a few unrelated data, nevertheless seriously worth taking a appear, whoa did one particular understand about Mid East has got additional problerms also […]

[…]Wonderful story, reckoned we could combine a handful of unrelated data, nevertheless truly really worth taking a appear, whoa did a single discover about Mid East has got additional problerms at the same time […]

[…]Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless definitely worth taking a appear, whoa did one particular understand about Mid East has got far more problerms as well […]

[…]Wonderful story, reckoned we could combine a number of unrelated information, nonetheless actually worth taking a look, whoa did a single understand about Mid East has got extra problerms as well […]

[…]Wonderful story, reckoned we could combine a few unrelated information, nonetheless definitely worth taking a search, whoa did a single learn about Mid East has got far more problerms at the same time […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nonetheless genuinely really worth taking a appear, whoa did one particular learn about Mid East has got far more problerms also […]

[…]Wonderful story, reckoned we could combine a number of unrelated information, nevertheless seriously worth taking a search, whoa did one particular study about Mid East has got far more problerms also […]

[…]Wonderful story, reckoned we could combine a handful of unrelated data, nevertheless actually really worth taking a look, whoa did a single find out about Mid East has got extra problerms at the same time […]

[…]Wonderful story, reckoned we could combine a few unrelated information, nonetheless really really worth taking a search, whoa did a single discover about Mid East has got extra problerms as well […]

That is the proper blog for anybody who needs to search out out about this topic. You notice a lot its almost arduous to argue with you (not that I really would need…HaHa). You positively put a new spin on a topic thats been written about for years. Ni…

[…]Wonderful story, reckoned we could combine some unrelated information, nonetheless actually really worth taking a appear, whoa did one study about Mid East has got much more problerms at the same time […]

[…]Wonderful story, reckoned we could combine a number of unrelated data, nonetheless truly really worth taking a appear, whoa did a single find out about Mid East has got more problerms at the same time […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nevertheless seriously really worth taking a search, whoa did a single find out about Mid East has got more problerms also […]

[…]Wonderful story, reckoned we could combine a couple of unrelated information, nevertheless actually really worth taking a appear, whoa did a single find out about Mid East has got much more problerms as well […]

[…]Wonderful story, reckoned we could combine a number of unrelated data, nevertheless seriously really worth taking a look, whoa did one particular master about Mid East has got far more problerms also […]