Skip to content

Using PS3/PS4 controller


This guide is outdated and some steps may not work. Will be updated later

PS3 Controller PS4 Controller

Totem robots can be controller using DUALSHOCK™3 and DUALSHOCK™4 wireless controllers. This tutorial contains set-up instructions required to use with Totem products.


How it works

Controller communicates directly with ESP32 MCU using Arduino libraries PS3 Controller Host, PS4Controller. They provide API to read controller buttons, control leds, vibration, etc.

When PS button is pressed, controller tries to connect device with MAC address stored in its memory. ESP32 presents itself with this address and accepts connection. For this reason, a setup of same MAC address for controller and ESP32 is required.

Install library

A third party Arduino library is required to compile the code to use with controller.
Select install instructions depending on controller. Both of them can be installed also.

PS3 Controller Host - DUALSHOCK™3
  1. Click PlatformIO icon in sidebar.
  2. Select MiscellaneousNew Terminal.
  3. Run command inside terminal:
    pio lib --global install
  1. Select SketchInclude LibraryManage Libraries...
  2. In search field type PS3 Controller Host.
  3. Select library PS3 Controller Host from the list and click Install.
  4. Close the window when installation is finished.
PS4Controller - DUALSHOCK™4
  1. Click PlatformIO icon in sidebar.
  2. Select MiscellaneousNew Terminal.
  3. Run command inside terminal:
    pio lib --global install
  1. Download file
  2. Select SketchInclude LibraryAdd .ZIP Library...
  3. Select downloaded file.
  4. Message "Library added to your libraries" should appear.

Configure controller

Stored MAC address can be changed with Sixaxis Pairer Tool using PC.
This is required only once. If controller was connected to other device, this step should be repeated. Follow instructions to change controller address:

Download link: SixaxisPairToolSetup-0.3.1.exe – [Size: 25.6 MB]
Run downloaded file and install.

Download link: sixpair - [Size: 9.4 KB]
This utility requires libusb, which can be downloaded from Choose the binary for your version of OSX.

Download link: SixaxisPairTool – [Size: 55.7 KB]

Required dependencies: qt5, libusb-1.0

You will also need to install the following udev rule file under /etc/udev/rules.d/ to give the app access to the controller: 51-sixaxispairtool.rules

Sixaxis Pair Tool

  1. Run SixaxisPairTool.
  2. Connect controller to PC using USB cable.
  3. SixaxisPairTool should detect connected controller and display current stored MAC address at "Current Master".
  4. In "Change Master" enter 01:02:03:04:05:06
  5. Click Update
  6. "Current Master" will change to "01:02:03:04:05:06"
  7. Address is set. Unplug controller and close the tool.

Run example code

Totem library provides example code to connect and use controllers.

Examples starting with "Controller/PS3_" are made for DUALSHOCK™3 controller.
Examples starting with "Controller/PS4_" are made for DUALSHOCK™4 controller.

Ensure that adddress entered in "Change Master" matches with one provided in PS4.begin("01:02:03:04:05:06").
Press PS button on the controller and after few seconds it should start working.


Sometimes remote does not connect even if MAC address is correct. Erase ESP32 flash and upload it again to resolve issue.
Select PlatformIO → esp32dev → Platform → Erase Flash
or erase_flash.