# Keep-alive

## 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="69.66666666666669">Byte</th><th width="80">Bit Index</th><th width="74">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td>-</td><td><strong>01</strong></td><td>Command byte for this packet.</td></tr><tr><td>1</td><td>-</td><td>XX</td><td>Internal temperature sensor data, bits 15:8 – T[15:8].</td></tr><tr><td>2</td><td>-</td><td>XX</td><td><p>Internal temperature sensor data, bits 7:0 - T[7:0].  </p><p>t [°C] = (T[15: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>Device battery voltage data, bits 15:8.</td></tr><tr><td>5</td><td>-</td><td>XX</td><td>Device battery voltage data, bits 7:0. Battery voltage, [mV].</td></tr><tr><td>6</td><td>-</td><td>XX</td><td>CO2 value in ppm, bits 7:0.</td></tr><tr><td>7</td><td>7:3</td><td>-</td><td>CO2 value in ppm, bits 12:8.</td></tr><tr><td></td><td>2:0</td><td>-</td><td><p>Power source status.</p><p>Тhe device is powered by:</p><p>000 - Built-in photovoltaic panel;</p><p>001 - Reserved;<br>002 - USB power supply.</p></td></tr><tr><td>8</td><td></td><td>XX</td><td>Device light intensity data, bits 15:8.</td></tr><tr><td>9</td><td></td><td>XX</td><td>Device light intensity data, bits 7:0. Light intensity [Lux].</td></tr></tbody></table>

### Keepalive example

<table><thead><tr><th width="68.66666666666669">Byte</th><th width="75">Bit index</th><th width="71">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td>-</td><td><strong>01</strong></td><td>Command byte for this packet.</td></tr><tr><td>1</td><td>-</td><td><strong>02</strong></td><td>Internal temperature sensor data, bits 15:8 – T[15:8].</td></tr><tr><td>2</td><td>-</td><td><strong>88</strong></td><td><p>Internal temperature sensor data, bits 7:0 - T[7:0].  </p><p>t [°C] = (T[15:0]-400)/10<br>t [°C] = (<strong>0x0288</strong>-400)/10 = (648-400)/10 = 24.8 deg 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>0A</strong></td><td>Device battery voltage data, bits 15:8.</td></tr><tr><td>5</td><td>-</td><td><strong>45</strong></td><td><p>Device battery voltage data, bits 7:0. </p><p>Battery voltage, [mV].<br><strong>0x0A45</strong> = 2629mV</p></td></tr><tr><td>6</td><td>-</td><td><strong>6B</strong></td><td>CO2 value in ppm, bits 7:0.</td></tr><tr><td>7</td><td>7:3</td><td><strong>18</strong></td><td><p>CO2 value in ppm, bits 12:8.</p><p>CO2, [ppm]=CO2[12:0] = 875 ppm. <br>Example code:<br>co2_value = ((Byte[7] &#x26; 0xF8) &#x3C;&#x3C; 5) | Byte[6];</p></td></tr><tr><td></td><td>2:0</td><td><strong>00</strong></td><td><p>Power source status.</p><p>Тhe device is powered by:</p><p><strong>0x00</strong>=0001101100000000</p><p>[3:0]=000</p><p>000 - Built-in photovoltaic panel;</p></td></tr><tr><td>8</td><td></td><td><strong>02</strong></td><td>Device light intensity data, bits 15:8.</td></tr><tr><td>9</td><td></td><td><strong>7A</strong></td><td>Device light intensity data, bits 7:0. Light intensity [LUX].<br><strong>0x027A</strong> = 634 LUX</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 0F=15min.</strong></td></tr></tbody></table>

**Example command:** 0x020A

The example sets the keep-alive period to 10 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 sent from server:** 0x12;

**Example command response:** 0x1209 – the keep-alive is 9 minutes.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mclimate.eu/mclimate-lorawan-devices/devices/mclimate-co2-display-lite/co2-display-lite-device-communication-protocol/keep-alive.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
