Skip to main content
Version: current

TG-LR setup guide

Quickstart Guide

  • Register device on LoRaWAN network server. Use tg-lrx2-2.0-ul-dec.js payload decoder script if device model not supported.

  • Optionally deploy Grafana + Influx (telemetry_hub.zip) docker services for device capability evaluation.

  • Activate device by holding magnet near reed switch and wait for 2x LED blinks (~1.5s).

Functionality

New device is in SHUTDOWN mode. To activate use magnet switch commands.

Table 1 Models

ModelDescriptionSensors
TG-LR82LoRaWAN 1.0.4 Class A, B, 863.0 - 869.0 MHz band.TMP116N, HDC2010, LIS2DW12
TG-LR92LoRaWAN 1.0.4 Class A, B, 900.0 - 928.0 MHz band.TMP116N, HDC2010, LIS2DW12

Table 2 Bands

Numeric codeNameDescription
1BAND_1GHzSub-GHz operating band. Frequency range is based on device Model.
2BAND_2GHz2.4GHz ISM band.

Table 3 Operating modes

Numeric codeModeDescription
0SHUTDOWNDevice in low power mode with all functionality disabled.
1RUNDevice joins network and sends uplinks based on current profile and configuration.

Table 4 Supported regions

X-Y CodedownlinkCommon NameTG-LR82TG-LR92
1-11EU868Yes
2-12AS923_GRP1Yes
3-13US915Yes
4-14AU915Yes
WW2G4YesYes
6-17AS923_GRP2Yes
7-18AS923_GRP3Yes
8-19IN865Yes
9-110KR920Yes

LoRaWAN

Device supports Class A and B, and can operate in two frequency bands: BAND_1GHz and BAND_2GHz. User can configure periodic link check, MAC time synchronization (DeviceTimeReq) and network ADR.

Join Procedure

Once activated (RUN) device will attempt to join network. Device sends Join-Request on primary band and if Join-Accept is not received it will wait back-off interval and send next Join-Request on secondary band if enabled, otherwise primary-band again.

Join attempt interval depends on time on air for last Join-Request and total join time. See 1 section 7. If last join request used slower data rate - expect longer interval.

Join configuration commands: lora primary-band, lora second-band, lora join-cfg. See Command Encoding on how to convert text commands to binary encoding for downlink.

Once device has joined network optional periodic link check can be performed. Link check can be configured specifically for each band using lora link-chk. If link check fails device leaves network and restarts join procedure.

Any network downlink will restart link check timer to prevent unnecessary LinkCheckReq.

Time Synchronization

Device supports optional time synchronization using DeviceTimeReq MAC command. See command lora clk-sync for configuration parameters or to request immediate synchronization.

Class B

Device supports Class B operation. Class B operation can be either manually requested using lora class or device can be configured to automatically switch to class B on network join using lora cfg-class-b.

ADR Configuration

It is possible to disable network ADR and set fixed data rate using lora adr-cfg.

Leaving Network

In case of Link Check or confirmed uplink failure device leaves network and restarts join procedure.

Credentials

Device has factory configured default credentials that come with each device: DevEUI, JoinEUI, AppKey.

DevEUI and JoinEUI are IEEE 64-bit EUI (2) written MSB first. On air byte order is LSB first. See 1 section 6.2.5.

AppKey is 16 byte AES128 encryption key and is written as stored in device memory. AppKey must be kept secret!

To change JoinEUI and AppKey use commands: lora join-eui, lora net-key and lora cred. Commands lora join-eui and lora net-key can be issued in any order and multiple times to write new pending join credentials.

Once new pending credentials are written “lora cred 600,1” or “app reset 0” can be executed to attempt join with new credentials. If new credentials are not confirmed by join accept device will revert to previous. See LORA-275, LORA-276 for know issues!

Example sequence where JoinEUI and AppKey are written and join is attempted:

lora join-eui 87904163,0x00,0x16,0xC0,0x01,0xFF,0xFE,0x00,0x00
lora net-key 87904163,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F
lora cred 600
app reset 0
// device reboots and attempts join using new credentials with 600s timeout

JoinEUI from previous example can be copy/pasted as is 00 16 C0 01 FF FE 00 00 to register new device. lora join-eui parameters are MSB first.

warning

Executing lora cred <confirm-timeout-s>,87904163 will force confirm credentials without verification join attempt! You may lose access to the device!

Each LoRaWAN uplink message is formed by placing pending Data Frames ID and its contents in FPort and FRMPayload fields. All pending frames are packed in ascending order and differential encoding is used for IDs.

See tg-lrx2-2.0-ul-dec.js script for frame encoding details. This script can be used as is in application server payload decoders.

Telemetry

Device Profiles

Device has 6 configurable profiles. Each profile stores independent sensor and uplink send configuration. This allows device to quickly change operating characteristics without requiring costly downlink configuration messages. Profile can be switched using Device Commands, magnet or even based on evaluated Data Rules. For instance switching between periodic keepalive mode with uplinks few times per day to more rapid telemetry every few minutes.

MikroTik can support your specific use case, new devices with custom default configuration are available.

Devices come preconfigured with evaluation configuration to showcase some of possible use case:

