The Python software library designed to work with OpenBCI hardware.
Latest commit 28d6c23 Aug 8, 2016 @gabrielibagon gabrielibagon committed on GitHub fixed function call within print_register_settings


The Python software library designed to work with OpenBCI hardware.

Please direct any questions, suggestions and bug reports to the github repo at:


NOTE: For comprehensive list see requirments.txt: (

OpenBCI 8 and 32 bit board with 8 or 16 channels.

This library includes the main open_bci_v3 class definition that instantiates an OpenBCI Board object. This object will initialize communication with the board and get the environment ready for data streaming. This library is designed to work with iOS and Linux distributions. To use a Windows OS, change the init function in to establish a serial connection in Windows.

For additional details on connecting your board visit:


This python code is meant to be used by people familiar with python and programming in general. It's purpose is to allow for programmers to interface with OpenBCI technology directly, both to acquire data and to write programs that can use that data on a live setting, using python.

If this is not what you are looking for, you can visit and browse other OpenBCI software that will fit your needs.


Basic usage

The startStreaming function of the Board object takes a callback function and begins streaming data from the board. Each packet it receives is then parsed as an OpenBCISample which is passed to the callback function as an argument.

OpenBCISample members: -id: int from 0-255. Used to tell if packets were skipped.

-channel_data: 8 int array with current voltage value of each channel (1-8)

-aux_data: 3 int array with current auxiliary data. (0s by default)

This code provides a simple user interface (called to handle various plugins and communicate with the board. To use it, connect the board to your computer using the dongle (see for details).

Then simply run the code given as an argument the port your board is connected to: Ex Linux:

$python -p /dev/ttyUSB0

The program should establish a serial connection and reset the board to default settings. When a '-->' appears, you can type a character (character map that will be sent to the board using ser.write. This allows you to change the settings on the board.

A good first test is to try is to type '?':

--> ?

This should output the current configuration settings on the board.

Another test would be to change the board settings so that all the pins in the board are internally connected to a test (square) wave. To do this, type:

--> [

Alternatively, there are 6 test signals pre configured:

--> /test1 (connect all pins to ground)

--> /test2 (connect all pins to vcc)

--> /test3 (Connecting pins to low frequency 1x amp signal)

--> /test4 (Connecting pins to high frequency 1x amp signal)

--> /test5 (Connecting pins to low frequency 2x amp signal)

--> /test6 (Connecting pins to high frequency 2x amp signal)

The / is used in the interface to execute a pre-configured command. Writing anything without a preceding '/' will automatically write those characters, one by one, to the board.

For example, writing

-->x3020000X will do the following:

‘x’ enters Channel Settings mode. Channel 3 is set up to be powered up, with gain of 2, normal input, removed from BIAS generation, removed from SRB2, removed from SRB1. The final ‘X’ latches the settings to the ADS1299 channel settings register.

Pre-configured commands that use the / prefix are:

test (As explained above)

--> /test4

start selected plugins (see below)

--> /start

Adding the argument "T:number" will set a timeout on the start command.

--> /start T:5

Stop the steam to issue new commands

--> /stop

Useful commands:

Writting to SD card a high frequency square wave (test5) for 3 seconds:

$ python -p /dev/ttyUSB0
User serial interface enabled...
Connecting to  /dev/ttyUSB0
Serial established...
View command map at
Type start to run. Type /exit to exit.

OpenBCI V3 8bit Board
Setting ADS1299 Channel Values
ADS1299 Device ID: 0x3E
LIS3DH Device ID: 0x33
Free RAM: 447
--> /test5
Warning: Connecting pins to high frequency 2x amp signal

--> a
Corresponding SD file OBCI_18.TXT$$$
--> /start T:3


When writing to the board and expecting a response, give the board a second. It sometimes lags and requires the user to hit enter on the script until you get a response.


Use plugins

Select the print plugin:

$python -p /dev/ttyUSB0 --add print

Plugin with optional parameter:

$python -p /dev/ttyUSB0 --add csv_collect record.csv

Select several plugins, e.g. streaming to OSC and displaying effective sample rate:

$python -p /dev/ttyUSB0 --add streamer_osc --add sample_rate

Note: type /start to launch the selected plugins.

Create new plugins

Add new functionalities to by creating new scripts inside the plugins folder. You class must inherit from yapsy.IPlugin, see below a minimal example with print plugin:

    import plugin_interface as plugintypes

    class PluginPrint(plugintypes.IPluginExtended):
        def activate(self):
            print "Print activated"

        def deactivate(self):
            print "Goodbye"

        def show_help(self):
            print "I do not need any parameter, just printing stuff."

        # called with each new sample
        def __call__(self, sample):
            print "----------------"
            print("%f" %(
            print sample.channel_data
            print sample.aux_data

Describe your plugin with a corresponding print.yapsy-plugin:

    Name = print
    Module = print

    Author = Various
    Version = 0.1
    Description = Print board values on stdout

You're done, your plugin should be automatically detected by

Existing plugins

  • print: Display sample values -- verbose output!

  • csv_collect: Export data to a csv file.

  • sample_rate: Print effective sampling rate averaged over XX seconds (default: 10).

  • streamer_tcp: Acts as a TCP server, using a "raw" protocol to send value.

    • The stream can be acquired with OpenViBE acquisition server, selecting telnet, big endian, float 32 bits, forcing 250 sampling rate (125 if daisy mode is used).
    • Default IP: localhost, default port: 12345
  • streamer_osc: Data is sent through OSC (UDP layer).

    • Default IP: localhost, default port: 12345, default stream name: /openbci
    • Requires pyosc. On linux type either pip install --pre pyosc as root, or pip install --pre --user.
  • udp_server: Very simple UDP server that sends data as json. Made to work with:

    • Default IP:, default port: 8888
  • streamer_lsl: Data is sent through LSL.

Tip: Type python --list to list available plugins and python --help [plugin_name] to get more information.


In the scripts folder you will find code snippets that use directly the OpenBCIBoard class from

Note: copy there if you want to run the code -- no proper package yet.

  • minimal example, printing values.
  • a version of a TCP streaming server that somehow oversamples OpenBCI from 250 to 256Hz.
  • DEPRECATED (Use Plugin): see for implementation example.