RichiH / modbus_exporter

Exporter which retrieves stats from a modbus system and exports them via HTTP for Prometheus consumption.
Apache License 2.0
89 stars 44 forks source link

Data is not properly collected #76

Open JesusFrontelo opened 2 days ago

JesusFrontelo commented 2 days ago

Good Afternoon @RichiH ,

When I try to get the data from the records of my Ingecon inverter from the modbus exporter I see that the values obtained are not correct. For example, the first 6 records correspond to the date (year, month, day, hour, minutes, and seconds). In modbus-exporter I am getting the value 2024 for all of them, but if I set a flow to node-red I get the data correctly.

This is the data i get from modbus-exporter: image

And this is the configuration at modbus.yml:

modules:

  - name: "start"
    protocol: 'tcp/ip'
    metrics:

      - name: "ModBus_Actual_Year"
        help: "Actual Date. Year (Uint16)"
        address: 30000
        dataType: uint16
        endianness: big
        metricType: gauge
        labels:
          address: 30000

      - name: "ModBus_Actual_Month"
        help: "Actual Date. Month (Uint16)"
        address: 30001
        dataType: uint16
        metricType: gauge
        endianness: big
        labels:
          address: 30001

      - name: "ModBus_Actual_Day"
        help: "Actual Date. Day (Uint16)"
        address: 30002
        dataType: uint16
        metricType: gauge
        endianness: big
        labels:
          address: 30002

....

This is the data i obtanined at node-red:

image

The configuration at buffer parser is:

image

I think it would be necessary to add the offset byte option to the metrics settings as you can see in Node-Red's parser buffer so that you can get the data correctly with Node-Exporter.

Hope someone can help me.

Regards.

JesusFrontelo commented 1 day ago

I saw this at the inverter imput registers documentation:

1.2 FUNCTION 0x04: READ INPUT REGISTERS Function 0x04 allows reading online data or Input Registers (references 3xxxx) from the inverter. The registers are redirected starting with the register number 1, which in the memory address is the position 0. Within the Input Registers map it can be read whatever part of the memory. The master sends a Query message to the inverter. It asks the number, 0xNHNL, of Input Registers starting in the address 0xFHFL. Address -- Inverter Address [1 .. 247]
Function 0x04 Read Input Registers
Starting Address Hi 0xFH Address of 1st register (HI byte)
Starting Address Lo 0xFL Address of 1st register (LO byte)
Number of Points Hi 0xNH Number of registers to read (HI byte)
Number of Points Lo 0xNL Number of registers to read (LO byte)
Error Check (CRC) - Hi -- Cyclic Redundancy Code (HI byte)
Error Check (CRC) - Lo -- Cyclic Redundancy Code (LO byte)
The inverter answer sending the following Response message, which includes the values of the 0xNHNL configuration parameters (2 bytes per register [0xNN]) Address -- Inverter address [1 .. 247]
Function 0x04 Read Input Registers
Byte Count 0xNN Number of data octets
Data Hi -- Value of register 1 (HI byte)
Data Lo -- Value of register 1 (LO byte)
Data Hi --
Data Lo --
Data Hi -- Value of register n (HI byte)
Data Lo -- Value of register n (LO byte)
Error Check (CRC) - Hi -- Cyclic Redundancy Code (HI byte)
Error Check (CRC) - Lo -- Cyclic Redundancy Code (LO byte)

But I don't know how to use it to set up the exporter correctly