TG-LR82 (operates in 863.0–869.0 MHz and 2.4 GHz band) and TG-LR92 (operates in 900.0–928.0 MHz band and 2.4 GHz band) are LoRaWAN 1.0.4 compatible sensor tags.
User Manual:
Overview
TG-LR82 and TG-LR92 are MikroTik's first LoRa tags equipped with temperature, humidity and acceleration/orientation sensors (as well as magnetic switch for changing tag's configuration).
Generally, LoRa nodes or tags are devices which broadcast the data (which, the tags, usually get from their own built-in sensors, like the surrounding temperature or humidity) over the LoRa frequencies.
A typical LoRaWAN topology consists of 3 main elements → the server, the node and the gateway. The gateway's job is to simply forward received LoRa packets that are broadcasted by the nodes (within the same supported frequency spectrum) to the server (where they are decoded).
Once the LoRa node gets activated, it should start broadcasting "Join-request" packets, which should be captured by the gateway (over LoRa frequency) and forwarded to the server (over IP connection). If the node is registered on the server, the server should generate session keys for the node and send "Join-accept" packet back to the node (through the gateway, which acts as a "bridge" between IP and LoRa communication). As a result of this packet exchange, both ends should obtain session keys, the node should obtain a "DevAddr" from the server and a communication line between the two elements should be up and running. To the gateway, the LoRa packets/payloads broadcasted by the node will look "encrypted", however, the server, if it has a correct decoder setup, should see proper sensor captured data/values.
Operating modes
Mode | Description |
---|---|
Shutdown | Device deactivated in low power mode with all functionality disabled. Factory default mode. |
Run | Normal application functionality. |
New device is in SHUTDOWN mode and is inactive. To change device configuration or set RUN mode, use Magnet Switch input method.
Supported LoRaWAN regions
Numeric code X-Y | Common Name | ||
---|---|---|---|
1-1 | EU868 | Yes | |
2-1 | AS923_GRP1 | Yes | |
3-1 | US915 | Yes | |
4-1 | AU915 | Yes | |
5-1 | WW2G4 | Yes | Yes |
6-1 | AS923_GRP2 | Yes | |
7-1 | AS923_GRP3 | Yes | |
8-1 | IN865 | Yes | |
9-1 | KR920 | Yes |
Magnetic Switch
Device has magnet switch that can be used for configuration commands or as external input signal.
When using magnet switch for configuration user must apply sequence of 1 to 4 digits. Each digit in sequence is entered consecutively. When magnetic field is applied to device, LED starts blinking with interval 500ms ON, 500ms OFF (or according to LED Mode). When LED is switched on, internal counter is incremented starting from 0. When magnetic field is removed counter value is latched as user input digit. If magnetic field is applied again, next digit in input sequence is started. If interval after applying digit is larger than 2.5s, sequence code is executed as command.
When applying input code based on time, ensure to follow this equation: T = N - 0.5, where N is input digit and T is time in seconds to apply magnetic field. The interval between digits should be less than 1s.
If valid input command sequence is detected device executes requested operation and indicates status using device LED signals.
Sequence | PIN pro- tected | |
---|---|---|
2-1 | optional | Activate - enable RUN operating mode. |
3-1 | optional | Trigger "current-state" frame uplink. |
4-1-X | optional | Switch device profile, where X is profile number [1..6]. |
4-2-1 | optional | Set primary band to 8xx MHz or 9xx MHz (depending on the model) |
4-2-2 | optional | Set primary band to 2.4 GHz band. |
4-3-1 | optional | Enable secondary band. |
4-3-9 | optional | Disable secondary band. |
6-1 | optional | Device reset. |
6-2-9 | optional | Deactivate device. |
9-X-Y | optional | Set LoRaWAN Region as per supported LoRaWAN regions. |
6-9-9 | yes | Device factory reset |
3-1-5 | yes | Exit PIN mode. |
A-B-C-D | - | Enter PIN mode. A-B-C-D are digits of device factory PIN code. |
If applied command doesn’t exist device ignores it.
LED indications during digit input can change based on device configuration. It is possible to change or completely disable LED indications.
Sensors and Data
Device has temperature, humidity, magnetic field, acceleration/orientation sensors. Data from these sensors can be sent to LoRaWAN application server periodically or based on configurable rules.
See “ul_decoder.js” script for data field decoding details. This script is compatible with TTN JavaScript engine.
Following data fields are contained in these UL frame types:
Key | Frame types | |
---|---|---|
temperature | current-state, last-temp | Last measured temperature °C. |
avg_temperature | ema-temp | Exponential moving average of temperature samples. |
temp_histogram | temp_histogram | Epoch number and bin counter values for temperature histogram. |
humidity | current-state, last-humid | Last measured relative humidity RH%. |
humid_histogram | humid_histogram | Epoch number and bin counter values for humidity histogram. |
avg_humidity | ema-humid | Last measured relative humidity RH%. |
mag_sw_cnt_lsb | current-state | LSB of magnet switch 32bit counter value. |
mag_sw_cnt | mag-switch | Magnet switch 32bit counter value. |
mag_switch_ts | mag-switch | Last magnet switching time stamp. UNIX time or device uptime [s]. |
activity_state | current-state, full-activity, activity | Current device Activity State Code. |
activity_s | full-activity | Activity time 32bit counter [s]. |
high_activity_s | full-activity | High level activity (if configured) time 32bit counter [s]. |
total_activity_s | activity | Current device activity state. |
major_axis_orient | current-state | Approximate device Major axis orientation code. |
orientation | device-orientation | Device orientation normal vector: x, y, z. |
free_fall_event | current-state | Flag indicating the free fall event is pending. |
free_fall_cnt | motion-events | Free fall event 32bit counter. |
impact_cnt | motion-events | Impact event 32bit counter. |
impact_cnt_u16 | impact-count | Impact event 16 LSB bit counter. |
impact_cnt_x | impact-count | X axis impact event 16 LSB bit counter. |
impact_cnt_y | impact-count | Y axis impact event 16 LSB bit counter. |
impact_cnt_z | impact-count | Z axis impact event 16 LSB bit counter. |
uptime_s | dev-time | Device uptime [s]. |
unix_time | dev-time | Current device UNIX time. |
battery_mv | dev-health | Battery voltage mV. |
version_str | version | Device version data. |
serial_number | serial-number | Device serial number string. |
config_checksum | cfg-state | Device current configuration checksums. |
pending_event | current-state | Flag indicating pending device events. |
Data Frames
Each LoRaWAN uplink message may contain multiple data frames depending on maximum payload size and pending frames. See "ul_decoder.js” script for frame encoding details.
ID | Name | Description |
---|---|---|
1 | current-state | Basic sensor and state data. |
2 | device-events | List of device events with time stamp. |
3 | temp-histogram | Temperature histogram data. |
4 | humid-histogram | Humidity histogram data. |
5 | device-orientation | Orientation data. |
6 | full-activity | Complete activity data. |
7 | motion-events | Impact and free-fall event counter. |
8 | mag-switch | Full magnetic switch data. |
9 | impact-count | Detailed impact counters - including specific axis. |
10 | last-temp | Last measured temperature. |
11 | ema-temp | Exponential moving average of temperature samples. |
12 | last-humid | Last measured humidity. |
13 | ema-humid | Exponential moving average of humidity samples. |
14 | activity | Activity state and total active time. |
20 | dev-time | Device uptime and UNIX time stamp. |
21 | dev-health | Device health status: battery voltage. |
22 | version | Version information. |
23 | serial-number | Serial number string. |
24 | cfg-state | CRC of each configuration block. |
Configuring Frames
Each frame can be configured to be sent periodically, on network join and either as confirmed or unconfirmed message.
To configure frames following command must be encoded as msgpack array and sent to device as a downlink on port 2:
2,2,<profile>,<frame-id>,<ul-period-s>,<confirmed>,<on-join> profile: device profile 0..5. frame-id: frame ID number or name string. ul-period-s: interval to send frame or 0 to disable. confirmed: true/false to enabled/disable confirmed frame. on-join: true/false to enable/disable send on join event.
Examples:
Configuring dev-health frame to be sent every 180 seconds
Command: [2,2,0,21,180,false,false] can be encoded using https://msgpack.solder.party/ as bytes:
[0x97 0x02 0x02 0x00 0x15 0xCC 0xB4 0xC2 0xC2].
Activity State codes
Code | State |
---|---|
0 | IDLE |
1 | LOW |
2 | HIGH |
3 | DISABLED |
Major Axis orientation code
Code | Orientation |
---|---|
0 | XH |
1 | XL |
2 | YH |
3 | YL |
4 | ZH |
5 | ZL |
LED MODE
Numeric Code | Mode | Description |
---|---|---|
0 | HALF_DUTY_CYCLE | LED blinks with 50% duty. |
1 | SHORT_BLINK | LED blinks with short pulses on counter increment. |
2 | NO_BLINK | LED is completely disabled. |