Skip to Content
On this page

HJ 212

This plugin maps HJ 212 reports to variables and provides device methods for field settings and history queries.

Compatible devices and models

Device series / model examplesConnection requirements
Pollution monitoring instruments and data loggers reporting HJ 212Match MN, password, system code and measurement codes. Devices must actively report using the frame format used by this plugin.

Configure the acquisition terminal’s platform and factors

Select HJ 212 in the terminal’s platform settings. Enter the reachable gateway IP/port, actual MN, six-character password, ST and reporting intervals. MN is the business device identity, distinct from IP, port and pollutant factor.

  1. For terminal-initiated connections use a gateway TCP server and allow its listener port. Use TCP client only when the terminal listens. Match UDP endpoints or transparently carry complete frames over serial.
  2. Inspect a complete report in the terminal/network tool. Preserve ##, body length, CRC and terminator rather than sending only CP.
  3. For report ST=32, MN=MN000001, CN=2011, add read-only String address ST=32;MN=MN000001;CN=2011. These are header filters, not factor names.
  4. CP may contain DataTime=20261203120000;a01001-Rtd=23.5,a01001-Flag=N. The variable receives that whole CP. Extract and convert a01001-Rtd separately and handle its Flag; the entire CP is not a Float.

Variable ST/MN/CN filter uploads. Device system code, MN and password target/authenticate downlink commands; setting device MN does not fill every variable filter. Use distinct MNs for multiple terminals. A TCP server must receive a terminal report before routing downlink to it.

Allow setting commands defaults off and controls time/interval changes, not uploads. Read settings/history use their method permissions. Execution timeout defaults to 30000 ms, range 100–120000; request retries default to 3, range 0–99, and apply only before acceptance. Accepted setting actions are not resent. Split history queries to respect record/byte limits and use field-clock times.

Open the plugin

Open Development Configuration → Collection Configuration, create a device, and select HJ 212 under Device Plugin.

Supported channels and data types

Channel typeCheck before configuration
UDPConfirm the local bind address, port, firewall rules, and packet source.
TCP clientConfirm the device IP, port, and network reachability from the gateway.
TCP serverThe device connects to the gateway. Only one online connection may claim the same ST, MN and password; receive a device report before sending commands.
Serial portConfirm that the port is not in use and that baud rate, data bits, stop bits, and parity match the device.

Optional data types: Boolean, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float, Double, String, and Decimal.

Address rules

The variable address matches the HJ 212 message header:

ST=<system-code>;MN=<device-id>;CN=<command-code>
  • ST is the system code, MN is the device identifier, and CN is the command code from the incoming report.
  • Fill in the values from an actual field message. Do not leave example placeholders in a production variable.
  • When the header matches, the variable receives the message’s CP data area. Use a read expression when a single pollutant field must be extracted from CP.
  • Field names are case-insensitive; use uppercase ST, MN, and CN with English semicolons for consistency.
  • Variables update from incoming reports. Use device special methods for settings and history queries rather than polling ordinary variable addresses.

Commands and history queries

In the device’s command properties, enter the field system code, device MN and six-character access password. Setting commands are disabled by default. Enable them when required and grant the caller permission to execute special methods.

Special methodParameters and result
ReadSettingsAsynccommand: 1011 (clock), 1061 (real-time interval), or 1063 (minute interval). For 1011, pollutant optionally identifies a six-character pollutant code.
SetSettingsAsynccommand: 1012, 1062, or 1064. value: field clock in yyyyMMddHHmmss, 30–3600 seconds, or 1/2/3/4/5/6/10/12/15/20/30 minutes, respectively. For 1012, pollutant is optional.
QueryHistoryAsynccommand: 2031 (daily data), 2041 (daily running time), 2051 (minute data), or 2061 (hourly data). beginTime and endTime use the field clock format yyyyMMddHHmmss. maximumRecords defaults to 512 and allows 1–4096.

A 9011 acceptance does not complete a command: the final 9012 execution result is required, together with the actual setting value for reads. History results contain complete committed records only; execution code 100 means no data. Results are capped at 1 MiB. Reduce the requested time range when the record or byte limit is exceeded.

Retries resend the exact QN and frame only before acceptance. After acceptance, the gateway waits for the execution timeout without replaying a setting action. Commands and upload batches execute serially per device. Large uploads split at complete parameter boundaries, repeat the data time, use a distinct QN per segment and wait for each 9014 acknowledgment. A field too large for a standard frame is rejected before the first send.

Device debug

Open Development Configuration → Collection Configuration, select the HJ 212 device, then open Protocol Debug at the top of the workspace.

In Field settings, select the field clock, real-time reporting interval or minute statistics interval. Clock operations optionally accept a six-character lowercase alphanumeric pollutant code; interval commands do not send this field. Read the current parameter, or confirm the device and value before setting it.

In History query, select daily statistics, running time, minute statistics or hourly statistics. Choose the start and end using the field clock and a maximum of 1–4096 records. Timestamps retain the field time without browser timezone conversion, and the start must not exceed the end.

Both tabs require permission to execute special methods and device method calls to be enabled. Setting values additionally requires control commands to be enabled. Acceptance is not completion: results retain request and execution codes and complete data. Reception monitoring remains available for incoming reports and variable mapping.

HJ 212: Receive monitor

Functions

FunctionPurpose
Last activityShow the receive time of the latest valid HJ 212 message.
Variable tableCheck the matched address, current CP value, online state, collection time, and last error.
Message statisticsReview queued, dropped, and truncated message counts.
Message logReview HJ 212 reports received by the current session.

Verify the configuration

  1. Copy ST, MN, and CN from a real test report and create a variable with the address format above.
  2. Make the same device send the command report again and confirm that a new record appears in reception monitoring.
  3. Confirm that the variable value is the report’s CP data area, the collection time updates, and the last error is empty.
  4. Send a test report with a different MN or CN and confirm that it does not update the current variable.
  5. When a single pollutant value is required, configure a read expression and verify the extracted value and data type.

Troubleshooting

SymptomCheck
No new report in reception monitoringConfirm that the device is actively reporting. Check the channel, frame boundaries, and HJ 212 message validation.
Report arrives but the variable is unchangedCompare ST, MN, and CN with the received message character by character. Remove example placeholders.
The variable shows the full CP areaThis is the default mapping. Add a read expression to extract one pollutant field.
Data from multiple devices updates one variableInclude a distinguishing MN in the variable address and add CN when commands differ.
Serial device does not respondCheck port ownership, baud rate, data bits, stop bits, parity, and channel type.