Table 5 Default profile configuration

Profile NumberNameDescription
0Sensor TelemetrySend current-state, device-orientation every 5 minutes. Send remaining telemetry every 60 minutes.
1Activity MonitorSend activity, full-activity, current-state every 60 min and send activity_state events on activity idle transition.
2Magnet SwitchSend mag-switch, current-state, device-events every 60 minutes and send mag_sw_cnt event when magnet is removed for at least 15 seconds. Save up to 10 events.
3OrientationSend current-state, device-events, device-orientation every 60 minutes. Send device-orientation frame in case of fast rotation by 30 degrees after idle ~30 seconds. Send angle_1 event in case of specific orientation: V=(0,1,1). Save up to 3 events.
4Asset MonitorSend asset healt info every 3h with different frames based on events.
5Empty

See default-cfg.txt for exact factory default configuration commands.

Configuring Sensors

Sampling Intervals

Periodic temperature, humidity and battery voltage sampling can be configured for specific use cases using data poll-cfg command. Device can sample data at a higher rate than uplink frames are sent. This gives opportunity to send average values or to perform rule based decisions. Since sampling interval influences device power consumption this can be leveraged to improve lifetime.

Averaging

Device also tracks average of sampled values in: temperature_ema, humidity_ema, battery_mv_ema, angle_ema. Command data ema-cfg configures exponential moving average (EMA) period and optionally can send EMA values in current-state, dev-health, device-orientation if send-ema-* is enabled.

Count parameters temp-cnt, humid-cnt, bat-cnt, orient-cnt in data ema-cfg determine coefficient a used for moving average calculation. Moving EMA is calculated based on previous value ema and new value sample as:

ema(t) = sample(t) * a + ema(t-1) * (1 - a)

To get approximate time constant t of EMA you need to use sampling intervals configured by data poll-cfg and data orient-cfg (interval) and respective count parameter (N):

t ~ (N + 1) * interval / 2

To get required count parameter value for data ema-cfg:

N ~ 2 * t / interval - 1

Example:

Temperature sampling interval th-poll-int is configured to 30s using data poll-cfg. To configure EMA with time constant t ~ 60 minutes:

temp-cnt = 2 * 3600 / 30 - 1 = 239

Assuming profile #0 is used and we don’t want to change other parameters we need to send command:

data ema-cfg 1,239
Histogram

All periodic samples are added to temperature and humidity histograms. Histograms can be used in addition to regular telemetry or simply stand alone to monitor temperature and humidity distribution. Configure bins and epoch intervals using data temp-histo-cfg, data humid-histo-cfg commands and/or enable temp-histogram, humid-histogram frames. All histogram frames contain epoch number to detect histogram counter reset. Since frame size is limited to 1B per bin, if internal bin counter value is above 255 histogram will be normalized (probability type) for uplink.

Example configuration:

data temp-histo-cfg 1,86400,0,0,1,1,-10,0,10,15,17.5,20,22.5,25.0,30
data humid-histo-cfg 1,86400,0,0,1,1,10,20,30,40,50,60,70,80,90
Orientation

Fig. 1 Device accelerometer axis.

Periodic device 3D orientation sampling relative to Earth can be configured using command: data orient-cfg. In addition 3 user orientation vectors ref-1, ref-2, ref-3 can be configured to detect specific device orientations. User variables angle_1, angle_2, angle_3 contain current angle between device last sampled orientation and user defined vector. These variables can be used in Data Rules to trigger on specific orientation. angle_ema is angle between last sampled device orientation and EMA value of samples. In addition coarse orientation is also available with major_axis_orientation variable.

Table 6 major_axis_orientation description

ValueNumeric codeDescription
XH0X up
HL1X down
YH2Y up
YL3Y down
ZH4Z up
ZL5Z down
DISABLED7sensor disabled

Coarse orientation has advantage that it is sent in current-state frame.

Activity Monitor

Device has activity monitoring service based on accelerometer. This service will automatically manage simple state machine that determines movement/activity. activity_s, high_activity_s, total_activity_s count accumulated time in each state activity_state, activity_state_etm hold state information.

Command data activity-cfg can be used to configure mode and thresholds for activity monitoring. data activity-cal can be used to automatically perform calibration for specific mode.

level1-th and level2-th units are 1/64 * 2G irrespective of other accelerometer settings (like in data acc-cfg). level2-cnt is internally computed and not user configurable. level2-cnt is always in range 7..15 and calculated as:

level2-cnt = 7 + round((1 - ((level2-th - level1-th - 1) / 61)) * 8)

Table 7 activity_state description

Numeric codeValue
0IDLE
1LOW
2HIGH
3DISABLED
Single Mode

Mode in data activity-cfg is set to single.

  • If accelerometer sample value in any axis is above level1-th device transitions from IDLE to LOW state.

  • If all samples for at least 1.3s are below level1-th device transitions from LOW to IDLE state.

Example to set profile #0 single mode with threshold 0.25G:

data activity-cfg 1,1,8,63
Dual Mode

Mode in data activity-cfg is set to dual.

In dual mode LOW state has two sub states: LOW1 and LOW2 that both represent LOW. Device will report LOW state during both of these and actvity counter values are incremented as if in LOW state. Only difference is transition logic between these states.

