# EM330 / EM340 emulation

### Defaults

* Modbus device id: `1`
* RS485: `9600 8N1`
* Function codes: `FC03`
* Data types: mixed `int32` and `int16`
* Unavailable values: `0`

### Main measurement registers

| Register | Description              | Type    | Unit / encoding       |
| -------- | ------------------------ | ------- | --------------------- |
| 0        | voltage\_l1              | `int32` | V x10                 |
| 2        | voltage\_l2              | `int32` | V x10                 |
| 4        | voltage\_l3              | `int32` | V x10                 |
| 6        | line\_voltage\_l1\_l2    | `int32` | V x10                 |
| 8        | line\_voltage\_l2\_l3    | `int32` | V x10                 |
| 10       | line\_voltage\_l3\_l1    | `int32` | V x10                 |
| 12       | current\_l1              | `int32` | A x1000               |
| 14       | current\_l2              | `int32` | A x1000               |
| 16       | current\_l3              | `int32` | A x1000               |
| 18       | active\_power\_l1        | `int32` | W x10                 |
| 20       | active\_power\_l2        | `int32` | W x10                 |
| 22       | active\_power\_l3        | `int32` | W x10                 |
| 24       | mirror of 18             | `int32` | W x10                 |
| 26       | mirror of 20             | `int32` | W x10                 |
| 28       | mirror of 22             | `int32` | W x10                 |
| 30       | reactive\_power\_l1      | `int32` | fixed `0`             |
| 32       | reactive\_power\_l2      | `int32` | fixed `0`             |
| 34       | reactive\_power\_l3      | `int32` | fixed `0`             |
| 36       | system\_voltage\_ln      | `int32` | averaged value        |
| 38       | system\_voltage\_ll      | `int32` | averaged value        |
| 40       | system\_active\_power    | `int32` | W x10                 |
| 42       | system\_apparent\_power  | `int32` | same as register `40` |
| 44       | system\_reactive\_power  | `int32` | fixed `0`             |
| 46       | power\_factor\_l1        | `int16` | `1000` or `-1000`     |
| 47       | power\_factor\_l2        | `int16` | `1000` or `-1000`     |
| 48       | power\_factor\_l3        | `int16` | `1000` or `-1000`     |
| 49       | power\_factor\_total     | `int16` | `1000` or `-1000`     |
| 50       | phase sequence           | `int16` | fixed `0`             |
| 51       | frequency                | `int16` | `500` = 50.0 Hz       |
| 52       | imported energy total    | `int32` | kWh x10               |
| 54       | imported reactive energy | `int32` | fixed `0`             |
| 80       | exported energy total    | `int32` | kWh x10               |
| 82       | exported reactive energy | `int32` | fixed `0`             |
| 92       | run hour meter           | `int32` | seconds since boot    |

### Configuration / info registers

| Register | Description        | Type    | Value                  |
| -------- | ------------------ | ------- | ---------------------- |
| 406      | pre4 meter flag    | `int32` | `0` or `1`             |
| 408      | firmware version   | `int32` | packed `MMmmpp`        |
| 410      | dongle name        | `int32` | packed `P1M3`          |
| `0x2000` | device id          | `int16` | current `DevID`        |
| `0x2001` | baudrate selector  | `int16` | `1-5`                  |
| `0x2002` | parity selector    | `int16` | `1` = none, `2` = even |
| `0x2003` | stop bits          | `int16` | `1` or `2`             |
| `0x2004` | max words per read | `int16` | fixed `50`             |

### Notes

* The implementation mixes 16-bit and 32-bit registers, so clients must request registers exactly as expected by the target integration.
