How do I get the RSSI from an ESP32?

All of my devices to date are based on the Wemos D1 Mini (ESP8266) and I routinely put this into my YAML file for the device:

sensor:
  - platform: wifi_signal
    name: ${friendly_name} WiFi Level
    update_interval: 300s

But if I put this code into the YAML for an ESP32, I get a page of “undefined references”.

So how can I get the RSSI as a sensor from the ESP32?

It works for my ESP32s.

Show the compile logs and serial logs.

Since it won’t compile, there is no serial log.
Here is the compile log. The errors start on line 19.

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/esp32-bluetooth-proxy-45ac90.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-bluetooth-proxy-45ac90 (board: esp32dev; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.40405.230623 (4.4.5) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.7.1 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.4
|-- ArduinoJson @ 6.18.5
|-- Improv @ 1.2.3
Linking .pioenvs/esp32-bluetooth-proxy-45ac90/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection17send_sensor_stateEPNS_6sensor6SensorEf+0x8): undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0x8): undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0xc): undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_state(esphome::sensor::Sensor*, float)':
/data/build/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.cpp:463: undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_info(esphome::sensor::Sensor*)':
/data/build/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.cpp:476: undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/build/esp32-bluetooth-proxy-45ac90/src/esphome/components/api/api_connection.cpp:478: undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/components/web_server/web_server.o: in function `ArduinoJson6185_71::Converter<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void>::toJson(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ArduinoJson6185_71::VariantRef)':
/data/build/esp32-bluetooth-proxy-45ac90/.piolibdeps/esp32-bluetooth-proxy-45ac90/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp:17: undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o:(.literal._Z5setupv+0xd4): undefined reference to `vtable for esphome::wifi_signal::WiFiSignalSensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o:(.literal._Z5setupv+0xd8): undefined reference to `vtable for esphome::wifi_signal::WiFiSignalSensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o:(.literal._Z5setupv+0x134): undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o:(.literal._Z5setupv+0x138): undefined reference to `esphome::sensor::Sensor::set_state_class(esphome::sensor::StateClass)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o:(.literal._Z5setupv+0x140): undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/main.o: in function `setup()':
/data/build/esp32-bluetooth-proxy-45ac90/src/main.cpp:246: undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/build/esp32-bluetooth-proxy-45ac90/src/main.cpp:251: undefined reference to `esphome::sensor::Sensor::set_state_class(esphome::sensor::StateClass)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/build/esp32-bluetooth-proxy-45ac90/src/main.cpp:254: undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/core/controller.o:(.literal._ZN7esphome10Controller16setup_controllerEb+0x8): undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-bluetooth-proxy-45ac90/src/esphome/core/controller.o: in function `esphome::Controller::setup_controller(bool)':
/data/build/esp32-bluetooth-proxy-45ac90/src/esphome/core/controller.cpp:29: undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32-bluetooth-proxy-45ac90/firmware.elf] Error 1
========================= [FAILED] Took 20.35 seconds =========================

Try the arduino framework instead of esp-idf.

Edit: don’t do this for BT proxies. See below.

True.

And which version?

Full YAML? I’m guessing you’re using a specific board variant?

I have the same sensor on all of my boards, including ESP32s which are almost all using the esp-idf framework. I use the esp32dev board type for all of mine.

Which version of what?
ESPHome: 2023.12.5
The module:

substitutions:
  name: esp32-bluetooth-proxy-45ac90
  friendly_name: Bluetooth Proxy 45ac90
packages:
  esphome.bluetooth-proxy: github://esphome/firmware/bluetooth-proxy/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}

api:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

web_server:
  port: 80

sensor:
  - platform: wifi_signal
    name: ${friendly_name} WiFi Level
    update_interval: 10s

I’ve never used the BT Proxy package (and honestly don’t really know why it exists, seems like lots of folks have problems with it). There’s more typing by including it versus just adding it normally. This is what I have in all my BT Proxies (and you don’t even need the active part unless you are connecting to a device that requires an active connection):

bluetooth_proxy:
  active: true

esp32_ble_tracker:

Just don’t include captive portal and DO use the esp-idf framework.

1 Like

What’s the advantage of using the esp-idf framework over the default arduino framework?

It’s strongly encouraged per the BT Proxy docs.

1 Like