question

PVTex avatar image
PVTex asked

Help needed for Power Meter lib for Modbus-RTU-based meters from finder

Hello,

i am a little stuck here.
i try to add power meter from finder the 7M.24 and 7M.38

made a new file finder.py under /opt/victronenergy/dbus-modbus-client
included it in the dbus-modbus-client.py file and compiled both files.

but the venus os cant find my meter.


i have attached the modbus register declaration as pdfModbus-7M24-7M38_v2_30062021.pdf

this is my finder.py file:

import struct
import device
import probe
from register import Reg, Reg_s16, Reg_s32b, Reg_u16, Reg_u32b, Reg_u64b, Reg_text

class Reg_serial(Reg, str):
    def __init__(self, base, name):
        Reg.__init__(self, base, 2, name)

    def decode(self, values):
        v = struct.unpack('>i', struct.pack('>2H', *values))
        return self.update(str(v[0]))

class Finder_Meter(device.EnergyMeter):
    productid = 0xb017
    min_timeout = 0.5

    def __init__(self, *args):
        super(Finder_Meter, self).__init__(*args)

        self.info_regs = [
            Reg_serial(9, '/Serial'),
            Reg_text(13, '/FirmwareVersion'),
        ]

    def device_init(self):
        self.data_regs = [
            Reg_u32b(2491, '/Ac/Power',          100, '%.1f W'),
            Reg_u32b(2498, '/Ac/Frequency',      100, '%.1f Hz'),
            Reg_u32b(2760, '/Ac/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(2768, '/Ac/Energy/Reverse', 100, '%.1f kWh', invalid=0xffffffffffffffff),

            # We always have L1 voltage and current
            Reg_u32b(2500, '/Ac/L1/Voltage',      10, '%.1f V'),
            Reg_u32b(2516, '/Ac/L1/Current',     100, '%.1f A'),
        ]

    def get_ident(self):
        return 'finder_{}'.format(self.info['/Serial'])

class Finder_Meter_1P(Finder_Meter):
    productname = 'Finder 7M.24 Energy Meter'

    def device_init(self):
        super(Finder_Meter_1P, self).device_init()

        # Copies of overall values, because phase values show not-supported.
        self.data_regs += [
            Reg_u32b(2530, '/Ac/L1/Power',          100, '%.1f W'),
            Reg_u32b(2762, '/Ac/L1/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(2770, '/Ac/L1/Energy/Reverse', 100, '%.1f kWh'),
        ]

class Finder_Meter_3P(Finder_Meter):
    productname = 'Finder 7M.38 Energy Meter'

    def device_init(self):
        super(Finder_Meter_3P, self).device_init()
        self.data_regs += [
            Reg_u32b(2502, '/Ac/L2/Voltage',      10, '%.1f V'),
            Reg_u32b(2504, '/Ac/L3/Voltage',      10, '%.1f V'),
            Reg_u32b(2518, '/Ac/L2/Current',     100, '%.1f A'),
            Reg_u32b(2520, '/Ac/L3/Current',     100, '%.1f A'),

            Reg_u32b(2530, '/Ac/L1/Power',       100, '%.1f W'),
            Reg_u32b(2532, '/Ac/L2/Power',       100, '%.1f W'),
            Reg_u32b(2534, '/Ac/L3/Power',       100, '%.1f W'),

            Reg_u32b(2762, '/Ac/L1/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(2764, '/Ac/L2/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(2766, '/Ac/L3/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(2770, '/Ac/L1/Energy/Reverse', 100, '%.1f kWh'),
            Reg_u32b(2772, '/Ac/L2/Energy/Reverse', 100, '%.1f kWh'),
            Reg_u32b(2774, '/Ac/L3/Energy/Reverse', 100, '%.1f kWh'),
        ]

models = {
    927804978: { # 7M.24 (0x374d2e32)
        'model':    '7M.24',
        'handler':  Finder_Meter_1P,
    },
    927804979: { # 7M.38 (0x374d2e33)
        'model':    '7M.38',
        'handler':  Finder_Meter_3P,
    },
}

probe.add_handler(probe.ModelRegister(Reg_u32b(1), models,
                                      methods=['rtu', 'tcp'],
                                      units=[1, 11],
      rates=[115200]
Energy MeterModbus TCP
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

5 Answers
PVTex avatar image
PVTex answered ·

just eddited the pyhton script to use floats in big indian

import logging

import device
import probe
from register import *

log = logging.getLogger()

class Finder_Meter(device.EnergyMeter):
    productid = 0xb099
    productname = 'finder 7M series'
    min_timeout = 0.5

    def __init__(self, *args):
        super(Finder_Meter, self).__init__(*args)

        self.info_regs = [
            Reg_text(9, 4,'/Serial'),
            Reg_text(13, '/FirmwareVersion'),
        ]

    def device_init(self):
        self.data_regs = [
            Reg_f32b(2491, '/Ac/Power',          100, '%.1f W'),
            Reg_f32b(2498, '/Ac/Frequency',      100, '%.1f Hz'),
            Reg_f32b(2760, '/Ac/Energy/Forward', 100, '%.1f kWh'),
            Reg_f32b(2768, '/Ac/Energy/Reverse', 100, '%.1f kWh'),

            # We always have L1 voltage and current
            Reg_f32b(2500, '/Ac/L1/Voltage',      10, '%.1f V'),
            Reg_f32b(2516, '/Ac/L1/Current',     100, '%.1f A'),
        ]

    def get_ident(self):
        return 'finder_%s' % self.info['/Serial']

class Finder_Meter_1P(Finder_Meter):
    productname = 'Finder 7M.24 Energy Meter'

    def device_init(self):
        super(Finder_Meter_1P, self).device_init()

        self.data_regs += [
            Reg_f32b(2530, '/Ac/L1/Power',          100, '%.1f W'),
            Reg_f32b(2762, '/Ac/L1/Energy/Forward', 100, '%.1f kWh'),
            Reg_f32b(2770, '/Ac/L1/Energy/Reverse', 100, '%.1f kWh'),
        ]

class Finder_Meter_3P(Finder_Meter):
    productname = 'Finder 7M.38 Energy Meter'

    def device_init(self):
        super(Finder_Meter_3P, self).device_init()
        self.data_regs += [
            Reg_f32b(2502, '/Ac/L2/Voltage',      10, '%.1f V'),
            Reg_f32b(2504, '/Ac/L3/Voltage',      10, '%.1f V'),
            Reg_f32b(2518, '/Ac/L2/Current',     100, '%.1f A'),
            Reg_f32b(2520, '/Ac/L3/Current',     100, '%.1f A'),

            Reg_f32b(2530, '/Ac/L1/Power',       100, '%.1f W'),
            Reg_f32b(2532, '/Ac/L2/Power',       100, '%.1f W'),
            Reg_f32b(2534, '/Ac/L3/Power',       100, '%.1f W'),

            Reg_f32b(2762, '/Ac/L1/Energy/Forward', 100, '%.1f kWh'),
            Reg_f32b(2764, '/Ac/L2/Energy/Forward', 100, '%.1f kWh'),
            Reg_f32b(2766, '/Ac/L3/Energy/Forward', 100, '%.1f kWh'),
            Reg_f32b(2770, '/Ac/L1/Energy/Reverse', 100, '%.1f kWh'),
            Reg_f32b(2772, '/Ac/L2/Energy/Reverse', 100, '%.1f kWh'),
            Reg_f32b(2774, '/Ac/L3/Energy/Reverse', 100, '%.1f kWh'),
        ]

models = {
    927804978: { # 7M.24.8.230.0210 (0x374d 2e32 342e 382e 3233 302e 3032 3130)
        'model':    '7M.24',
        'handler':  Finder_Meter_1P,
    },
    927804979: { # 7M.38.400.0212F0 (0x374d 2e33 382e 3430 302e 3032 3132 4630)
        'model':    '7M.38',
        'handler':  Finder_Meter_3P,
    },
}

probe.add_handler(probe.ModelRegister(Reg_u32b(1), models,
                                      methods=['rtu','tcp'],
                                      units=[1, 11]))


i can see on my modbus tcp simulator that the venus system requests the right request (i can check that by changing the address and length).

the simulator send back the right bytes, but venus os is seeing nothing there is nothing in the log.


what have i made wrong?


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

PVTex avatar image
PVTex answered ·

i can see in the ssh console that the meter is found when i emulate it with an modbus software on my laptop

1691784498161.png


but it not shown in the venus gui

when i try to use the modbus tcp2rtu gateway it is not found.
using the gateway does function well for home assistant



1691784498161.png (40.0 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

PVTex avatar image
PVTex answered ·

had to wait a little longler.

the emulated meter show up and can be setup up.


but the real meter is not found over the gateway

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

PVTex avatar image
PVTex answered ·

perhabs it is a timing problem.

if i set a slave delay on the emulator for around 250ms the emulator is found but no data could be read. if i set the delay above 300ms the emulator is not found,

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

PVTex avatar image
PVTex answered ·

just programmed an esp32 that response to modbus querys with a data snapshot of the real meter.

the esp is not found.

what is different between the software Modbus Slave on my laptop and the esp or real meter?


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.