Table 8 activity_state dual mode state transitions

CurrentNextCondition
IDLELOW2sample > level1-th
LOW2LOW1sample < level2-th at least 5s
LOW1LOW2sample > level1-th
LOW2HIGHsample > level2-th at least level2-cnt times
LOW1IDLEsample < level1-th at least 5s
HIGHLOW1sample < level2-th at least 5s

Example to set profile #0 dual mode with thresholds 0.25G and 0.5G:

data activity-cfg 1,2,8,16
Calibration

In addition to manually configuring level1-th and level2-th there is activity calibration functionality. Executing command data activity-cal will perform auto calibration of cal-level. level-one will calibrate level1-th and level-two will calibrate level2-th for all profiles selected in profile-mask. For dual mode you can run level-one and level-two in sequence. Calibration time is 15s. This functionality is mostly suited for periodic motion/vibration.

It may be useful to enable LED during calibration procedure or activity monitor testing to ensure correct operation.

Example to calibrate profile #0 with single level activity monitor:

warning

Activity calibration with orientation enabled causes fault and device reboot. Disable using data orient-cfg before calibration and re-enable after finished. See LORA-279.

  • Place device in environment with periodic motion/activity to calibrate.

  • Send commands:

data activity-cfg 1,1,,,1
data activity-cal 1,1,1
  • Observe LED periodic blink 2x/1.5s for ~ 15s.

  • Test motion detection. During LOW activity device will blink LED 3x/1s.

  • If calibration results are acceptable send command to disable LED:

data activity-cfg 1,,,,0

Example to calibrate profile #0 with dual level activity monitor:

  • Place device in environment with periodic motion/activity for level 1 calibration.

  • Send commands:

data activity-cfg 1,2,,,1
data activity-cal 1,1,1
  • Observe LED periodic blink 2x/1.5s for ~ 15s.

  • Place device in environment for level 2 calibration.

  • Send commands to calibrate level 2:

data activity-cal 1,2,1
  • Observe LED periodic blink 2x/1.5s for ~ 15s.

  • Test motion detection. During HIGH activity device will blink LED 6x/1s.

  • If calibration results are acceptable send command to disable LED:

data activity-cfg 1,,,,0

After calibration level1-th and level2-th can be manually changed using command data activity-cfg.

Impact and Free fall

Command data acc-cfg can be used to configure device accelerometer for basic impact and free-fall detection. Frames: motion-events, impact-count contain relevant data fields. current-state contains impact_evnt, free_fall_evnt flags that indicate new event. These can be used if explicit read is preferred.

Variables impact_cnt, impact_cnt_x, impact_cnt_y, impact_cnt_z, impact_etm, free_fall_cnt, free_fall_etm allow rule based logic.

If Activity Monitor is enabled impact and free fall detection can’t be used and will be ignored.

Data Rules

Up to 32 custom user rules are configurable using commands: data set-rule, data del-rule. Rules have test expression, optional input rules and actions to perform.

Command syntax to add or override rules:

data set-rule [<rule-num>],<test-expr>,[<input-expr>],[<switch-profile>],[<make-event-0>],[<make-event-1>], [<make-event-2>],[<make-event-3>],[<send-frame-0>],[<send-frame-1>],[<send-frame-2>],[<send-frame-3>],[<clr-timer-mask>]
Test Expression

<test-expr>: [^] variable-type <operator> <argument>

[^]use variable absolute value in expression
variable-typevariable name or ID
<operator>>, >=, <, <=, ==, !=, %
<argument>numeric value

Example:

data set-rule 0,profile == 0
data set-rule 1,^temperature > 30.55
data set-rule 2,impact_etm < 60

Same rules can be given using User Variables numeric IDs:

data set-rule 0,0 == 0
data set-rule 1,^8 > 30.55
data set-rule 2,24 < 60
Input Expression

Input expression is used if rule needs to depend on result of other rules. This allows constructing sophisticated logic based on multiple test expressions.

<input-expr>: [&][|][!]<input-rule>[<]

[&]logical AND of <rule-num> and <input-rule>
[|]logical OR of <rule-num> and <input-rule>
[!]logical NOT of input value
<input-rule>rule number to add as a input
[<]use rule combined state as input value, otherwise local state.

Following configuration will send current-state data frame if magnet switch changed state less than 15s ago and temperature or humidity are out of range (-5..55 and 10..90%):

data del-rule
data set-rule 0,temperature < -5
data set-rule 1,temperature > 55
data set-rule 2,humidity < 10
data set-rule 3,humidity > 90,|0|1|2
data set-rule 4,mag_sw_etm < 15,&3<,,,,,,current-state

Input rules are evaluated in numeric order irrespective of ordering in set-rule command.

Actions

Rule Test Expression evaluated value represents data rule local state. Local state evaluated with optional input rules represents combined state.

If combined state changes to TRUE state optional rule actions are performed: profile switching, event generation, frame scheduling, user timer reset.

If <switch-profile> parameter is given, current profile will be changed. For example if temperature drops below 15 C device will switch to profile 5 (Device Profiles):

