Dual SML Reader with ESP8266 Software UART

Hi there,

i have an ESP8266 with two SML Readers, to read two Power Meters.
Read each Powermeter separately works fine. But when I connect both Powermeters I have the feeling, that there is too much information and nothing is read out right. If I disconnect one of the SML Readers from the Powermeter it works fine.

The Powermeters both send each second the whole data package.

So my best queen would be to read out each Powermeter separately eg Evers 30s or so.

Is the any way in ESPHome to deactivate the UARTs seperatly and reactivate after X seconds / alternating both UARTs?

esphome:
  name: smlreader
esp8266:
  board: d1_mini
  framework:
    version: recommended
# Enable logging
logger:
  #level: VERBOSE
  level: DEBUG
# ENable OTA Updates
ota:
  password: "" 

# Enable Webserver
web_server:
api:

# Enable Wifi
wifi:
  output_power: "8.5db"
  ssid: "xxx"
  password: "xxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "yyyy"
    password: "yyyy"

time:
  - platform: sntp
    id: sntp_time

uart:
  - id: uart_bus1
    tx_pin: GPIO14
    rx_pin: GPIO12
    baud_rate: 9600
  #  debug:
  #    direction: BOTH
  #    dummy_receiver: false
  #    after:
  #      delimiter: "\n"
  #    sequence:
  #      - lambda: UARTDebug::log_string(direction, bytes);
    rx_buffer_size: 2048
    data_bits: 8
    stop_bits: 1
    parity: NONE
  - id: uart_bus2
    tx_pin: GPIO13
    rx_pin: GPIO15
    baud_rate: 9600
  #  debug:
  #    direction: BOTH
  #    dummy_receiver: false
  #    after:
  #      delimiter: "\n"
  #    sequence:
  #      - lambda: UARTDebug::log_string(direction, bytes);
    rx_buffer_size: 2048
    data_bits: 8
    stop_bits: 1
    parity: NONE

sml:
 - id: sml_zwei
   uart_id: uart_bus1
 - id: sml_bezug
   uart_id: uart_bus2
  
sensor:

  - platform: sml
    name: "zwei_bezug"
    id: "zwei_bezug"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    filters:
     - multiply: 0.0001
    accuracy_decimals: 4
    force_update: true
    
  - platform: sml
    name: "zwei_bezugWh"
    id: "zwei_bezugWh"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: Wh
    state_class: total_increasing
    device_class: energy
    filters:
     - multiply: 0.1
    accuracy_decimals: 1
    force_update: true
    
  - platform: sml
    name: "zwei_export"
    id: "zwei_export"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:2.8.0"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    filters:
     - multiply: 0.0001
    accuracy_decimals: 4
    force_update: true

  - platform: sml
    name: "zwei_WhExported"
    id: "zwei_WhExported"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:2.8.0"
    unit_of_measurement: Wh
    state_class: total_increasing
    device_class: energy
    filters:
     - multiply: 0.1
    accuracy_decimals: 1
    force_update: true

  - platform: sml
    name: "bezug_import"
    id: "bezug_import"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    accuracy_decimals: 4
    filters:
     - multiply: 0.0001
    force_update: true
    
  - platform: sml
    name: "bezug_WhImported"
    id: "bezug_WhImported"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: Wh
    state_class: total_increasing
    device_class: energy
    filters:
     - multiply: 0.1
    accuracy_decimals: 1
    force_update: true

  - platform: sml
    name: "zwei_Power"
    id: "zwei_power"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "zwei_L1"
    id: "zwei_L1"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:36.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "zwei_L2"
    id: "zwei_L2"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:56.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "zwei_L3"
    id: "zwei_L3"
    sml_id: sml_zwei
    server_id: "0a01454d480000bcf120"
    obis_code: "1-0:76.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power

  - platform: sml
    name: "bezug_Power"
    id: "bezug_power"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "bezug_L1"
    id: "bezug_L1"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:36.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "bezug_L2"
    id: "bezug_L2"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:56.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power
  - platform: sml
    name: "bezug_L3"
    id: "bezug_L3"
    sml_id: sml_bezug
    server_id: "0a01454d480000c26989"
    obis_code: "1-0:76.7.0"
    unit_of_measurement: W
    state_class: measurement
    device_class: power

You could use another GPIO to pull the RX low / to make the receiver blind. I recommend to use a ESP32 because of the three hardware UARTs. Receiving SML datagrams at 1 Hz from three different smart meters works flawlessly here.

managed it at the moment by putting the logger to TX only UART and assign one of the sml reader to the free hardware UART and the other one to Software Serial.
Now i works with the “old” ESP8266

Shifting load to the hardware UART is a good idea! I hope your setup still works if the telegrams of both meters arrive simultaneously / at the same second.

at the moment it worked fine for round 24h. So I think it will be ok for sometime. For long term use I’m still looking for a fitting ESP32.
My Wemos C3 Mini had serveral problems with es-home so that I use one of the old d1 mini for initial setup :slight_smile: