> For the complete documentation index, see [llms.txt](https://docs.mclimate.eu/mclimate-lorawan-devices/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mclimate.eu/mclimate-lorawan-devices/devices/mclimate-ht-+-pir-lite/ht-+-pir-lite-device-communication-protocol/keep-alive.md).

# Keep-alive

The keep-alive is a periodic message sent by the HT + PIR Lite with sensor data and more. In this page you will learn how to decode keepalive messages and how to set the keepalive interval.

## Keep-alive decoding

Periodically sent message which contains the most important device data.

The data is described in the table below, where an example is also given in a second table.

<table><thead><tr><th width="87.66666666666669">Byte</th><th width="108">Bit Index</th><th width="77">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td>-</td><td><strong>81</strong></td><td>Command byte for this packet.</td></tr><tr><td>1</td><td>7:3</td><td>-</td><td>(RFU) - Reserved for future use</td></tr><tr><td>1</td><td>2</td><td>-</td><td>Occupied</td></tr><tr><td>1</td><td>1:0</td><td>-</td><td>Internal temperature sensor data, bits - T[9:8]</td></tr><tr><td>2</td><td>-</td><td>XX</td><td><p>Internal temperature sensor data, bits - T[7:0] </p><p>t [°C] = (T[9:0] - 400) / 10</p></td></tr><tr><td>3</td><td>-</td><td>XX</td><td>Relative Humidity data; RH [%] = (XX * 100) / 256</td></tr><tr><td>4</td><td>-</td><td>XX</td><td>Battery Voltage, [mV] = ((XX * 2200) / 255) + 1600</td></tr><tr><td>5</td><td>-</td><td>XX</td><td>PIR trigger count</td></tr></tbody></table>

### Keepalive example

<table><thead><tr><th width="87.66666666666669">Byte</th><th width="89">Bit index</th><th width="79">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td>-</td><td><strong>81</strong></td><td>Command byte for this packet.</td></tr><tr><td>1</td><td>7:3</td><td>-</td><td>(RFU) - Reserved for future use</td></tr><tr><td>1</td><td>2</td><td>-</td><td>Occupied</td></tr><tr><td>1</td><td>1:0</td><td><strong>-</strong></td><td>Internal temperature sensor data, bits – T[9:8]</td></tr><tr><td>2</td><td>-</td><td><strong>88</strong></td><td><p>Internal temperature sensor data, bits - T[7:0] </p><p>t [°C] = (T[9:0]-400)/10<br>t [°C] = (<strong>0x0288</strong>-400)/10 = (648-400)/10 = 24.8 °C</p></td></tr><tr><td>3</td><td>-</td><td><strong>80</strong></td><td>Relative Humidity data; RH [%] = (XX*100)/256<br>(0x80 * 100)/256 = (128*100)/256 = 50% RH</td></tr><tr><td>4</td><td>-</td><td><strong>C8</strong></td><td>Battery Voltage, [mV] = ((0xC8 * 2200) / 255) + 1600 = 3325mV </td></tr><tr><td>5</td><td>-</td><td><strong>0B</strong></td><td>PIR trigger count = 11</td></tr></tbody></table>

### Keepalive period

{% tabs %}
{% tab title="SET" %}

<table data-header-hidden><thead><tr><th width="142">Byte index</th><th>Hex value - Meaning</th></tr></thead><tbody><tr><td><strong>Byte index</strong></td><td><strong>Hex value - Meaning</strong></td></tr><tr><td>0</td><td>02 – Command code to set keepalive period</td></tr><tr><td>1</td><td>XX – keep-alive period in minutes. Value 0x00 isn’t applicable.<br><strong>Default value 0A=10min.</strong></td></tr></tbody></table>

**Example command:** 0x020F

The example sets the keep-alive period to 15 minutes.

Note that the period value must respect the LoRaWAN messages duty cycle limitations. Otherwise the message will be sent when this is allowed. Also, the bigger period value, the less battery discharge. In most of cases, min. allowed period is 3 minutes and recommended values are 10 minutes or greater.
{% endtab %}

{% tab title="GET" %}
This command is used to get the period of the keep-alive command messages. Server sends the command code and the response is sent from the device together with the next keep-alive command.&#x20;

The keep-alive in the example is omitted for clarity.

<table data-header-hidden><thead><tr><th width="131.66666666666666">Byte index</th><th width="136">Sent request</th><th>Received response</th></tr></thead><tbody><tr><td><strong>Byte index</strong></td><td><strong>Sent request</strong></td><td><strong>Received response</strong></td></tr><tr><td>0</td><td>12 – The command code.</td><td>12 – The command code.</td></tr><tr><td>1</td><td></td><td>XX – device keep-alive period in minutes.</td></tr></tbody></table>

**Example command:** 0x12

**Example response:** 0x120A – the keep-alive is 10 minutes.
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mclimate.eu/mclimate-lorawan-devices/devices/mclimate-ht-+-pir-lite/ht-+-pir-lite-device-communication-protocol/keep-alive.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
