I implemented this esphome smart meter.
Hardware and code itself are working flawlessly. I did a test run, and the device was online for 3 days without problems. This was a few weeks ago. I now implemented a more permanent solution, but other than changing the battery pack to a power supply, nothing changed.
Since then, the ESP (ESP-01 because it’s smaller) almost never connects to my Wi-Fi. ESPHome states it’s online, but I can’t connect to it, and my router also doesn’t show it. As the device sits two floors below my router, I thought about range issues and tried this antenna mod - nothing changed.
And now my main curious problem: It now almost never connects in my rooms next to the router as well. Sometimes, after a few restarts, it connects but is offline a few seconds/minutes later. I tried using different ESPs and Wemos D1 Minis instead, but the same problem occurs.
ESPHome version: 2024.12.2
wemos code:
external_components:
- source: github://mampfes/esphome_obis_d0
esphome:
name: smart-meter
friendly_name: smart_meter
esp8266:
board: d1_mini
# Enable logging
logger:
level: DEBUG
baud_rate: 0 # disables uart logger, needed to use rx pin
# for initial setup: VERY_VERBOSE
logs:
sml: DEBUG
text_sensor: DEBUG
# Enable Home Assistant API
api:
encryption:
key: "*****"
ota:
- platform: esphome
password: "*****"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.178.103
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.178.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Smart-Meter Fallback Hotspot"
password: !secret wifi_password
captive_portal:
uart:
id: my_uart
rx_pin:
#D7 @ wemos D1 rx
number: D7
inverted: false
baud_rate: 9600
data_bits: 7
parity: EVEN
stop_bits: 1
debug:
obis_d0:
id: my_sm
uart_id: my_uart
optimize_size: true
sensor:
- platform: uptime
name: Uptime
entity_category: DIAGNOSTIC
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
entity_category: DIAGNOSTIC
- platform: obis_d0
name: "Consumed Energy"
obis_d0_id: my_sm
obis_code: "1-0:1.8.0*255"
unit_of_measurement: kWh
accuracy_decimals: 4
state_class: total_increasing
device_class: energy
value_regex: "\\d{6}\\.\\d{8}\\*kWh"
- platform: obis_d0
name: "Provided Energy"
obis_d0_id: my_sm
obis_code: "1-0:2.8.0*255"
unit_of_measurement: kWh
accuracy_decimals: 4
state_class: total_increasing
device_class: energy
value_regex: "\\d{6}\\.\\d{8}\\*kWh"
- platform: obis_d0
name: "Power"
obis_d0_id: my_sm
obis_code: "1-0:16.7.0*255"
unit_of_measurement: W
accuracy_decimals: 2
state_class: measurement
device_class: power
value_regex: "-?\\d{6}\\.\\d{2}\\*W"
ESP-01 code:
external_components:
- source: github://mampfes/esphome_obis_d0
esphome:
name: smart-meter
friendly_name: smart_meter
esp8266:
board: esp01_1m
# Enable logging
logger:
level: DEBUG
baud_rate: 0 # disables uart logger, needed to use rx pin
# for initial setup: VERY_VERBOSE
logs:
sml: DEBUG
text_sensor: DEBUG
# Enable Home Assistant API
api:
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.178.105
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.178.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Smart-Meter Fallback Hotspot"
password: !secret wifi_password
captive_portal:
uart:
id: my_uart
rx_pin:
#D7 GPIO3 @ esp01 rx
number: GPIO3
inverted: false
baud_rate: 9600
data_bits: 7
parity: EVEN
stop_bits: 1
debug:
obis_d0:
id: my_sm
uart_id: my_uart
optimize_size: true
sensor:
- platform: uptime
name: Uptime
entity_category: DIAGNOSTIC
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
entity_category: DIAGNOSTIC
- platform: obis_d0
name: "Consumed Energy"
obis_d0_id: my_sm
obis_code: "1-0:1.8.0*255"
unit_of_measurement: kWh
accuracy_decimals: 4
state_class: total_increasing
device_class: energy
value_regex: "\\d{6}\\.\\d{8}\\*kWh"
- platform: obis_d0
name: "Provided Energy"
obis_d0_id: my_sm
obis_code: "1-0:2.8.0*255"
unit_of_measurement: kWh
accuracy_decimals: 4
state_class: total_increasing
device_class: energy
value_regex: "\\d{6}\\.\\d{8}\\*kWh"
- platform: obis_d0
name: "Power"
obis_d0_id: my_sm
obis_code: "1-0:16.7.0*255"
unit_of_measurement: W
accuracy_decimals: 2
state_class: measurement
device_class: power
value_regex: "-?\\d{6}\\.\\d{2}\\*W"
I implemented the uptime and Wi-Fi strength components later, so unfortunately I don’t have any data from my successful test.
One idea where the problem may come from is that I installed a Wi-Fi mesh repeater, and maybe the ESPs have problems with it. However, I tried unplugging it temporarily, but nothing changed. I use a router and mesh repeater by AVM FRITZ!Box.
I also tried the following Wi-Fi settings:
- ssid: !secret wifi_ssid
password: !secret wifi_password
bssid: "0C:72:74:A4:9A:9A" # Mac adress of router
power_save_mode: none
fast_connect: True
Again, no solution.
I don’t have any ideas left, and what really bogs me is that I have a few other ESPHome devices running without problems.
I appreciate any input!
Thank you, guys!