Exploring ESPHOME Sensor Integration and Troubleshooting Tips

Hello ESPHOME enthusiasts! :wave: I’m diving into the world of ESPHOME and have encountered an interesting challenge while trying to add custom sensors to my setup. I wanted to integrate both an uptime sensor and a WiFi signal strength sensor into my ESP32 device. However, my attempts so far have resulted in some perplexing compilation errors. Let me walk you through my journey and perhaps gather some insights or solutions from the community.

My Setup and Attempt

I started by editing the esp32-proxy1.yaml configuration file. Here’s what my setup looks like:

yaml
substitutions:
name: “esp32-proxy1”
packages:
esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/esp32-generic.yaml@main
esphome:
name: ${name}
name_add_mac_suffix: false
api:
encryption:
key: xxx
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
sensor:

  • platform: uptime
    name: Uptime Sensor

I uncommented the sensor section and added the uptime sensor. I also tried adding the wifi_signal sensor but faced compilation errors both ways. The error logs pointed to undefined references related to the sensor functionality, which I found quite puzzling.

The Error Logs

The compilation error logs were quite extensive, but here are some key excerpts:

undefined reference to esphome::sensor::Sensor::has_state() const' undefined reference to esphome::sensor::Sensor::get_unit_of_measurementabi:cxx11
undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()’

These errors suggested that the sensor component wasn’t being properly recognized or linked during the build process. I’m still unclear whether this is a configuration issue, a missing dependency, or perhaps an error in the way I structured the YAML file.

Seeking Solutions

I decided to reach out to the community for help. Here are some questions I have:

  1. Where should additional sensor components be added in ESPHOME? Is there a specific section or file where sensors should be declared to ensure proper linking?
  2. Are there any dependencies or libraries that need to be explicitly included when adding custom sensors? I’m suspecting that some sensor-related libraries might be missing from my configuration.
  3. Could the issue be related to the version of ESPHOME or the toolchain I’m using? I’m currently using esphome version 2023.5.x and the default toolchain provided by PlatformIO.

Community Insights

If anyone has successfully integrated custom sensors into their ESPHOME setup, I’d love to hear about your experiences! What steps did you take to ensure smooth compilation and functionality? Any tips on troubleshooting undefined reference errors would be incredibly helpful.

Final Thoughts

This challenge has been both frustrating and intriguing. I’m determined to crack this and get those sensors up and running. Let’s hope the community can shed some light on this mystery. Happy coding! :rocket: