Library error for ESP32

Hi,
I am playing around with an ESP32 (LOLIN C3 mini). I was able to get a super simple sketch uploaded eventually (I'm still not sure why its working, but it is lol).

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hello from ESP32");
  delay(1000);

}

After getting that to work, I'm trying to do the tutorial that starts here https://www.youtube.com/watch?v=aM2ktMKAunw
about creating a bluetooth app that turns on LEDs.

This is where I'm having difficulty. When I verify the sketch:

// --------------------------------------------------
//
// Code for control of ESP32 through MIT inventor app (Bluetooth). 
// device used for tests: ESP32-WROOM-32D
// 
// App on phone has three buttons:
// Button 1: 11 for ON and 10 for OFF
// Button 2: 21 for ON and 20 for OFF
// Button 3: 31 for ON and 30 for OFF
//
// Written by mo thunderz (last update: 20.4.2021)
//
// --------------------------------------------------

// this header is needed for Bluetooth Serial -> works ONLY on ESP32
#include "BluetoothSerial.h" 

// init Class:
BluetoothSerial ESP_BT; 

// init PINs: assign any pin on ESP32
int led_pin_1 = 4;
int led_pin_2 = 0;
int led_pin_3 = 2;     // On some ESP32 pin 2 is an internal LED, mine did not have one

// Parameters for Bluetooth interface
int incoming;

void setup() {
  Serial.begin(19200);
  ESP_BT.begin("ESP32_Control"); //Name of your Bluetooth interface -> will show up on your phone

  pinMode (led_pin_1, OUTPUT);
  pinMode (led_pin_2, OUTPUT);
  pinMode (led_pin_3, OUTPUT);
}

void loop() {
  
  // -------------------- Receive Bluetooth signal ----------------------
  if (ESP_BT.available()) 
  {
    incoming = ESP_BT.read(); //Read what we receive 

    // separate button ID from button value -> button ID is 10, 20, 30, etc, value is 1 or 0
    int button = floor(incoming / 10);
    int value = incoming % 10;
    
    switch (button) {
      case 1:  
        Serial.print("Button 1:"); Serial.println(value);
        digitalWrite(led_pin_1, value);
        break;
      case 2:  
        Serial.print("Button 2:"); Serial.println(value);
        digitalWrite(led_pin_2, value);
        break;
      case 3:  
        Serial.print("Button 3:"); Serial.println(value);
        digitalWrite(led_pin_3, value);
        break;
    }
  }
}

I get this error information:

c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function .L0 ': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:715: undefined reference to esp_spp_disconnect'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function _stop_bt': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:716: undefined reference to esp_spp_deinit'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function .L0 ': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:189: undefined reference to esp_spp_write'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:153: undefined reference to esp_bt_gap_set_pin' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:650: undefined reference to esp_bt_gap_register_callback'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function _init_bt': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:658: undefined reference to esp_spp_register_callback'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:666: undefined reference to esp_spp_init' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:688: undefined reference to esp_bt_gap_set_security_param'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:693: undefined reference to esp_bt_gap_set_cod' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function .LVL458':
C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:265: undefined reference to esp_bt_gap_set_scan_mode' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function esp_spp_cb':
C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:271: undefined reference to esp_spp_start_srv' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:283: undefined reference to esp_spp_disconnect'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:364: undefined reference to esp_spp_connect' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:391: undefined reference to esp_spp_disconnect'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function .L0 ': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:126: undefined reference to esp_bt_gap_resolve_eir_data'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function get_name_from_eir': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:130: undefined reference to esp_bt_gap_resolve_eir_data'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function .L0 ': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:456: undefined reference to esp_bt_gap_cancel_discovery'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Temp\arduino-sketch-9A5ABB4C3BD61F8B59B571E01C5C1667\libraries\BluetoothSerial\BluetoothSerial.cpp.o: in function esp_bt_gap_cb': C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:455: undefined reference to esp_spp_start_discovery'
c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:522: undefined reference to esp_bt_gap_pin_reply' c:/users/lisac/appdata/local/arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\lisac\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\BluetoothSerial\src/BluetoothSerial.cpp:530: undefined reference to esp_bt_gap_ssp_confirm_reply'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1

