Guys,
Long time ago with the assistance of community I had achieved to setup an ESP32 project for measuring
1)the level of my storage water tank, converting to liters and percentage of capacity and
2) the temperature of solar panel and boiler hot water via 3x dallas sensors.
It was working quite good, In general I was satisfied with performance of ultrasound measurements although in higher distance it was problematic in the sense of accuracy.
Dallas sensors were fine, performing well and I wasn’t thinking to touch it ever!
Few months ago, after an update of ESPhome noticed that sensors are not providing data anymore and when trying to update or to reboot, it was coming an error of
INFO ESPHome 2025.3.2
INFO Reading configuration /config/esphome/esp32-sensors.yaml…
Failed configsensor.custom: [source /config/esphome/esp32-sensors.yaml:24]
The “custom” component has been removed. Consider conversion to an external component.
Contributing — ESPHome.
Presently my board, named as “ESP32-sensors” is stucked with ver 2024.12.4 without being able to update to 2025.3.2
or even run it and have measurements.
As I have no idea for whta is talking about or what is the external component or how to compile it,
I’m adressing the situation to the community and seeking for assistance to bring it back to life.
I have (apart the installed ESP32+AJ_SR04M) a spare mini ESP32 that prooved to be… burned or bricked, an ESP32 on the way from china to my home, an extra AJ_SR04M for experiment and quite few time as pensioner.
Here is the esp32-sensors.yaml and the AJ_SR04M_Sensor.h at
esp32-sensors.yaml
esphome:
name: esp32-sensors
friendly_name: ESP32-sensors
includes:
- AJ_SR04M_Sensor.h
esp32:
board: esp32dev
framework:
type: arduino
one_wire:
- platform: gpio
pin: GPIO22
uart:
id: uart_bus
tx_pin: GPIO32
rx_pin: GPIO33
baud_rate: 9600
stop_bits: 1
rx_buffer_size: 4
sensor:
- platform: custom
lambda: |-
auto my_sensor = new AJ_SR04M_Sensor(id(uart_bus));
App.register_component(my_sensor);
return {my_sensor};
sensors:
unit_of_measurement: cm
accuracy_decimals: 1
name: "Tk Ullages"
filters:
- median:
window_size: 19
send_every: 20
send_first_at: 1
- filter_out: nan
- platform: custom
lambda: |-
auto my_sensor = new AJ_SR04M_Sensor(id(uart_bus));
App.register_component(my_sensor);
return {my_sensor};
sensors:
unit_of_measurement: Ltrs
accuracy_decimals: 1
name: "Tk Quantity"
filters:
- lambda: return ((229.0*143.0*(210.0 - x))/1000.0);
- median:
window_size: 29
send_every: 30
send_first_at: 3
- filter_out: nan
- platform: custom
lambda: |-
auto my_sensor = new AJ_SR04M_Sensor(id(uart_bus));
App.register_component(my_sensor);
return {my_sensor};
sensors:
unit_of_measurement: pct%
accuracy_decimals: 1
name: "Tk space pct"
filters:
- lambda: return ((((229.0*143.0*(210.0 - x))/1000.0)/6877.0)*100.0);
- median:
window_size: 29
send_every: 30
send_first_at: 3
- filter_out: nan
- platform: dallas_temp
address: 0xea0722b0dcbabc28
name: "Boiler Hot water"
- platform: dallas_temp
address: 0xd30822b0f48ffd28
name: "Boiler Diesel Inl."
- platform: dallas_temp
address: 0xa90722b0e5ac1328
name: "Boiler Solar Inl."
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
platform: esphome
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
web_server:
port: 80
globals:
- id: last_state
type: float
restore_value: no
initial_value: '0.0'
and AJ_SR04M_Sensor.h from /homeassistant/esphome/
#include "esphome.h"
class AJ_SR04M_Sensor : public PollingComponent, public UARTDevice, public Sensor {
public:
float last_state;
float old_state;
AJ_SR04M_Sensor(UARTComponent *parent) : PollingComponent(5000), UARTDevice(parent) {}
void update() override {
old_state = last_state;
//ESP_LOGD("Start", "Last: %.2f", old_state);
byte frame[4];
int pos = 0;
float value = 0.0;
//write(0x00); // Try this
write(0x01); // Try this
//write(0x55); // Try this AJ_SR04M
//write(0xFF); // Try this DYP-A12BNYTW-V1.0
while (available()) {
frame[pos] = read();
//ESP_LOGD("Hex", "Hex: %X", frame[pos]);
//pos++;
if (pos == 3) {
//ESP_LOGD("Validation", "pos == 4");
//if ((frame[0] == 0xFF) && (frame[4] == 0x00) && (((frame[0] + frame[1] + frame[2]) & 0x00ff) == frame[3])){
if ((frame[0] == 0xFF) && (((frame[0] + frame[1] + frame[2]) & 0x00FF) == frame[3])) {
//ESP_LOGD("Validation", "SUM");
value = ((frame[1] << 8) + frame[2]) / 10.0;
publish_state(value);
last_state = value;
//ESP_LOGD("Start", "Last: %f", last_state);
}
break;
}
pos++;
}
}
};
Does anybody could fix this? or compile this external component for me? or provide any kind of help to set it up in another but functional way?
Thanks!