Arduino Nano esp32 and PS4 controller, verify fails

Hello,
Newbie here. I am trying to connect a ps4 controller to a Nano esp32. I am trying to follow this youtube video from #includeelectronics to get this working. I downloaded the ps4 controller library from juan pablo marquez's github. In the video he link additional board manager url to: "https://dl.espressif.com/dl/package_esp32_index.json" and so I copied that. It seems weird to me because I'm using an arduino nano, not an espressif board; but since I don't know if it matters or not I copied it. Maybe someone can clarify that for me. Anyway, the video then installs the esp32 (espressif) in the board manager. I was going to follow that, but saw that arduino had their own version of esp32 so I installed that. Does that matter if the link and the installed boards are different? Anyway, the video goes on to post this code:

#include "PS4Controller.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"

void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
PS4.begin();
const uint8_t* address = esp_bt_dev_get_address();
char str[100];
sprintf(str, "ESP32's Bluetooth MAC address is - %02x:%02x:%02x:%02x:%02x:%02x", address[0], address[1], address[2], address[3], address[4], address[5]);
Serial.println(str);

}

void loop() {
  // put your main code here, to run repeatedly:

}

Now in the video he uploads this to the board. This fails for me. So I tried to verify the code and get the following error message:
-/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/-
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_disconnect_ind_cback+0x4): undefined reference to L2CA_DisconnectRsp' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_config_ind_cback+0x0): undefined reference to L2CA_ConfigRsp'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_connect_ind_cback+0x8): undefined reference to L2CA_ErtmConnectRsp' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_connect_ind_cback+0xc): undefined reference to L2CA_ConfigReq'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_init_service+0x14): undefined reference to L2CA_Register' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o:(.literal.ps4_l2cap_send_hid+0x18): undefined reference to L2CA_DataWrite'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o: in function ps4_l2cap_disconnect_ind_cback': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:269: undefined reference to L2CA_DisconnectRsp'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o: in function ps4_l2cap_config_ind_cback': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:252: undefined reference to L2CA_ConfigRsp'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o: in function ps4_l2cap_connect_ind_cback': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:186: undefined reference to L2CA_ErtmConnectRsp'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:189: undefined reference to L2CA_ErtmConnectRsp' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:192: undefined reference to L2CA_ConfigReq'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o: in function ps4_l2cap_init_service': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:144: undefined reference to L2CA_Register'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_l2cap.c.o: in function ps4_l2cap_send_hid': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_l2cap.c:115: undefined reference to L2CA_DataWrite'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o:(.literal.sppCallback+0x8): undefined reference to esp_bt_gap_set_scan_mode' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o:(.literal.sppCallback+0xc): undefined reference to esp_spp_start_srv'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o:(.literal.sppInit+0x14): undefined reference to esp_spp_register_callback' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o:(.literal.sppInit+0x18): undefined reference to esp_spp_init'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o: in function sppCallback': c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_spp.c:126: undefined reference to esp_bt_gap_set_scan_mode'
c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_spp.c:127: undefined reference to esp_spp_start_srv' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\libraries\PS4Controller\ps4_spp.c.o: in function sppInit':
c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_spp.c:56: undefined reference to esp_spp_register_callback' c:/users/snapp/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: c:\Users\snapp\Documents\Arduino\libraries\PS4Controller\src/ps4_spp.c:65: undefined reference to esp_spp_init'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
-/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/-

Also when I click the debug button two bubbles popup that say:

  1. Unable to find executable file at C:/Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\My_PS4Controller_to_ESP32.ino.elf.
  2. File not found "executable": "C:/Users\snapp\AppData\Local\Temp\arduino\sketches\DDA3795F080822F040816F62E575CB4F\My_PS4Controller_to_ESP32.ino.elf"

Do you need more info? I would be happy to give more, but being a newbie I'm not sure what else to provide. Can you please help me figure out how to resolve this?

You are using a Nano ESP32

Which board have you got selected in the IDE ?

@UKHeliBob
If I understand your question I have Aduino Nano ESP32 selected.
image

I have made some progress because I just have one error. After reading the README, I discovered that I downloaded the wrong version of espressif boards. I uninstalled the latest version and installed 1.0.3 as stated. I also downloaded a different ps4 controller library from git (his version). So now when I click upload, I still have an error about "No such file or directory for PS4Controller.h" (See below). This doesn't make sense because when I check the library directory for that file, it is there (See 2nd screenshot below). Do you have any ideas as to why it can't find the file?

image

The Nano ESP32 should have been named the Nano ESP32-S3. This an important distinction for Bluetooth because the original ESP32 supports Bluetooth classic and BLE. The ESP32-S3 supports BLE but not classic.

The PS4 controller and many other Bluetooth controllers such as PS5 DualSense require Bluetooth classic so will not work with the ESP32-S3.

One option is to buy a regular ESP32 board.

@customcontroller
Thank you! I need helpful insights like that. I will order the right board asap. I wonder though, will my code still fail to find the ps4controller.h file once I have the right esp32 board?

The PS4-esp32 repo 2 years old and has been archived probably because it is obsolete and the author does not have time to keep it up to date.

The bluepad32 project is being updated. GitHub - ricardoquesada/bluepad32: Bluetooth gamepad support for the ESP32 (mirror).

@customcontroller Thank you for pointing me in the direction of bluepad. At first I didn't understand the flashing process or which boards worked with it. I reached out to Ricardo on discord and he rewrote his readme so an doofus like me could decipher it. What a good dude! Anyway it is working now. Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.