Can anyone help me figure out what is going wrong?
Thanks!

the thread on github states
Bluetooth Serial or SPP (Serial Port Profile) is part of BT 2.1 and uses RFCOMM to connect two peer devices.
It will only work for the ESP32.

ESP32-C3 has only BLE support. There is no SPP in BLE.
Therefore, BluetoothSerial will never work for the C3.

have a look at ESP32-xx_family

well :poop: that sucks. Any idea if there is any other way to control the C3 with a bluetooth app? That was my end goal, so I'm disappointed to hear that it won't work with this example.

thanks so much for your help with pointing that out.

you could attach a HC-05 or HC-06 bluetooth Classic serial module

does MIT inventor suport BLE
if so have a look at File>Examples>ESP32 BLE Arduino>BLE Uart
it provides BLE serial communications, e.g. to the Arduino BLE Terminal app

what exactly do you want to do?

awesome! Thank you :slight_smile:

I have some sketches that I've written for the D1 mini that basically are light shows with the RGB shield. I'd like to be able to control them with the C3 using bluetooth app on a phone, that way I can easily select between the shows without needing to upload to the D1 mini. I played around with the wifi feature of the D1 mini but wasn't satisfied with it. Connecting is kind of a PITA and not as quick as I want to be able to access it.

thanks again for your help :slight_smile:

what language/IDE do you use to program the Android?
I use Java with the Android Studio IDE
have not used the Android BLE Uart for a real application but have used Microchip's Transparent Uart which is similar

Right now I am just using the newest Arduino IDE. I've never tried anything different. Is there one you would recommend?

oh sorry you mean Android not Arduino. I was planning to try the MIT App Inventor like he does in the video i linked above

I'm reading through the BLE documentation. Do you know in my case, would the phone be considered the central device or the peripheral device? The phone would be sending the directive to the C3 mini to turn a certain color.

if I

  1. run the BLE uart on an ESP32
  2. do a scan with the Android BLE terminal app
  3. the app scan finds "UART Service" which I tap to connect too

I can then exchange text between the ESP32 and Android

the question is does MIT App Inventor support BLE?

I'm not sure actually. I'll have to look into that. I haven't got quite that far yet. It's MIT so I imagine it will support BLE but you bring up a good point to look into it!

quick search says yes MIT app inventor works with BLE. However I'm open to other programs if you have a suggestion!

if you have experience with MIT Inventor keep with that
Android Studio is very complex to use and requires a steep learning curve
I can implement prototype Android apps but get specialist developers in to do final products

found example code Adafruit_Android_BLE_UART
on opening the project Android Studio displays
Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.12-all.zip'.

Experimented with MIT app inventor and created a Bluetooth Classic Terminal which communicated using an Android phone with an ESP32 running the Example>Bluetooth Serial>BluetoothToSerialBT code OK - could exchange text between the devices
e.g. Android screenshot

and ESP32 Serial Monitor

06:10:55.704 -> SerialToSerialBT
06:10:56.181 -> The device started, now you can pair it with bluetooth!
06:11:51.637 -> hello ESP32hello from android
06:13:05.292 -> 1234567890

now attempting to communicate using BLE - device scan not working so far

have a look at PushButton in ESP2 sends HIGH/LOW using BLE - it uses an ES32

  1. button connected to pin 12 when pressed lights a LED attached to pin 2 and sends message over BLE to
  2. app on Android phone which displays HIGH or LOW

there is C/C++ source code for the ESP32 and an .aia file for MIT Inventor for the Android
you should be able to adapt this for you application

BLE is much more complex than Bluetooth Classic but seeing that your ESP32 C3 only supports BLE this looks like your only option unless yopu purchase an ESP32 with Bluetooth Classic and BLE

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