data set-rule 1,temperature < 15,,5

Up to 4 different Data Frames can be scheduled per rule:

data set-rule 0,impact_cnt % 10,,,,,,,current-state,device-orientation,dev-health,ema-temp

Rule chaining can be used if more than 4 frames should be sent.

Up to 4 different events can be generated per rule:

data set-rule 0,impact_cnt % 10,,,temperature_ema,humidity_ema,activity_state,timer_1
Events

Actions can optionally generate events. Events are time stamped User Variables that are sent in device-events frame. Event storage can be configured using data event-cfg command. If device has received absolute time using Time Synchronization events will have POSIX time stamp. This allows collecting specific historic data to report later. Event uplink can be triggered periodically, based on some rule or manually using downlink command.

Magnet Switch

Device has magnet switch that can be used for command input or as magnetic field sensor. If unused, command input can be completely disabled or PIN protected using mag svc command.

Unique PIN code comes with each device.

Command Input

User must apply command sequence of 1 to 4 digits. Each digit is entered consecutively. After 2.5s idle, valid input command is executed and device indicates result using LED. Successfully executed command is indicated with 3x 0.2s LED blinks and failure is 1s long LED pulse. Invalid commands are ignored.

When magnetic field is applied to device, LED starts blinking with interval 500ms ON, 500ms OFF (or according to mag cfg configured blink-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 is evaluated.

When applying input code based on time, ensure to follow this equation: T = N - 0.5, where N is input digit from 1 to 9 and T is time in seconds to apply magnetic field. The interval between digits must be less than 2.5s, but more than 200ms.

Some commands require PIN mode to be entered and some can be optionally protected by PIN mode. See table Magnet switch commands. To enter PIN mode, user must apply sequence of PIN digits provided with the device. Once PIN mode is entered it will expire after configurable time and device will return back to normal mode.

It is also possible to completely disable magnet commands. Only way to re-enable is using LoRaWAN downlink command. This can be useful if magnet sensor is used only for detecting external signals and no user commands are expected or allowed.

Table 9 Magnet switch commands

SequencePIN modeCommand description
2optionalActivate - enable RUN mode.
3-1optionalTrigger current-state frame uplink.
4-1-XoptionalSwitch device profile, where X is Profile Number + 1 [1..6].
4-2-1optionalSet primary band to BAND_1GHz.
4-2-2optionalSet primary band to BAND_2GHz.
4-3-1optionalEnable secondary band.
4-3-9optionalDisable secondary band.
6-1optionalDevice restart.
6-2-9optionalDeactivate device - SHUTDOWN mode.
9-X-YoptionalSet region for sub GHz band as per Supported regions.
6-9-9mandatoryDevice factory reset.
3-1-5mandatoryExit PIN mode.
A-B-C-DEnter PIN mode. A-B-C-D are digits of device factory PIN code.
5-3-1optionalReserved.

LED indications during digit input can be changed based on device configuration. It is possible to change or completely disable LED indications using mag cfg.

Magnet Sensor

Magnetic sensor is always operational (even when commands are applied). This sensor can be utilized to detect switching events mag_sw_flag or to count number of these events mag_sw_cnt. Device can report current switch state, number of state changes and last time stamp (UNIX/uptime) mag_switch_ts. Additionally you can create rules based on these attributes.

Command Encoding

Device commands are binary encoded to reduce downlink message size. We provide Python utilities to verify, encode and publish commands as LoRaWAN binary downlink messages.

tg-lrx2-utils.zip or install with pip install tg-lrx2-utils

Example configuration to set current-state and activity frame uplink every 600 seconds and mag-switch every 43200 seconds as confirmed message:

# lora-script.txt
frame set-cfg 1,601,0,0,current-state,activity
frame set-cfg 1,43200,1,0,mag-switch

We can use tg-lrx2-encode to convert text commands to binary messages for downlink:

tg-lrx2-encode --script ./lora-script.txt --dev-desc ./tg-lrx2-2.0-desc.yml --max-len=50 --out ./lora-pub.yml

tg-lrx2-2.0-desc.yml contains full device characterization and is used by other tools. Make sure to use correct file for specific device and FW version!

lora-pub.yml will contain serialized binary payloads to use for downlink. You can either manually schedule them using available web tools or use tg-lrx2-pub to schedule them on The Things Network:

tg-lrx2-pub --host ./ttn-app.yml --dl-msg ./lora-pub.yml device-id

Example TTN credential file:

# ttn-app.yml
app-id: "ttn-tag-demo@ttn"
host: "eu1.cloud.thethings.industries"
port: 1883
user: "ttn-tag-demo@ttn"
password: "NNSXS.5G..."

tg-lrx2-encode accepts command strings on CLI as well. This can be used for single or few lines of commands:

tg-lrx2-encode --cmd $'frame send device-orientation\napp profile 1,0' --dev-desc ./tg-lrx2-2.0-desc.yml --max-len=50 --out ./lora-pub.yml
tg-lrx2-pub --host ./ttn-app.yml --dl-msg ./lora-pub.yml device-id

Device Commands

All device commands consist of group-name and cmd-name. Optional parameters are given in square brackets. Parameters must be comma separated for tg-lrx2-encode script. group-name and cmd-name can also be comma separated but spaces are also accepted.

Example:

app factory-reset <key>,[<fw-def>],<delay-ms>

Parameters <key> and <delay-ms> are mandatory, but <fw-def> is optional and can be omitted:

app factory-reset 984651411,,2500

Each parameters has valid input range and format. Some parameters allow only specific choice between parameters or choice between ranges.

Most parameters accept integer values. %f indicates that parameter accepts fractional value. Use of these values results in larger downlink payload so if possible integer values should be preferred. variable-type indicates that parameter accepts either user variable name or respective integer ID. frame-type indicates that parameter accepts either data frame name or integer ID. tg-lrx2-encode automatically converts these names to numeric ID.

app set-mode

app set-mode <mode>
Set device operating mode
ParameterRangeDescription
mode0SHUTDOWN
1RUN

app profile

app profile <profile-num>,<make-default>
Switch active profile and optionally make default
ParameterRangeDescription
profile-num0..5
make-default0no
1yes

app reset

app reset <type>
System reset
ParameterRangeDescription
type0board
1app only

app factory-reset

app factory-reset <key>,[<fw-def>],<delay-ms>
Reboot device, clear saved configuration and set to defaults (optional)
ParameterRangeDescription
key984651411
fw-def784565141don’t apply default configuration
delay-ms0..65535

app led

app led [<enable>]
Configure application LED signals
ParameterRangeDescription
enable0no
1yes

app set-time

app set-time [<unix-time-s>],<uptime-s>
Set UNIX time relative to device uptime
ParameterRangeDescription
unix-time-s0..4294967295
uptime-s0..4294967295

lora set-region

lora set-region <region-code>
Set LoRaWAN region for sub GHz band
ParameterRangeDescription
region-code1EU868
2AS923-1
3US915
4AU915
7AS923-2
8AS923-3
9IN868
10KR920

lora primary-band

lora primary-band <band>
Select primary band
ParameterRangeDescription
band1<1GHz
22.45GHz

lora second-band

lora second-band <mode>
Enable or disable secondary band
ParameterRangeDescription
mode0off
1on

lora join-cfg

lora join-cfg <band>,<duty>
Configure join duty cycle for band
ParameterRangeDescription
band1<1GHz
22.45GHz
duty00.1%
1..254
2551%
lora link-chk <band>,<int-minutes>
Set band specific link check interval and timeout
ParameterRangeDescription
band1<1GHz
22.45GHz
int-minutes0off
5..500000

lora adr-cfg

lora adr-cfg <en-netw-adr>,[<fixed-data-rate>]
Enable network ADR or configure fixed data rate
ParameterRangeDescription
en-netw-adr0off
1on
fixed-data-rate0..6

lora clk-sync

lora clk-sync [<int-minutes>],[<leap-sec>],<sync-now>,[<retry-s>],[<retry-cnt>]
Absolute time synchronization
ParameterRangeDescription
int-minutes0off
1..65535
leap-sec-128..127
sync-now0no
1yes
retry-s0..255
retry-cnt0..255

lora cfg-class-b

lora cfg-class-b [<auto-en>],[<ping-slot-int-s>]
Configure LoRaWAN Class B
ParameterRangeDescription
auto-en0off
1on
ping-slot-int-s1
2
4
8
16
32
64
128

lora class

lora class <class>
Switch LoRaWAN class
ParameterRangeDescription
class0A
1B

lora join-eui

lora join-eui <cred-ch-key>,<eui-0>,<eui-1>,<eui-2>,<eui-3>,<eui-4>,<eui-5>,<eui-6>,<eui-7>
Override network JoinEUI
ParameterRangeDescription
cred-ch-key87904163
eui-00..255
eui-10..255
eui-20..255
eui-30..255
eui-40..255
eui-50..255
eui-60..255
eui-70..255

lora net-key

lora net-key <cred-ch-key>,<key-0>,<key-1>,<key-2>,<key-3>,<key-4>,<key-5>,<key-6>,<key-7>,<key-8>,<key-9>,<key-10>, <key-11>,<key-12>,<key-13>,<key-14>,<key-15>
Override network AppKey
ParameterRangeDescription
cred-ch-key87904163
key-00..255
key-10..255
key-20..255
key-30..255
key-40..255
key-50..255
key-60..255
key-70..255
key-80..255
key-90..255
key-100..255
key-110..255
key-120..255
key-130..255
key-140..255
key-150..255

lora cred

lora cred [<confirm-timeout-s>],[<action>]
User network credential management
ParameterRangeDescription
confirm-timeout-s60..65535revert if not joined
action0clear pending
1try now
87904163force confirm

frame send

frame send <frame-id>,…
Schedule uplink frames
ParameterRangeDescription
frame-idframe-type

frame set-cfg

frame set-cfg <profile-mask>,[<ul-period-s>],[<confirmed>],[<on-join>],<frame-id>,…
Set uplink frame configuration
ParameterRangeDescription
profile-mask1..63bitfield
ul-period-s0off
1..65535
confirmed0no
1yes
on-join0no
1yes
frame-idframe-type

frame clear-cfg

frame clear-cfg <profile-mask>
Clear all frame config for specified profiles (as if ‘set-cfg profile-mask,0,0,0,…’)
ParameterRangeDescription
profile-mask1..63bitfield

mag cfg

mag cfg [<pin-timeout>],[<pin-protect>],[<blink-mode>]
Set configuration
ParameterRangeDescription
pin-timeout0..65535
pin-protect0off
1on
blink-mode0half duty
1pulse
2off

mag svc

mag svc <new-state>,<key>
Enable or disable magnet command interface
ParameterRangeDescription
new-state0off
1on
key649864801

data sample

data sample
Force sensor polling

data next-epoch

data next-epoch <type>
Manually start next histogram epoch
ParameterRangeDescription
type

data poll-cfg

data poll-cfg <profile-mask>,[<th-poll-int>],[<sync-period>],[<on-mag-switch>],[<on-activity-change>],[<on-impact>], [<on-free-fall>],[<on-ul-stale>],[<bat-poll-int>]
Set data polling configuration
ParameterRangeDescription
profile-mask1..63bitfield
th-poll-int1..4294967295temperature and humidity
sync-period0no
1yes
on-mag-switch0no
1yes
on-activity-change0no
1yes
on-impact0no
1yes
on-free-fall0no
1yes
on-ul-stale0no
1yes
bat-poll-int1..4294967295battery voltage

data temp-histo-cfg

data temp-histo-cfg <profile-mask>,[<epoch-interval-s>],[<epoch-interval-cnt>],[<epoch-max-bin-cnt>], [<frame-on-new-epoch>],[<lim-divider>],[<bin-limit-0>],[<bin-limit-1>],[<bin-limit-2>],[<bin-limit-3>],[<bin-limit-4>], [<bin-limit-5>],[<bin-limit-6>],[<bin-limit-7>],[<bin-limit-8>]
Set temperature histogram configuration
ParameterRangeDescription
profile-mask1..63bitfield
epoch-interval-s0off
1..4294967295
epoch-interval-cnt0off
1..4294967295
epoch-max-bin-cnt0off
1..4294967295
frame-on-new-epoch0no
1yes
lim-divider1..4294967295
bin-limit-0-128..127°C
%f
bin-limit-1-128..127°C
%f
bin-limit-2-128..127°C
%f
bin-limit-3-128..127°C
%f
bin-limit-4-128..127°C
%f
bin-limit-5-128..127°C
%f
bin-limit-6-128..127°C
%f
bin-limit-7-128..127°C
%f
bin-limit-8-128..127°C
%f

data humid-histo-cfg

data humid-histo-cfg <profile-mask>,[<epoch-interval-s>],[<epoch-interval-cnt>],[<epoch-max-bin-cnt>], [<frame-on-new-epoch>],[<lim-divider>],[<bin-limit-0>],[<bin-limit-1>],[<bin-limit-2>],[<bin-limit-3>],[<bin-limit-4>], [<bin-limit-5>],[<bin-limit-6>],[<bin-limit-7>],[<bin-limit-8>]
Set humidity histogram configuration
ParameterRangeDescription
profile-mask1..63bitfield
epoch-interval-s0off
1..4294967295
epoch-interval-cnt0off
1..4294967295
epoch-max-bin-cnt0off
1..4294967295
frame-on-new-epoch0no
1yes
lim-divider1..4294967295
bin-limit-00..99RH%
%f
bin-limit-10..99RH%
%f
bin-limit-20..99RH%
%f
bin-limit-30..99RH%
%f
bin-limit-40..99RH%
%f
bin-limit-50..99RH%
%f
bin-limit-60..99RH%
%f
bin-limit-70..99RH%
%f
bin-limit-80..99RH%
%f

data ema-cfg

data ema-cfg <profile-mask>,[<temp-cnt>],[<humid-cnt>],[<bat-cnt>],[<orient-cnt>],[<send-ema-temp>],[<send-ema-humid>], [<send-ema-bat>],[<send-ema-orient>]
Set exponential moving average (EMA) configuration
ParameterRangeDescription
profile-mask1..63bitfield
temp-cnt1..32766a = 2 / (temp-cnt + 1)
humid-cnt1..32766a = 2 / (humid-cnt + 1)
bat-cnt1..32766a = 2 / (bat-cnt + 1)
orient-cnt1..32766a = 2 / (orient-cnt + 1)
send-ema-temp0no
1yes
send-ema-humid0no
1yes
send-ema-bat0no
1yes
send-ema-orient0no
1yes

data activity-cfg

data activity-cfg <profile-mask>,[<mode>],[<level1-th>],[<level2-th>],[<en-led>]
Set activity monitor configuration
ParameterRangeDescription
profile-mask1..63bitfield
mode0off
1single
2dual
level1-th1..63
level2-th1..63
en-led0off
1on

data acc-cfg

data acc-cfg <profile-mask>,[<full-scale>],[<en-impact-x>],[<en-impact-y>],[<en-impact-z>],[<impact-th>],[<impact-dur>], [<en-ff>],[<ff-th>],[<ff-dur>],[<data-rate>],[<filter>],[<lp-mode>],[<low-noise>]
Set accelerometer configuration
ParameterRangeDescription
profile-mask1..63bitfield
full-scale02G
14G
28G
316G
en-impact-x0off
1on
en-impact-y0off
1on
en-impact-z0off
1on
impact-th1..63impact-th * full-scale / 64
impact-dur0..3
en-ff0off
1on
ff-th0..7
ff-dur0..63
data-rate2Hz
13
25
500
100
200
filter2cutoff = data-rate/filter
4
10
20
lp-mode0..3
low-noise0no
1yes

data orient-cfg

data orient-cfg <profile-mask>,[<enable>],[<max-1G-offset>],[<poll-interval-s>],[<ref-1-x>],[<ref-1-y>],[<ref-1-z>], [<ref-2-x>],[<ref-2-y>],[<ref-2-z>],[<ref-3-x>],[<ref-3-y>],[<ref-3-z>]
Set orientation sense configuration
ParameterRangeDescription
profile-mask1..63bitfield
enable0off
1on
max-1G-offset1..20
poll-interval-s1..4294967295
ref-1-x-32768..32767
ref-1-y-32768..32767
ref-1-z-32768..32767
ref-2-x-32768..32767
ref-2-y-32768..32767
ref-2-z-32768..32767
ref-3-x-32768..32767
ref-3-y-32768..32767
ref-3-z-32768..32767

data event-cfg

data event-cfg <profile-mask>,[<max-count>],[<send-th>],[<discard>],[<send-all>]
Set event storage configuration
ParameterRangeDescription
profile-mask1..63bitfield
max-count0disabled
1..100
send-th0..65535if count >= send-th: send(device-events)
discard0oldestif no free space
1newest
send-all0off
1on

data erase-events

data erase-events [<num-oldest>]
Erase <num-oldest> events if provided, otherwise all
ParameterRangeDescription
num-oldest0..65535

data del-rule

data del-rule [<rule-num>]
Delete <rule-num> rules if provided, otherwise delete all
ParameterRangeDescription
rule-num0..31

data set-rule

data set-rule [<rule-num>],<test-expr>,[<input-expr>],[<switch-profile>],[<make-event-0>],[<make-event-1>], [<make-event-2>],[<make-event-3>],[<send-frame-0>],[<send-frame-1>],[<send-frame-2>],[<send-frame-3>],[<clr-timer-mask>]
Set data rule <rule-num>
ParameterRangeDescription
rule-num0..31
test-expr
input-expr
switch-profile0..5
make-event-0variable-type
make-event-1variable-type
make-event-2variable-type
make-event-3variable-type
send-frame-0frame-type
send-frame-1frame-type
send-frame-2frame-type
send-frame-3frame-type
clr-timer-mask0..15

data timer

data timer [<timer_1>],[<timer_2>],[<timer_3>],[<timer_4>]
Set user timer value
ParameterRangeDescription
timer_10..4294967295timer_1
timer_20..4294967295timer_2
timer_30..4294967295timer_3
timer_40..4294967295timer_4

data activity-cal

data activity-cal <profile-mask>,<cal-level>,<cal-led>
Run activity monitor calibration and apply result to profiles
ParameterRangeDescription
profile-mask1..63bitfield
cal-level1level-one
2level-two
cal-led0no
1yes

Data Frames

IDSize [B]NameData Fields
15current-statetemperature, humidity, mag_sw_cnt_u8, major_axis_orientation, activity_state, free_fall_evnt, impact_evnt, pending_evnt
2variabledevice-eventsevent-list
311temp-histogramtemp_histo_epoch, temp_histo_bin[10]
411humid-histogramhumid_histo_epoch, humid_histo_bin[10]
53device-orientationorientation_x, orientation_y, orientation_z
69full-activityactivity_state, activity_s, high_activity_s
78motion-eventsimpact_cnt, free_fall_cnt
88mag-switchmag_sw_cnt, mag_switch_ts
98impact-countimpact_cnt_u16, impact_cnt_x_u16, impact_cnt_y_u16, impact_cnt_z_u16
102last-temptemperature
112ema-temptemperature_ema
121last-humidhumidity
131ema-humidhumidity_ema
145activityactivity_state, total_activity_s
208dev-timeuptime_s, unix_time
212dev-healthbattery_mv
2211versionversion_pid, version_maj, version_min, version_rev, version_hash[6]
2311serial-numberserial_number[11]
2410cfg-statecfg_app_crc, cfg_net_crc, cfg_frames_crc, cfg_data_crc, cfg_rules_crc
25variablefull-cfgcontent-offset, content-final, content-len, content-binary-blob
26variableapp-cfgcontent-offset, content-final, content-len, content-binary-blob
27variablenet-cfgcontent-offset, content-final, content-len, content-binary-blob
28variableframe-cfgcontent-offset, content-final, content-len, content-binary-blob
29variabledata-cfgcontent-offset, content-final, content-len, content-binary-blob
30variablerules-cfgcontent-offset, content-final, content-len, content-binary-blob

User Variables

IDSize [B]EncodingNameDescription
01u8profilecurrent data profile (0..5)
14u32profile_etmelapsed time [s] since last profile switch
24u32daytime_tmseconds since midnight 00:00 GMT or 0 if unknown
34u32unix_timecurrent UNIX time or device uptime if unknown
44u32net_frame_etmelapsed time since last network uplink
51boolnet_joined_flagnetwork join state
61u8net_classcurrently selected LoRaWAN class
71u8net_regioncurrently used LoRaWAN region code
82f8.8temperaturelast measured temperature
92f8.8temperature_emaEMA of measured temperature
101u8humiditylast measured humidity
111u8humidity_emaEMA of measured humidity
124u32mag_sw_cntmagnetic switch state change counter
134u32mag_sw_etmelapsed time since last magnetic switch change [s]
141boolmag_sw_flagcurrent state of magnetic switch
151activityactivity_statecurrent device activity state
164u32activity_slow activity (level 1) state counter [s]
174u32high_activity_shigh activity (level 2) state counter [s]
181orientmajor_axis_orientationcoarse device orientation
194u32impact_cnt_xX axis impact event counter
204u32impact_cnt_yY axis impact event counter
214u32impact_cnt_zZ axis impact event counter
224u32impact_cntimpact event counter
231boolimpact_evntimpact event flag, cleared by current-state, motion-events, impact-count frames
244u32impact_etmelapsed time since last impact event event [s]
254u32free_fall_cntfree-fall event counter
261boolfree_fall_evntfree-fall event flag, cleared by current-state, motion-events frames
274u32free_fall_etmelapsed time since last free-fall event [s]
281u8angle_1angle between current orientation and user ref-1 vector, see data orient-cfg
291u8angle_2angle between current orientation and user ref-2 vector, see data orient-cfg
301u8angle_3angle between current orientation and user ref-3 vector, see data orient-cfg
311u8angle_emaangle between current orientation and EMA of device orientation
322u16battery_mvlast measured battery voltage [mV]
332u16battery_mv_emaEMA of battery voltage [mV]
342u16meta_rule_idmeta variable to send generate event with rule number
354u32timer_1resettable continues up counting timer [s]
364u32timer_2resettable continues up counting timer [s]
374u32timer_3resettable continues up counting timer [s]
384u32timer_4resettable continues up counting timer [s]
394u32activity_state_etmtime since activity_state state change [s]

Frame Data Fields

Size [B]EncodingNameDescription
1u8mag_sw_cnt_u8LSB of internal magnet switch counter mag_sw_cnt
1/8boolpending_evntindicates device has stored events
0event-listvariable length list of: event time stamp, code and optional value
1u8temp_histo_epochtemperature histogram epoch number
10u8[10]temp_histo_bin[10]temperature histogram bin counter values
1u8humid_histo_epochhumidity histogram epoch number
10u8[10]humid_histo_bin[10]humidity histogram bin counter values
1i8orientation_xdevice orientation normal vector X axis
1i8orientation_ydevice orientation normal vector Y axis
1i8orientation_zdevice orientation normal vector Z axis
4u32mag_switch_tstime stamp of last time magnetic switch state change
2u16impact_cnt_u16impact event counter
2u16impact_cnt_x_u16X axis impact event counter
2u16impact_cnt_y_u16Y axis impact event counter
2u16impact_cnt_z_u16Z axis impact event counter
4u32total_activity_stotal activity state time (level 1 + level 2)
4u32uptime_sdevice FW uptime
2u16version_pidTG-LR82:0x0000, TG-LR92:0x0001
1u8version_majFW version major number
1u8version_minFW version minor number
1u8version_revFW version patch number
6u8[6]version_hash[6]FW version hash
11u8[11]serial_number[11]last 11 characters of device serial number
2u16cfg_app_crcapp & mag configuration group 16 bit checksum
2u16cfg_net_crcnet configuration group 16 bit checksum
2u16cfg_frames_crcframe configuration group 16 bit checksum
2u16cfg_data_crcdata configuration group 16 bit checksum
2u16cfg_rules_crcdata rule configuration 16 bit checksum
1/8boolcontent-finalflag indicating last chunk of content
15/8u15content-offsetbyte offset of content data
1u8content-lenlength of content
0content-binary-blobbinary data of content chunk

Known Issues

IDFWDescription
LORA-2752.0.0No timeout changing credentials with secondary band disabled.
LORA-2762.0.0Incorrect credential change command timeout.
LORA-2792.0.0Activity calibration with orientation enabled causes fault.

LORA-275

Description: If credential changes are initiated with secondary band disabled - device will not timeout join. Device will be stuck attempting join until either it succeeds or is restarted.

Workaround: If new credentials are invalid restart device physically with magnet switch command.

LORA-276

Description: When lora cred is executed device will timeout join procedure on next join attempt based on total uptime instead of command execution time. If uptime is longer than confirm-timeout-s parameter device will timeout exactly after single failed join attempt.

Workaround: Issue device reset command app reset before attempting to change credentials. Or manually retry credential change multiple times.

LORA-279

Description: If activity calibration is performed while orientation detection is enabled device may fault and restart.

Workaround: Disable orientation detection with data orient-cfg before performing activity calibration and re-enable after.

NoName
1TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification
2Guidelines for 64-bit Global Identifier (EUI-64)