This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MBus and Siemens UH50 meter
#12
(18.04.2024, 11:40)BrentW Wrote:
(26.02.2024, 12:45)tomnord Wrote:
Code:
SW: 20230607

Hi Tomnord, 

Any update on how you went with this integration? 
We are also integrating with the UH50 using Mbus and the meters do have some peculiar behaviours.

Brent

I got it to work, had some issues with cables. All values ar updatet each 15min, but previous value is stored in mBus buffer. 
Script below with separated GA's.
Code:
-- config init
if not meters then
  require('mbus')

  -- time to wait between each meter read
  sleeptime = 10
  -- use /dev/RS232 serial port with 2400 baud rate
  mbus.init('/dev/RS232', 2400)

  -- meter definition
  -- addr - short address
  -- id - number from data table where value resides
  -- div - optional divisor for convertion to the final value
  meters = {
    { ga = '3/0/0', addr = 10, id = 4, div = 10}, --  kW, dpt 14.
    { ga = '3/0/1', addr = 10, id = 2}, --  kWh dpt 12.
    { ga = '3/0/2', addr = 10, id = 5, div = 1000 }, --  m3h dpt 14
    { ga = '3/0/3', addr = 10, id = 6 }, --T1    dpt 12.
    { ga = '3/0/4', addr = 10, id = 7 }, -- T2   dpt 12.
    { ga = '3/1/0', addr = 20, id = 4, div = 10 }, --  kW
    { ga = '3/1/1', addr = 20, id = 2}, --  kWh
    { ga = '3/1/2', addr = 20, id = 5, div = 1000 }, --m3h
    { ga = '3/1/3', addr = 20, id = 6 }, --T1   
    { ga = '3/1/4', addr = 20, id = 7 }, --T2  
    { ga = '3/2/0', addr = 30, id = 4, div = 10 }, --kW
    { ga = '3/2/1', addr = 30, id = 2}, --kWh
    { ga = '3/2/2', addr = 30, id = 5, div = 1000 }, --m3h
    { ga = '3/2/3', addr = 30, id = 6 }, --T1   
    { ga = '3/2/4', addr = 30, id = 7 }, --T2    
  }

  -- reset meter values on first run
  for _, meter in ipairs(meters) do
    meter.value = 0
  end
end

-- read each meter
for _, meter in ipairs(meters) do
  res = mbus.getdata(meter.addr)

  -- read ok
  if type(res) == 'table' then
    data = res.data[ meter.id ]
    value = nil

    -- get current value
    if type(data) == 'table' then
      value = tonumber(data.value)
    end

    -- value is valid and different from previous read
    if value and meter.value ~= value then
      -- apply divisor if set
      div = meter.div
      dpt = div and dt.float32 or dt.uint32
      if div then
        value = value / div
      end

      -- update group address value
      grp.update(meter.ga, value, dpt)
      meter.value = value
      --log(meter.ga, meter.value, dpt)
    end
  end

  -- wait for next read
  os.sleep(sleeptime)
end
Reply


Messages In This Thread
MBus and Siemens UH50 meter - by tomnord - 23.02.2024, 07:54
RE: MBus and Siemens UH50 meter - by admin - 23.02.2024, 08:20
RE: MBus and Siemens UH50 meter - by tomnord - 26.02.2024, 06:51
RE: MBus and Siemens UH50 meter - by admin - 26.02.2024, 06:56
RE: MBus and Siemens UH50 meter - by tomnord - 26.02.2024, 09:06
RE: MBus and Siemens UH50 meter - by admin - 26.02.2024, 09:11
RE: MBus and Siemens UH50 meter - by tomnord - 26.02.2024, 12:13
RE: MBus and Siemens UH50 meter - by admin - 26.02.2024, 12:41
RE: MBus and Siemens UH50 meter - by tomnord - 26.02.2024, 12:45
RE: MBus and Siemens UH50 meter - by BrentW - 18.04.2024, 11:40
RE: MBus and Siemens UH50 meter - by tomnord - 24.04.2024, 10:45
RE: MBus and Siemens UH50 meter - by admin - 26.02.2024, 12:46
RE: MBus and Siemens UH50 meter - by BrentW - 01.05.2024, 09:28
RE: MBus and Siemens UH50 meter - by tomnord - 13.05.2024, 12:31

Forum Jump: