Coder Social home page Coder Social logo

esphome_multical402's Introduction

Kamstrup Multical 402 for esphome

Introduction

This is a custom component for esphome that can read values from a Kamstrup Multical 402 meter. This meter type is used for district heating for the most.

The code is combined and adapted from other sources, see Sources & Inspiration below.

The meter is using KMP (Kamstrup Meter Protocol) for communication which is also used in power meters, but the code in this repository is written to read specific register values.

Optical Reader

The Multical 402 meter is equipped with an optical communication port. In order to communicate with the meter an Optical Reader is needed.

These are typically equipped with an USB port and are rather expensive, but for this project we only need a simple circuit that can be controlled by the ESP chip.

Options:

However, I don't think it's feasible making your own. The ones from ebay are really cheap (~18 EUR), but if you have a 3D printer already you can get the pcb and magnet for less.

Configuration

Update the multical402.yaml file as follows.

Board

In my case I'm using a Weemos D1 mini clone, but make sure to specify the right board here. Get more info here.

esphome:
  board: d1_mini    <-- Set the right board here
  ...

Wifi

Specify wifi credentials.

wifi:
  ssid: INSERT_WIFI_SSID
  password: INSERT_WIFI_PASSWORD

UART

The optical reader has 2 connections (besides VCC and GND). Specify them here:

uart:
  - id: uart_bus
    rx_pin: D1      <-- Set RX pin
    tx_pin: D2      <-- Set TX pin
    ...

Update interval

The code will run every 10 seconds. This can be changed here:

custom_component:
  - lambda: |-
      auto multical402 = new Multical402(
        10000,      <-- Specify update interval in milliseconds
        ...

Sensors

Currently the code is hardcoded to read the following register values:

  • Energy (Wh)
  • Power (W)
  • Temperature In (°C)
  • Temperature Out (°C)
  • Temperature Diff (°C)
  • Flow (l/h)
  • Volume (m3)

The code (kmp.h) can be changed to read other registers, but that is outside the scope of this readme.

Unit of Measurement

Make sure to specify the unit of measurement on the sensors to match the value from the meter (eg. Wh vs kWh vs MWh).

sensors:
- name: 'Energy'
    ...
    unit_of_measurement: MWh  <-- specify unit of measurement here
    ...

Troubleshooting

In case no values are being read and the log shows something like this:

[21:04:37][D][Multical402:048]: Start update
[21:04:37][W][Multical402:163]: Timed out listening for data
[21:04:37][W][Multical402:163]: Timed out listening for data
[21:04:38][W][Multical402:163]: Timed out listening for data
[21:04:38][W][Multical402:163]: Timed out listening for data
[21:04:38][W][Multical402:163]: Timed out listening for data
[21:04:39][W][Multical402:163]: Timed out listening for data
[21:04:39][W][Multical402:163]: Timed out listening for data
[21:04:39][D][Multical402:078]: End update

Check the following:

  • Check the IR LED on the optical reader; use a mobile phone and use the camera, the IR LED should blink every 10 seconds (or other if the update interval has been changed). If this isn't the case, check the UART pins and the wiring.
  • Press the "play" button on the meter to enable the IR Port. The meter will turn off the optical port after 30min of inactivity on either buttons and optical port.
  • Make sure the optical reader is positioned the right way; turn it 180° to flip the position of the IR sensor.

Sources & Inspiration

Protocol Description

esphome_multical402's People

Contributors

0x414c49 avatar cenobitedk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

esphome_multical402's Issues

Multical 403 on ESP32

I had timeout problems on some registers with this code.

Debugging showed two gave timeout and therefore other registers didn’t come through.

Increasing timeout property in the code to 250 solved it.

Thanks for the great work 👍

Resolution of Energy register

Hi

the information I read from the energy register is in KWh with no decimals value.

This is not a very good resolution when energy consumption is around 5-20 KWh in the summer period.

In HA it gives this result in the energy dashboard:
IMG_2118

But when I look at my suppliers statistics they have better resolution in my energy data:
IMG_2117

Therefore I assume that the data is available in the Multical but not stored in the Energy register…

Any ideas which register (if any) would store more detailed energy data?

Ir Implementation links dead

Hi,

sadly the links to the schematics for the ir Implementation are broken can you provide more informations?

I cant get it log my meter - Multical 602

Hi there.
thank you for the very good application for the Multical Optical reading.
i just have the issue, that i cant get it read from my meter.

i get this error:
image

if i take it of the meter it get the this error you make the troubleshooting at:
image

my hardware is this one here:
https://www.ebay.com/itm/354359025520?hash=item5281719f70:g:BgcAAOSwPqxjWj~H

and here is my .yaml code

`substitutions:
device_name: multical602
friendly_name: Multical 602

esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
includes:
- kmp.h
- multical402.h

Enable logging

logger:
baud_rate: 0

Enable Home Assistant API

api:
encryption:
key: "S8FouGpCYDTCDmnP+uSO2m3/bIAChyGLBEtjORhjtFg="

ota:
password: "5050a1d09c9b1a4ad46202cc65d9aa21"

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

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: "Kamstrup-Multical"
password: "b1jzffPzfgBh"

#Multical UART
uart:

  • id: uart_bus
    rx_pin: GPIO03
    tx_pin: GPIO01
    baud_rate: 1200
    data_bits: 8
    parity: NONE
    stop_bits: 1

#Multical Custom Sensor (first variable is update interval in ms; 3600000 is 1 hour)
custom_component:

  • lambda: |-
    auto multical402 = new Multical402(
    10000,
    id(uart_bus),
    id(m_energy),
    id(m_power),
    id(m_tin),
    id(m_tout),
    id(m_tdiff),
    id(m_flow),
    id(m_volume));
    App.register_component(multical402);
    return {multical402};
    components:
    • id: multical

sensor:
#Multical Custom Sensors

  • name: "Multical Energy"
    platform: template
    id: m_energy
    icon: "mdi:lightning-bolt"
    unit_of_measurement: MWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
    force_update: true

  • name: "Multical Volume"
    platform: template
    id: m_volume
    unit_of_measurement: m3
    accuracy_decimals: 2
    state_class: "measurement"

  • name: "Multical Temperature In"
    platform: template
    id: m_tin
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Temperature Out"
    platform: template
    id: m_tout
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Temperature Diff"
    platform: template
    id: m_tdiff
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Power"
    platform: template
    id: m_power
    icon: "mdi:flash"
    unit_of_measurement: kW
    accuracy_decimals: 1
    state_class: "measurement"
    device_class: "power"

  • name: "Multical Flow"
    platform: template
    id: m_flow
    unit_of_measurement: l/h
    accuracy_decimals: 0
    state_class: "measurement"`

i see the red IR in the sensor make the blink every 10 sec.
i have tried to rotate the eye on the meter withou luck.

can you in some way help me out here ?

BR
/Mike

Does it also work with a multical 21 ?

Sorry, this is more a question than an issue;
Does it also work with a multical 21 ? That is a Watermeter from Kamstrup that seems to have an optical diode as well.
This would be a feature request if it could be supported.
Keep up the good work, thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.