Skip to content

Bulion/esphome-components

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

401 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version 5 based on Kuba's dirty fork.

Supports both CC1101 and SX1276 radio transceivers for wM-Bus reception.

Previous versions: version 4 version 3 version 2

TODO:

  • Add support for SX1262 (with limited frame length)
  • Prepare packages for ready made boards (like UltimateReader) with displays, leds etc.
  • Aggresive cleanup of wmbusmeters classes/structs
  • Refactor traces/logs

DONE:

  • Add backward support for CC1101 with modern architecture
  • Reuse CRCs and frame parsers from wmbusmeters
  • Refactor 3out6 decoder
  • Migrate to esp-idf and drop Arduino!
  • Add support for SX1276
  • Run receiver in separate task
  • Drop all non wmbus related components from rf code part
  • Allow to specify ASCII decription key
  • Divide codebase to separate components (radio for radio communication, meter for meters (on which sensor may subscribe) and common for wmbusmeters code)
  • Add triggers:
    • Radio->on packet (allow to blink on frame/telegram)
    • Meter->on telegram (allow e.g. to send whole telegram to MQTT)
  • Re-pull of wmbusmeters code from upstream
  • Reimplement TCP and UCP senders. Should be classes with common interface to use as action under Radio->on packet trigger
  • Reimplement HEX and RTLWMBUS formatter to use as parameter of TCP/UDP action

Usage example:

CC1101 Radio Configuration

esphome:
  name: wmbus
  friendly_name: WMBus

external_components:
  - source: github://SzczepanLeon/esphome-components@main

esp32:
  board: esp32dev
  framework:
    type: esp-idf

logger:
  level: DEBUG

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

api:

spi:
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

wmbus_radio:
  radio_type: CC1101
  cs_pin: GPIO15
  gdo0_pin: GPIO4
  gdo2_pin: GPIO16
  frequency: 868.95

SX1276 Radio Configuration

esphome:
  name: wmbus
  friendly_name: WMBus
  platformio_options:
    upload_speed: 921600

external_components:
  - source: github://SzczepanLeon/esphome-components@main

esp32:
  board: heltec_wifi_lora_32_V2
  flash_size: 8MB
  framework:
    type: esp-idf

logger:
  id: component_logger
  level: DEBUG
  baud_rate: 115200

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

api:

web_server:
  version: 3

time:
  - platform: homeassistant

spi:
  clk_pin:
    number: GPIO5
    ignore_strapping_warning: true
  mosi_pin: GPIO27
  miso_pin: GPIO19

socket_transmitter:
  id: my_socket
  ip_address: 192.168.1.1
  port: 3333
  protocol: TCP

mqtt:
  broker: test.mosquitto.org
  port: 1883
  client_id: some_client_id

wmbus_radio:
  radio_type: SX1276
  cs_pin: GPIO18
  reset_pin: GPIO14
  irq_pin: GPIO35
  on_frame:
    - then:
        - logger.log:
            format: "RSSI: %ddBm T: %s (%d)"
            args: [ frame->rssi(), frame->as_hex().c_str(), frame->data().size() ]
    - then:
        - repeat:
            count: 3
            then:
              - output.turn_on: status_led
              - delay: 100ms
              - output.turn_off: status_led
              - delay: 100ms
    - mark_as_handled: True
      then:
        - mqtt.publish:
            topic: wmbus-test/telegram_rtl
            payload: !lambda return frame->as_rtlwmbus();
    - mark_as_handled: True
      then:
        - socket_transmitter.send:
            data: !lambda return frame->as_hex();

wmbus_meter:
  - id: electricity_meter
    meter_id: 0x0101010101
    type: amiplus
    key: 00000000000000000000000000000000
    mode: 
      - T1
      - C1
  - id: heat_meter
    meter_id: 12321
    type: hydrocalm3
    on_telegram:
      then:
        - wmbus_meter.send_telegram_with_mqtt:
            topic: wmbus-test/telegram

output:
  - platform: gpio
    id: vext_output
    pin: GPIO21
  - platform: gpio
    id: oled_reset
    pin: GPIO16
    inverted: True
  - platform: gpio
    id: status_led
    pin: GPIO25

sensor:
  - platform: wmbus_meter
    parent_id: heat_meter
    field: total_heating_kwh
    device_class: energy
    name: Zużycie energii cieplnej
    accuracy_decimals: 4
    state_class: total_increasing

  - platform: wmbus_meter
    parent_id: electricity_meter
    field: current_power_consumption_kw
    name: Moc aktualna
    accuracy_decimals: 0
    device_class: power
    unit_of_measurement: W
    state_class: measurement
    filters:
      - multiply: 1000

  - platform: wmbus_meter
    parent_id: electricity_meter
    field: total_energy_consumption_kwh
    name: Zużycie energii
    accuracy_decimals: 3
    device_class: energy
    state_class: total_increasing

  - platform: wmbus_meter
    parent_id: electricity_meter
    field: rssi_dbm
    name: Electricity Meter RSSI

text_sensor:
  - platform: wmbus_meter
    parent_id: electricity_meter
    field: timestamp
    name: Electricity Meter timestamp

  - platform: wmbus_meter
    parent_id: electricity_meter
    field: timestamp_zulu
    name: Electricity Meter timestamp zulu

  - platform: wmbus_meter
    parent_id: electricity_meter
    field: current_alarms
    name: Electricity Meter alarms

Radio Configuration Notes

CC1101

  • GDO0 pin: FIFO threshold indicator (asserts when data ready to read)
  • GDO2 pin: Sync word detection indicator (asserts when frame starts)
  • Frequency: Default 868.95 MHz (configurable via frequency parameter)
  • Polling interval: Default 2ms (configurable via polling_interval parameter)
  • Reception mode: Polling-based (checks GPIO pins periodically)
  • No hardware reset pin: Uses software reset via SPI command

SX1276

  • Reset pin: Hardware reset line (required for initialization)
  • IRQ pin: DIO1 interrupt line (triggers on FIFO threshold)
  • Reception mode: Interrupt-driven (hardware triggers when data available)
  • Board compatibility: Works with Heltec WiFi LoRa 32 boards

Both radios support wM-Bus Mode T (100 kbps, 3-of-6 encoding) and Mode C (100 kbps).

Updating wmbusmeters Code

In order to pull latest wmbusmeters code run:

git subtree pull --prefix components/wmbus_common https://github.com/wmbusmeters/wmbusmeters.git <REF> --squash

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 81.5%
  • C 10.7%
  • Python 7.8%