Skip to content

API Reference

Creates a board handle. Does not open a connection or allocate resources yet.

board = BoardShim(BoardIds.NEUROPAWN_KNIGHT_BOARD, params)

Opens the serial connection to the board and allocates BrainFlow’s internal resources. Must be called before start_stream(). Raises an exception if the port cannot be opened or the board is not detected.

board.prepare_session()

Starts the internal ring buffer and begins reading packets from the board. buffer_size is the number of samples the buffer can hold before wrapping — 450000 is sufficient for most use cases.

board.start_stream(450000)

After calling start_stream(), wait at least 2 seconds before sending channel commands to let the board stabilise.


Sends an ASCII command string to the board at runtime. Used to enable channels, set gain, and configure RLD. See the Command Set for all available commands.

board.config_board("chon_1_12") # enable channel 1 at gain 12
board.config_board("rldadd_1") # add channel 1 to RLD

Returns all samples currently in the ring buffer as a 2D NumPy array, then clears the buffer. Rows are data channels; columns are samples ordered oldest to newest.

data = board.get_board_data()
# shape → (num_rows, num_samples)

Use this for one-shot capture, or when you want to process exactly what has accumulated since the last call.


Returns up to num_samples of the most recent data without removing it from the buffer. Ideal for real-time processing loops where you want a sliding window of the latest signal.

data = board.get_current_board_data(sampling_rate * 2) # last 2 seconds

get_eeg_channels(board_id) / get_exg_channels(board_id)

Section titled “get_eeg_channels(board_id) / get_exg_channels(board_id)”

Returns the row indices in the data array that correspond to EEG/ExG channels. Use these to index into get_board_data() output without hardcoding row numbers.

eeg_channels = BoardShim.get_eeg_channels(BoardIds.NEUROPAWN_KNIGHT_BOARD)
eeg_data = data[eeg_channels, :] # shape: (8, num_samples), values in µV

Returns the board’s sampling rate in samples per second.

sampling_rate = BoardShim.get_sampling_rate(BoardIds.NEUROPAWN_KNIGHT_BOARD)
# → 125

Stops reading from the board and halts the ring buffer. The session stays open — you can call start_stream() again without re-running prepare_session().

board.stop_stream()

Closes the serial connection and frees all resources allocated by prepare_session(). Always call this when you are finished with the board.

board.release_session()