{
  "format": "voltrus-device-template/1",
  "template_id": "carlo-gavazzi-em340",
  "manufacturer": "Carlo Gavazzi",
  "model": "EM340",
  "protocol": "modbus",
  "description": "Three phase DIN rail energy meter from the EM300 family with an optional RS485 Modbus RTU port. The map covers phase and system voltage, current, power, power factor, frequency, import and export energy, tariffs and meter setup. Register map: https://voltrus.id/registers/carlo-gavazzi/em340/",
  "version": "1.0.0",
  "verified": false,
  "verified_notes": "Generated by voltrus.id from EM300 Series and ET300 Series Communication Protocol, Version 2 Revision 17 (July 05, 2021) (https://www.gavazziautomation.com/fileadmin/images/PIM/OTHERSTUFF/COMPRO/EM330_EM340_ET330_ET340_CP.pdf), read 2026-10-24. Not checked against a real device; confirm a known value before relying on it.",
  "quirks": [
    "Offsets are 0-based wire addresses. The manual prints Modicon numbers such as 40001.",
    "Word order from the manual: Low word first (CD AB).",
    "INT32, UINT32 and INT64 values are sent least significant word first, with MSB first inside each word (p. 7). The document also mentions an engineering-sample EM340 with the opposite word order (p. 14).",
    "The device speaks Modbus RTU. Voltrus SCADA polls Modbus TCP, so connect it through a Modbus RTU to TCP gateway: use the gateway's IP and port and the device's unit ID.",
    "Defaults from the manual: Per the protocol document: address 1, 9.6 kbps, no parity, one stop bit. Function codes 03 and 04 read the same data.",
    "2 unsigned 32-bit registers are read as int32: exact up to a raw value of 2,147,483,647."
  ],
  "license": "CC-BY-4.0",
  "port": 502,
  "unit_id": 1,
  "interval_ms": 1000,
  "endianness": "little",
  "registers": [
    {
      "name": "Voltage_L1N",
      "offset": 0,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Phase 1 line to neutral voltage (manual address 300001)"
    },
    {
      "name": "Voltage_L2N",
      "offset": 2,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Phase 2 line to neutral voltage (manual address 300003)"
    },
    {
      "name": "Voltage_L3N",
      "offset": 4,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Phase 3 line to neutral voltage (manual address 300005)"
    },
    {
      "name": "Voltage_L1L2",
      "offset": 6,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Line 1 to line 2 voltage (manual address 300007)"
    },
    {
      "name": "Voltage_L2L3",
      "offset": 8,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Line 2 to line 3 voltage (manual address 300009)"
    },
    {
      "name": "Voltage_L3L1",
      "offset": 10,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "Line 3 to line 1 voltage (manual address 300011)"
    },
    {
      "name": "Current_L1",
      "offset": 12,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.001,
      "unit": "A",
      "description": "Phase 1 current (manual address 300013)"
    },
    {
      "name": "Current_L2",
      "offset": 14,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.001,
      "unit": "A",
      "description": "Phase 2 current (manual address 300015)"
    },
    {
      "name": "Current_L3",
      "offset": 16,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.001,
      "unit": "A",
      "description": "Phase 3 current (manual address 300017)"
    },
    {
      "name": "ActivePower_L1",
      "offset": 18,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "Phase 1 active power (manual address 300019)"
    },
    {
      "name": "ActivePower_L2",
      "offset": 20,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "Phase 2 active power (manual address 300021)"
    },
    {
      "name": "ActivePower_L3",
      "offset": 22,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "Phase 3 active power (manual address 300023)"
    },
    {
      "name": "ApparentPower_L1",
      "offset": 24,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "VA",
      "description": "Phase 1 apparent power (manual address 300025)"
    },
    {
      "name": "ApparentPower_L2",
      "offset": 26,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "VA",
      "description": "Phase 2 apparent power (manual address 300027)"
    },
    {
      "name": "ApparentPower_L3",
      "offset": 28,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "VA",
      "description": "Phase 3 apparent power (manual address 300029)"
    },
    {
      "name": "ReactivePower_L1",
      "offset": 30,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "var",
      "description": "Phase 1 reactive power (manual address 300031)"
    },
    {
      "name": "ReactivePower_L2",
      "offset": 32,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "var",
      "description": "Phase 2 reactive power (manual address 300033)"
    },
    {
      "name": "ReactivePower_L3",
      "offset": 34,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "var",
      "description": "Phase 3 reactive power (manual address 300035)"
    },
    {
      "name": "VoltageLN_Sys",
      "offset": 36,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "System line to neutral voltage (manual address 300037)"
    },
    {
      "name": "VoltageLL_Sys",
      "offset": 38,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "V",
      "description": "System line to line voltage (manual address 300039)"
    },
    {
      "name": "ActivePower_Sys",
      "offset": 40,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "System active power (manual address 300041)"
    },
    {
      "name": "ApparentPower_Sys",
      "offset": 42,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "VA",
      "description": "System apparent power (manual address 300043)"
    },
    {
      "name": "ReactivePower_Sys",
      "offset": 44,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "var",
      "description": "System reactive power (manual address 300045)"
    },
    {
      "name": "PowerFactor_L1",
      "offset": 46,
      "register_type": "int16",
      "register_area": "input",
      "scale": 0.001,
      "description": "Phase 1 power factor (manual address 300047)"
    },
    {
      "name": "PowerFactor_L2",
      "offset": 47,
      "register_type": "int16",
      "register_area": "input",
      "scale": 0.001,
      "description": "Phase 2 power factor (manual address 300048)"
    },
    {
      "name": "PowerFactor_L3",
      "offset": 48,
      "register_type": "int16",
      "register_area": "input",
      "scale": 0.001,
      "description": "Phase 3 power factor (manual address 300049)"
    },
    {
      "name": "PowerFactor_Sys",
      "offset": 49,
      "register_type": "int16",
      "register_area": "input",
      "scale": 0.001,
      "description": "System power factor (manual address 300050)"
    },
    {
      "name": "PhaseSequence",
      "offset": 50,
      "register_type": "int16",
      "register_area": "input",
      "scale": 1,
      "description": "Phase sequence (manual address 300051)"
    },
    {
      "name": "Frequency",
      "offset": 51,
      "register_type": "int16",
      "register_area": "input",
      "scale": 0.1,
      "unit": "Hz",
      "description": "Frequency (manual address 300052)"
    },
    {
      "name": "EnergyImport_kWh",
      "offset": 52,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Total imported active energy (manual address 300053)"
    },
    {
      "name": "EnergyImport_kvarh",
      "offset": 54,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kvarh",
      "description": "Total imported reactive energy (manual address 300055)"
    },
    {
      "name": "PowerDemand",
      "offset": 56,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "Active power demand (manual address 300057)"
    },
    {
      "name": "PowerDemandPeak",
      "offset": 58,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "W",
      "description": "Active power demand peak (manual address 300059)"
    },
    {
      "name": "EnergyImportPartial_kWh",
      "offset": 60,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Partial imported active energy (manual address 300061)"
    },
    {
      "name": "EnergyImportPartial_kvarh",
      "offset": 62,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kvarh",
      "description": "Partial imported reactive energy (manual address 300063)"
    },
    {
      "name": "EnergyImport_kWh_L1",
      "offset": 64,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Phase 1 imported active energy (manual address 300065)"
    },
    {
      "name": "EnergyImport_kWh_L2",
      "offset": 66,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Phase 2 imported active energy (manual address 300067)"
    },
    {
      "name": "EnergyImport_kWh_L3",
      "offset": 68,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Phase 3 imported active energy (manual address 300069)"
    },
    {
      "name": "EnergyImport_kWh_T1",
      "offset": 70,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Imported active energy, tariff 1 (manual address 300071)"
    },
    {
      "name": "EnergyImport_kWh_T2",
      "offset": 72,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Imported active energy, tariff 2 (manual address 300073)"
    },
    {
      "name": "EnergyExport_kWh",
      "offset": 78,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kWh",
      "description": "Total exported active energy (manual address 300079)"
    },
    {
      "name": "EnergyExport_kvarh",
      "offset": 80,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.1,
      "unit": "kvarh",
      "description": "Total exported reactive energy (manual address 300081)"
    },
    {
      "name": "EnergyImport_kWh_Int",
      "offset": 1024,
      "register_type": "int32",
      "register_area": "input",
      "scale": 1,
      "unit": "kWh",
      "description": "Total imported active energy, integer part (manual address 301025)"
    },
    {
      "name": "EnergyImport_kWh_Dec",
      "offset": 1026,
      "register_type": "int32",
      "register_area": "input",
      "scale": 0.001,
      "unit": "kWh",
      "description": "Total imported active energy, decimal part (manual address 301027)"
    },
    {
      "name": "VersionCode",
      "offset": 770,
      "register_type": "uint16",
      "register_area": "input",
      "scale": 1,
      "description": "Firmware version code (manual address 300771)"
    },
    {
      "name": "RevisionCode",
      "offset": 771,
      "register_type": "uint16",
      "register_area": "input",
      "scale": 1,
      "description": "Firmware revision code (manual address 300772)"
    },
    {
      "name": "ProductCode",
      "offset": 11,
      "register_type": "uint16",
      "register_area": "input",
      "scale": 1,
      "description": "Carlo Gavazzi identification code (manual address 300012)"
    },
    {
      "name": "ProductionYear",
      "offset": 20496,
      "register_type": "uint16",
      "register_area": "input",
      "scale": 1,
      "description": "Production year (manual address 320497)"
    },
    {
      "name": "Password",
      "offset": 4096,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Programming password (manual address 304097)",
      "writable": true
    },
    {
      "name": "MeasuringSystem",
      "offset": 4098,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Measuring system (manual address 304099)",
      "writable": true
    },
    {
      "name": "CT_Ratio",
      "offset": 4099,
      "register_type": "int32",
      "register_area": "holding",
      "scale": 0.1,
      "description": "Current transformer ratio (manual address 304100)",
      "writable": true
    },
    {
      "name": "VT_Ratio",
      "offset": 4101,
      "register_type": "int32",
      "register_area": "holding",
      "scale": 0.1,
      "description": "Voltage transformer ratio (manual address 304102)",
      "writable": true
    },
    {
      "name": "DisplayMode",
      "offset": 4352,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Display mode (manual address 304353)",
      "writable": true
    },
    {
      "name": "TariffEnable",
      "offset": 4353,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Tariff management enable (manual address 304354)",
      "writable": true
    },
    {
      "name": "MeasurementMode",
      "offset": 4355,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Measurement mode selection (manual address 304356)",
      "writable": true
    },
    {
      "name": "WiringStatus",
      "offset": 4357,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Wrong connection status (manual address 304358)",
      "writable": true
    },
    {
      "name": "TariffMode",
      "offset": 4608,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Tariff selection source (manual address 304609)",
      "writable": true
    },
    {
      "name": "TariffNumber",
      "offset": 4609,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Active tariff via serial (manual address 304610)",
      "writable": true
    },
    {
      "name": "ModbusAddress",
      "offset": 8192,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "RS485 instrument address (manual address 308193)",
      "writable": true
    },
    {
      "name": "BaudRate",
      "offset": 8193,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "RS485 baud rate (manual address 308194)",
      "writable": true
    },
    {
      "name": "Parity",
      "offset": 8194,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "RS485 parity (manual address 308195)",
      "writable": true
    },
    {
      "name": "StopBits",
      "offset": 8195,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "RS485 stop bits (manual address 308196)",
      "writable": true
    },
    {
      "name": "MaxWordsPerRead",
      "offset": 8196,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Maximum words per read request (manual address 308197)"
    },
    {
      "name": "ResetPartialAndTariff",
      "offset": 16384,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Reset partial, tariff and demand meters (manual address 316385)",
      "writable": true
    },
    {
      "name": "ResetTotalEnergy",
      "offset": 16385,
      "register_type": "uint16",
      "register_area": "holding",
      "scale": 1,
      "description": "Reset total energy meters (manual address 316386)",
      "writable": true
    }
  ]
}
