IEC 60870-5-104 (IEC 104) is the telecontrol protocol of energy networks over TCP/IP: substations, grid-connected generation, water and gas networks. The Weble IoT Universal Gateway IEC 60870-5-104 driver exchanges measurements, signals, counters and commands with IEC 104 stations over TCP, port 2404 by default.
The driver works in two roles:
There is no polling loop as in Modbus: the controlled station sends every change by itself, with its quality and time tag, and a general interrogation reads the whole state back when the connection opens.
Driver key:
iec104— listed as IEC 60870-5-104 under Building Automation in Gateway driver. Licence: not required. Platforms: Linux and Windows.
IEC 104 has no authentication and no encryption. In server mode, fill Allowed IP addresses with the addresses of the controlling stations and keep port 2404 on a dedicated network, behind a firewall or reachable only through the VPN. See Security.
2404) of the remote station, or of the box when it acts as a server.k, w, t1, t2 and t3 if the remote station does not use the defaults of the standard.client. Set Host (controlled station) to the IP address of the RTU and keep Port = 2404.server.2404. Leave Listen address empty to listen on all interfaces of the box, or enter one IP address of the box.4 unless the operator connects more front ends.M_ME_NC_1 - Measured value, short float) and enter the Information object address (IOA). Leave Common address (empty = gateway) empty to use the common address of the gateway. The name is built for you, for example %iec104:M_ME_NC_1/4001.
Name, Cluster ID and Description are common to all drivers: see Gateways. The form shows only the fields of the selected Type.
| Label | JSON key | Default | Role | Description |
|---|---|---|---|---|
| Type | json.type |
client |
both | client: the gateway is the controlling station. server: the gateway is the controlled station. |
| Host (controlled station) | json.host |
(empty) | client | IP address or host name of the RTU or substation gateway. Required. |
| Listen address | json.listenAddress |
(empty) | server | IP address of the box to listen on. Empty: all interfaces. |
| Port | json.port |
2404 |
both | Client: port of the remote station. Server: listening port of the box. |
| Common address (CA) | json.commonAddress |
1 |
both | Station number, 1 to 65534. Used by the addresses that do not name a common address. Client: every common address in use is interrogated. Server: the box answers for this common address and for those named in its addresses. |
| Time base | json.timeBase |
utc |
both | Time base of the time tags (CP56Time2a), read and sent: utc (recommended by the standard) or local (local time of the box). The standard carries no time zone: use the same setting as the other end. |
| Originator address (OA) | json.originatorAddress |
0 |
client | Originator address (0 to 255) put in the commands and interrogations sent by the gateway. 0: not used. |
| Interrogation period (s) | json.interrogationPeriod |
0 |
client | Seconds between two general interrogations. 0: one interrogation when the connection opens, then only the changes sent by the station (normal operation). |
| Counter interrogation | json.counterInterrogation |
off | client | Also interrogates the counters (C_CI_NA_1) with every general interrogation. Without it, counters (M_IT_NA_1) arrive only when the station sends them by itself. |
| Clock synchronisation | json.clockSync |
off | client | Sends the box time to the station when the connection opens (C_CS_NA_1). Enable only when the station has no other time source. |
| Use the station time tags | json.deviceTime |
on | client | On: the date of a value is the time tag sent by the station, when there is one. Off: always the time of reception by the box. |
| Insert discovered points | json.autoInsert |
off | client | Creates an address for every point reported by the station and not configured yet. Commands are never reported: create them by hand. |
| Command timeout (s) | json.commandTimeout |
10 |
client | Seconds to wait for the station to confirm a command. Without confirmation the write fails with timeout. |
| Commands with time tag | json.commandTimeTag |
off | client | Sends commands with a time tag (types 58 to 64 instead of 45 to 51). Some stations require it. |
| Max. controlling stations | json.maxConnections |
4 |
server | Number of controlling stations connected at the same time. |
| Allowed IP addresses | json.allowedClients |
(empty) | server | IP addresses of the controlling stations allowed to connect, comma separated. Empty: any address. |
| Events with time tag | json.timeTag |
on | server | On: changes are sent with their time tag (types 30 to 37). Off: without time tag (types 1 to 15), for a controlling station that does not handle time-tagged types. |
| k (sent, unacknowledged) | json.k |
12 |
both | Maximum number of data frames sent without acknowledge. Must be the same on both sides. |
| w (acknowledge after) | json.w |
8 |
both | An acknowledge is sent at the latest after w received data frames. Recommended: not more than two thirds of k. |
| t0 connection timeout (s) | json.t0 |
30 |
client | Wait for the TCP connection. At most 25 s are applied: the box restarts by itself a gateway that is not connected after 30 seconds. |
| t1 acknowledge wait (s) | json.t1 |
15 |
both | Wait for the acknowledge of a sent frame. When exceeded, the link is closed and opened again. |
| t2 acknowledge delay (s) | json.t2 |
10 |
both | A received frame is acknowledged after this time when no data is sent in the meantime. Must stay below the t1 of the other side. |
| t3 idle test period (s) | json.t3 |
20 |
both | Time without reception before a test frame (TESTFR) is sent. |
Changes to the gateway are applied when the driver restarts, which saving the gateway does.
Client reading an RTU at 192.168.10.20, station 12, counters included:
{
"type": "client",
"host": "192.168.10.20",
"port": 2404,
"commonAddress": 12,
"timeBase": "utc",
"counterInterrogation": true,
"autoInsert": false,
"commandTimeout": 10,
"k": 12, "w": 8, "t0": 30, "t1": 15, "t2": 10, "t3": 20
}
Server for two SCADA front ends:
{
"type": "server",
"listenAddress": "",
"port": 2404,
"commonAddress": 1,
"timeBase": "utc",
"maxConnections": 2,
"allowedClients": "10.20.0.11, 10.20.0.12",
"timeTag": true,
"k": 12, "w": 8, "t1": 15, "t2": 10, "t3": 20
}
%iec104:[<CA>/]<TYPE>/<IOA>
| Part | Meaning | Values |
|---|---|---|
<CA> |
Common address of the station. Optional. | 1 to 65534. Omitted: Common address (CA) of the gateway. |
<TYPE> |
ASDU type, always written without time tag (see 3.2). | One of the 15 types of the table below. |
<IOA> |
Information object address. | 0 to 16777215. |
A point sent with a time tag arrives on the address of the same type without time tag: an M_ME_TF_1 (36) event updates %iec104:M_ME_NC_1/<IOA>.
Examples:
%iec104:M_ME_NC_1/4001 — short float measurement, object 4001 of the gateway common address%iec104:2/M_DP_NA_1/200 — double point, object 200 of common address 2%iec104:C_SC_NA_1/5000 — single command, object 5000The address table shows the Type, CA and IOA of each address in their own columns.
| Type | Type ID (with time tag) | Meaning | Values |
|---|---|---|---|
M_SP_NA_1 |
1 (30) | Single point | 0 / 1 |
M_DP_NA_1 |
3 (31) | Double point | 1 = OFF, 2 = ON, 0 and 3 = indeterminate |
M_ST_NA_1 |
5 (32) | Step position | -64 to 63 |
M_BO_NA_1 |
7 (33) | Bitstring 32 bit | 0 to 4294967295 |
M_ME_NA_1 |
9 (34) | Measured value, normalised | -1 to +1 |
M_ME_NB_1 |
11 (35) | Measured value, scaled | 16-bit integer |
M_ME_NC_1 |
13 (36) | Measured value, short float | float |
M_IT_NA_1 |
15 (37) | Integrated total (counter) | 32-bit integer |
C_SC_NA_1 |
45 (58) | Single command | 0 / 1 |
C_DC_NA_1 |
46 (59) | Double command | 1 = OFF, 2 = ON |
C_RC_NA_1 |
47 (60) | Regulating step command | 1 = lower, 2 = higher |
C_SE_NA_1 |
48 (61) | Set point, normalised | -1 to +1 |
C_SE_NB_1 |
49 (62) | Set point, scaled | 16-bit integer |
C_SE_NC_1 |
50 (63) | Set point, short float | float |
C_BO_NA_1 |
51 (64) | Bitstring 32 bit command | 0 to 4294967295 |
M_ types are monitoring points, C_ types are commands. For M_SP_NA_1, C_SC_NA_1, M_DP_NA_1, C_DC_NA_1 and C_RC_NA_1, true and false are accepted as well (double types: true = ON = 2, false = OFF = 1).
| Label | JSON key | Default | Description |
|---|---|---|---|
| Scale | json.scale |
(empty) | Measurements, set points and counters: value = bus value × scale + offset, and the reverse when sending. Needed for a normalised value, which travels between -1 and +1: scale = full scale (for example 400 for ±400 A). Empty: no scaling. |
| Offset | json.offset |
(empty) | Added after the scale (see above). |
| COV | json.cov |
(empty) | Monitoring points. Client: minimum change to emit a received value; empty = on every change; 0 = every received value, even unchanged. Server: minimum change since the last transmission to send an event to the controlling station; the local value and the general interrogation always follow. |
| Qualifier | json.qualifier |
0 |
Client commands. Single, double and regulating step commands: 0 = defined by the station, 1 = short pulse, 2 = long pulse, 3 = persistent output. Set points: 0. |
| Select before operate | json.sbo |
off | Client commands. The command is selected first and executed only after the station confirmed. Enable when the station requires it for this point. |
The form shows only the fields that apply to the type of the address. Log and Store value work the same way for every driver: see Log and Store value policies.
| Property | Value |
|---|---|
| Readable | Yes. Client: the last value received from the station; a point never received yet is read from the station. Server: the local value. |
| Writable | Client: C_ addresses only (a write sends the command). Server: all addresses (see section 5). |
| Created automatically | Client, with Insert discovered points: monitoring points reported by the station. Otherwise no. |
| Routable | Yes |
| Loggable | Yes |
When the connection opens, the driver runs a general interrogation of the gateway common address and of every common address named in the addresses. The station answers with the current state, then sends each change by itself. A station that signals the end of its initialisation is interrogated again.
The quality bits sent by the station appear in the address status, for example ! invalid, not topical (also substituted, blocked, overflow). A value marked invalid does not replace the last valid value.
Thirty seconds after the first general interrogation at the latest, the driver writes a summary in the log: number of configured points reported, configured points missing, points reported but not configured. A configured point that the station did not report gets the status ! not reported by the station. Counters are not part of the general interrogation and are not counted.
Counters (M_IT_NA_1) arrive only when the station sends them, or with every interrogation when Counter interrogation is checked.
Writing a value to a C_ address sends the command to the station. The write succeeds when the station confirms the command within Command timeout (s); otherwise it fails with timeout or with the cause given by the station. With Select before operate, the driver selects the point, waits for the confirmation, then executes. With Commands with time tag, the command carries the time of the box.
M_ addresses are read-only in client mode: a write is refused.
Check Insert discovered points during the commissioning: the addresses are created with the type and IOA reported by the station (common address omitted when it is the one of the gateway). Uncheck it afterwards, so that a change on the station side does not add addresses unnoticed. When it is off, the log lists the first points reported but not configured.
M_ address (route, logic module, API, interface) updates the point and sends it at once to every connected controlling station that started the data transfer, with a time tag when Events with time tag is checked. COV filters these events; the value served at the next general interrogation is always the current one.C_ address as a new value: route it to the driver that must act. A command on an object that has no address is refused (unknown IOA). Writing a C_ address locally only changes its value, nothing is sent.
Right-click in the address table and choose Monitor to see the frames sent and received, live: time, direction (RX / TX), remote station, frame format, sequence numbers N(S) / N(R), decoded content and raw bytes. The monitor stops after 5 minutes. Use it to check the common address, the types and the IOA actually sent by the other end.
Gateway: client to 192.168.10.20, common address 12 (see 2.1).
| Address | JSON | Purpose |
|---|---|---|
%iec104:M_ME_NC_1/4001 |
{ "cov": 0.5 } |
Active power of the feeder, kW, emitted when it moves by 0.5 kW |
%iec104:M_ME_NA_1/4010 |
{ "scale": 400 } |
Current, normalised value with a full scale of 400 A |
%iec104:2/M_DP_NA_1/200 |
Breaker position of the station with common address 2 (1 = open, 2 = closed) | |
%iec104:C_SC_NA_1/5000 |
{ "qualifier": 1, "sbo": true } |
Single command with short pulse and select-before-operate |
Route the measurements to a logger or to BACnet, and write 1 to %iec104:C_SC_NA_1/5000 to send the command.
Gateway: server, common address agreed with the operator, Allowed IP addresses = the operator front ends (see 2.1).
| Address | Fed by | Purpose |
|---|---|---|
%iec104:M_ME_NC_1/1001 |
route from the inverter or meter (Modbus, M-Bus…) | Active power sent to the operator |
%iec104:M_SP_NA_1/2001 |
route from an inverter status | Plant in operation |
%iec104:M_IT_NA_1/3001 |
route from the energy meter | Energy counter, served on counter interrogation |
%iec104:C_SE_NC_1/6001 |
command from the operator | Power limitation set point, routed to the inverter |
| Symptom | Cause | What to do |
|---|---|---|
Client gateway stays connecting; log cannot connect to <host>:<port> |
The station is not reachable, the port is closed or the station refuses the connection. | Check Host and Port, the network route and the firewall. The driver restarts after a short delay and tries again. |
Log connection to <host>:<port> lost or connection closed by … |
The link dropped or t1 expired. | The driver restarts and reconnects. If it happens often, align k, w, t1, t2 and t3 with the station. |
Address status ! not reported by the station |
The point is configured but the station did not send it in the general interrogation. | Check the type, the IOA and the common address against the point list; use Monitor to see what the station sends. |
Log points reported by the station are not configured |
The station sends points that have no address. | Add the addresses, or enable Insert discovered points for a while. |
Command fails with timeout |
The station did not confirm within Command timeout (s). | Check that the command type and IOA exist on the station, whether it requires Select before operate or Commands with time tag. |
Command fails with invalid value |
The value does not fit the type (for example 3 on a double command). |
Write a value of the range given in 3.2. |
Values dated hours away; log time tag of … is … s ahead of the box clock |
Different time bases on both sides. | Set Time base like the other station (utc or local). |
Server: log connection from <ip> refused: address not allowed |
The client is not in Allowed IP addresses. | Add its address if it is legitimate. |
Server: log refused: too many connections |
Max. controlling stations reached. | Raise the limit or close unused connections on the SCADA side. |
Server gateway red; log cannot listen on port 2404 |
The port is used by another gateway or service, or the listen address is not an address of the box. | Use another port or fix Listen address. |
To read the driver log: open the gateway log (see Gateways and Logs and diagnostics). The log starts with a config: line that sums up the settings in use. The Monitor (section 6) shows each frame.
For developers, gateways.testGateway checks through the API that a client gateway reaches its station and that the data transfer starts (see Peers API — gateways).
Keep this gateway on Cluster ID
0: the driver restarts its process when the connection fails, which would restart every gateway of a shared cluster.