# Sensor-triggered mode-independent events

You can set up several mode-independent events based on **sensor detection** to be sent to you regardless of mode. These events are often mode-specific for certain modes but can be configured to be sent in other modes as well. You can receive various button presses, logistic events from modes such as Trace me, temperature threshold alerts and light and darkness detection events.

### **Introduction and use case examples**

We have added these features because of some specific tracking and tracing use cases, but if they solve your problems in another use case, feel free to play around with them.

***Example 1:** You need to track cargo that needs to stay in an environment with a stable temperature. You set up tracing with enabled temperature measuring, which will trigger an alert when a temperature threshold is crossed. The thresholds can be customized in order to fit the stable temperature window.*

***Example 2:** You want to trace packages and make sure they’re not opened until they reach their final destination. You will use Trace me and with that, enable light sensor-triggered events to be sent to you. When somebody opens the package on the way, you will receive a light detection message.*

***Example 3:** In addition to counting the number of door openings, you want your staff to be able to report something with a button click - you will use the Reed counter mode and enable the button to be active all the time.*

### **Events you can receive in every user mode**

These are the events you can receive regardless of the mode you are in. Please note that all of these will not be sent by default unless they are mode-specific to the mode you are using! Enabling them requires additional configuration.

You can also receive an **Extra long press (0x81)** in every SimplePack or SimplePack Plus mode. This event will be always sent in default settings as it is the default way to [**request a downlink**](https://simplehw.atlassian.net/wiki/spaces/DOC/pages/23396404/API+6+Downlink+Information).

| **Event name (hex)**                                     | **Required sensor**      |
| -------------------------------------------------------- | ------------------------ |
| Short press (0x30)                                       | Button                   |
| Doubleclick (0x31)                                       | Button                   |
| Long press (0x32)                                        | Button                   |
| Start of movement (0x20)                                 | Accelerometer            |
| End of movement (0x21)                                   | Accelerometer            |
| Tracing tag (0x22)                                       | Accelerometer            |
| Light on (0x60)                                          | Light sensor             |
| Light off (0x61)                                         | Light sensor             |
| Temperature below threshold A, B or C (0x50, 0x52, 0x54) | Thermometer (optional)\* |
| Temperature above threshold A, B or C (0x51, 0x53, 0x55) | Thermometer (optional)\* |

{% hint style="info" %}
P*lease note that reporting temperature threshold breaches works only in modes that do not use the thermometer by default - e.g. Temperature monitoring (0x11) will report delta breaches only (as the 0x34 temperature measurement period register value is already wired to the main mode).*
{% endhint %}

### **Downlink configuration**

The way you enable these events is not consistent, so let’s go over the settings.

**Events triggered by the button (0x30, 0x31, 0x32)** can be enabled by setting **bit 4** of the value of **register 0x0E** from 0 to **1** (e.g. 101**1**1001 - 0xB9). This will stop limiting button functionality to arming, disarming and extra long press.

***

**Events triggered by the accelerometer (0x20, 0x21, 0x22)** can be enabled by setting **bit 0** of the value of **register 0x56** from 0 to **1** (e.g. 0000000**1** - 0x01). This will allow logistic events to be sent to you without being in a logistic mode.

***

**Events triggered by the light sensor (0x60 and 0x61)** can be enabled by turning light detection on as it’s turned off as a factory default. This means you need to change the value of **register 0x36** (Light sensor measurement period) to **any** [**SimpleTime**](https://simplehw.atlassian.net/wiki/spaces/DOC/pages/23396515/API+6+Encoding#SimpleTime) **value** except for 0x00.

***

**Events triggered by the precise thermometer or the ambi temperature (0x50, 0x51, 0x52, 0x53, 0x54, 0x55)** can be enabled by turning temperature measuring on as it’s turned off as a factory default, just like above. The value of **register 0x34** (Temperature measurement period) needs to be a [**SimpleTime**](https://simplehw.atlassian.net/wiki/spaces/DOC/pages/23396515/API+6+Encoding#SimpleTime) **value different** from 0x00.

### **Relevant registers**

The behavior of the sensors and the events above can be further configured by the following registers:

If you change the **general sensitivity** of the accelerometer and the magnetometer (0x11 and 0x19), respective **axis registers** reset to 0 as the general settings replace them and vice versa.

| **Register (hex)**                      | **Relevant for**    | **Additional information**         |
| --------------------------------------- | ------------------- | ---------------------------------- |
| Button press timing threshold (0x59)    | Button events       | Custom press time                  |
| Tracing interval (0x05)                 | Logistic events     | SimpleTime encoding                |
| Accelerometer sensitivity (0x11)        | Logistic events     | Default 0x07 is the most sensitive |
| Accelerometer X axis sensitivity (0x12) | Logistic events     | Default 0x07 is the most sensitive |
| Accelerometer Y axis sensitivity (0x13) | Logistic events     | Default 0x07 is the most sensitive |
| Accelerometer Z axis sensitivity (0x14) | Logistic events     | Default 0x07 is the most sensitive |
| Accelerometer measurement period (0x3C) | Logistic events     | SimpleTime encoding                |
| Accelerometer detection delay (0x49)    | Logistic events     | SimpleTime encoding                |
| Light sensitivity hysteresis (0x43)     | Light on/off events | Value in % of light                |
| Light sensitivity threshold (0x44)      | Light on/off events | Value in % of light                |
| Light sensor detection delay (0x4C)     | Light on/off events | SimpleTime encoding                |
| Temperature threshold A (0x1D)          | Temperature alerts  | SimpleTemp encoding                |
| Temperature hysteresis A (0x1E)         | Temperature alerts  | SimpleTemp encoding                |
| Temperature threshold B (0x1F)          | Temperature alerts  | SimpleTemp encoding                |
| Temperature hysteresis B (0x20)         | Temperature alerts  | SimpleTemp encoding                |
| Temperature threshold C (0x21)          | Temperature alerts  | SimpleTemp encoding                |
| Temperature hysteresis C (0x22)         | Temperature alerts  | SimpleTemp encoding                |
| Temperature detection delay (0x4D)      | Temperature alerts  | SimpleTime encoding                |

### **Periodic temperature independent event**

This is a sensor-triggered mode-independent event but deserves special mention as it works as a standalone mode. Records temperature and sends the records in an adjustable way.

Periodic temperature with redundancy is implemented in API 6 revision **6.0.113** and up.

This independent alert works reports **temperature records** over a period of time; you can adjust both the number of new records sent in one message and also the length between each record.

This independent alert works in **ANY mode** (can be combined with temperature modes as well) and can use **ANY temperature sensor** and even temperature measured at the **MCU** (without any sensor dedicated to measuring temperature only).

Please note that there is a difference in **precision** for each way of reporting temperature, from 0,5°C to 2-3°C. The precise temperature sensor is available in Full and Temp devices.

The 0xBA alert is **off** in default settings and is controlled by two downlink registers:

| **Hex** | **Register name**         | **What it is**                                                   |
| ------- | ------------------------- | ---------------------------------------------------------------- |
| 0x7E    | Periodic temp aggregation | The number of records sent in one message. Values 1, 2, 3, 4, 9. |
| 0x7F    | Periodic temp interval    | The time period between each record. SimpleTime value.           |

**Example 1:**

The value of 0x7E is 0x09 and the value of 0x7F is 0x81, which translates to aggregation 9 and interval 1 hour. The device will send you a 0xBA message:

* every 9 hours
* containing last 9 measurements made every hour
* without any backup data

**Example 2:**

The value of 0x7E is 0x03 and the value of 0x7F is 0x4A, which translates to aggregation 3 and interval 10 minutes. The device will send you a 0xBA message:

* every 30 minutes
* containing 3 new measurements
* containing 6 old backup measurements (this means that even two messages can be lost without the flow of data being compromised)

***

####
