Enabling UART2 as described in this post disables BELA’s analog inputs. Other UART interfaces might be fine (untested).

How to connect a UART serial interface to a BELA-enabled BeagleBone Black. As a sensor source, I used a PSoC4 chip that is programmed to capture six capacitively active areas and send their capacity values over a serial connection to the BeagleBone.

Hardware used in this post:

Setting up the serial port Link to heading

The BeagleBone has six on-board serial ports. Only /dev/ttyO0 is enabled by default, and it is coupled to the serial console (for the debug connector). All other serial ports must be enabled before they can be used.

To enable them on a BeagleBone Black, rev C (BB-UART1, BB-UART2. BB-UART4, BB-UART5):

  • Open the file /boot/uboot/uEnv.txt in an editor (vim/nano/pico)
  • If the key capemgr.enable_partno is not yet there, add it, otherwise add the ports you want to enable (comma separated):

For only UART2 enabled, the optargs variable on a BELA-equipped board looks like this:

optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN capemgr.enable_partno=BB-BONE-BAREAUDI,BB-SPIDEV0,BB-UART2

After saving, reboot the board. The TTY-port should be available then.

bela$ ls -l /dev/ttyO*
crw-rw---- 1 root tty     248, 0 Aug 26  2013 /dev/ttyO0
crw-rw---T 1 root dialout 248, 1 Jan  1  2000 /dev/ttyO1
crw-rw---T 1 root dialout 248, 2 Jan  1  2000 /dev/ttyO2

Connect serial source Link to heading

In this example, the sensor source is a PSoC4 chip programmed to capture six capacity sensors and send the measurements over a serial port. It is connected to the board as shown in the figure below. If a bi-directional communication is needed, connect the RX pin of your sensor to pin 21 GPIO_03, next to the receiving pin of the BeagleBone Black.

To see incoming data run

bela$ screen -S serial /dev/ttyO2 115200

To disconnect type <ctrl>-a d. Quitting the session is possible with

bela$ screen -X -S serial quit

SuperCollider Link to heading

I captured the serial data with SuperCollider running directly on the board. The below script does this for you. It needs the class extension ‘CapSerial’ which I will make available soon via the SuperCollider Quarks system.

Run the script with

bela$ sclang -D capsenseExample.scd
s = Server.default;

s.options.numAnalogInChannels = 8;
s.options.numAnalogOutChannels = 8;
s.options.numDigitalChannels = 16;

s.options.blockSize = 16;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;

q = ();

// q.device = "/dev/tty.usbmodem1421";
q.device = "/dev/ttyO2";
q.serial = SerialPort(q.device,
  baudrate: 115200,
  databits: 8,
  stopbit: 1,
  parity: nil,
q.caps = CapSerial(q.serial);

  "Server Booted.".inform;

  SynthDef(\aaa, {
    var freqs = \freqs.kr([0, 0, 0, 0, 0, 0]);
    var amps  = \freqs.kr([0, 0, 0, 0, 0, 0]);
    Out.ar(0, Splay.ar(SinOscFB.ar(
      freqs * [1, 2, 3, 4, 5, 6],
      // amps,
      // amps
    )) * 0.5);
  q.mySynth = Synth(\aaa);

  q.caps.capAction = {|vals|
    // vals.postln;
    q.mySynth .setn(
      \freqs, vals.linexp(0, 1, 100, 800),
      \amps, vals