Connect Xbox controller to Nvidia Nano/Raspberry Pi/EV3 Mindstorms with Python3

Spread the love



Raspberry Pi

Nvidia Nano

EV3 Mindstorms

Xbox controller

Pre Requisites

SSH with Mobaxterm

Use GUI and Command Line Interface with Linux

Linux Operating System (OS) installed.

Python3 installed.


Clone the repository from Github

sudo git clone

Disable ERTM

For the Xbox controller to maintain the connection, the ERTM will need to be enabled. The temporary solution will be reset when shutdown. The permanent solution will not lose the settings when shutdown.

Temporary ERTM solution.

Enter the command below in terminal to determine if the ‘ETRM’ is disabled. If the value is ‘N’ then enter the following command.

cat /sys/module/bluetooth/parameters/disable_ertm

If the ‘ERTM’ value from above is ‘N’, then run the following command to make it ‘Y’.

You will need to run this command every time you start your Nano/Pi/EV3.

sudo bash -c "echo 1 > /sys/module/bluetooth/parameters/disable_ertm"

Now verify the ‘ERTM’ value has changed to ‘Y’

cat /sys/module/bluetooth/parameters/disable_ertm

Once you have changed the ‘ERTM’ value to ‘Y’, go into the desktop and add the bluetooth controller.

Permanent ERTM solution (Nano/Pi)

This is a permanent solution for Pi and Nano users.

echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf

Connect Xbox using GUI (Nano/Pi)

Exit the command line interface and use the Linux GUI to connect the Xbox controller. In the top left of the screen you will see the icon for wi-fi and bluetooth. Follow the commands and connect your xbox controller. You will need to turn your Xbox controller on.

After pairing, the connection will not be maintained, there is a little bit more work to do.

Connect Xbox to EV3 using menus (EV3)

On the EV3 device, navigate the menu system and connect the Xbox via Bluetooth. Then follow the CLI commands below using your SSH intferace.

Connect thur CLI (Nano/Pi/EV3)

Turn your Xbox controller on and from the command line interface, enter the following commands.

sudo bluetoothctl
agent on
scan on

Locate your device and copy the MAC_ADDRESS


The light on your Xbox controller should now be ON.

Confirm Xbox is connected.

Enter the following commands from terminal.

The Xbox controller will be sending data to the ‘js0’ file and an ‘event’ file.

We need to determine which ‘event’ file the Xbox is using.

Enter the following command to open the event device folder.

cd /dev/input

The Xbox controller is usually the last ‘event’ in the list.

Try the following command for event0, event1.. etc. As you move the Xbox controller the data will fill the screen. Enter ‘Ctrl+C’ to exit.

cat event4

Install EVDEV

Now install ‘evdev’ for Python3 from Terminal.

sudo pip3 install evdev

For more information on evdev, see the PyPi website.

Test your connection

Run the following code and run it from the CLI.


The program will automatically detect the Xbox controller.

Did it work?

If you had an issue, please report it on the our github page.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.