MachineQ Developer Documentation logo DOCS

Sensor Operation

This page tells how the device samples and reports the onboard temperature sensor and the onboard humidity sensor. It also tells how the device keeps failed confirmed uplinks with the Data Caching function, and how battery depassivation works.

Supported Sensors and Functionality

The device supports these sensors through the LoRaWAN interface:

Sensor Type Sensors
Analog Thermometer (temperature), Hygrometer (humidity)

The device does not have other sensors that operate through the LoRaWAN interface.

Note: To discuss more functions or customization, contact your sales representative.

Sensor Reporting

The Reporting Period makes sure that all active sensors send a reading at an interval that is not longer than the Reporting Period. Each time the device sends an asynchronous report, the device resets the Reporting Period timer. The sections that follow give the conditions for these asynchronous reports.

Yes

No

No

Yes

Reporting Period timer starts

Asynchronous report sent?

Reporting Period complete?

All active sensors send a reading

Note: For the first 30 minutes after a device reset or a power cycle, the Reporting Period is 30 seconds. This helps you to verify the installation and to debug the device.

Analog Sensor Operation

Analog Sensors

  • Thermometer (temperature)
  • Hygrometer (humidity)

Default Operation

The device samples the analog sensors at the Sample Rate. The device compares the current sample with the previous sample. If the difference between the two readings is more than the configured delta, the device sends a sensor reading. The Reporting Period makes sure that the device sends a sample at the configured period or at a shorter interval.

Yes

No

Yes

No

Sample Period starts

Device samples the analog sensor

Difference from the previous sample more than the configured delta?

Device sends a sensor report

Reporting Period complete?

Sampling Configuration

Sampling Configuration is available in firmware v0.26.0 and later.

The Sampling Configuration sets the parameters of a median average filter. The filter is very useful when you use Delta Thresholds and long Reporting Periods. The filter stops noise. Noise can cause unnecessary reports that decrease battery life.

  • The Sample Window must be equal to or larger than the Average Window.
  • The Average Window must be in the center of the Sample Window, with an equal number of samples on each side.
  • The device rejects configurations that are not valid.

At each Sample Period, the device puts the sample into a FIFO. The Sample Window sets the length of the FIFO. The device then calculates the average of N samples in the center of the Sample Window. The Average Window sets N. The device reports the result with the Delta Threshold and Reporting Period logic.

Sample Period starts

Device puts the sample into the FIFO. The Sample Window sets the FIFO length.

Device calculates the average of the N samples in the center of the Sample Window. The Average Window sets N.

Device uses the result with the Delta Threshold and Reporting Period logic

Confirmed Messages

Confirmed Messages are available in firmware v0.26.0 and later.

Confirmed Messages are a LoRaWAN function. With this function, the Network Server sends an acknowledgement for each message. The device sends the message again until it gets the acknowledgement. This makes sure that the customer application receives the message. If the device loses the network connection, the device can keep the confirmed sensor reports. You can get the reports at a later time. Refer to Data Caching.

Use a bit mask to activate Confirmed Messages for each analog sensor. Refer to the Confirmed Message parameter in Configuration.

To get the longest battery life, use Confirmed Messages with the median filter and long Reporting Periods. With this configuration, the device sends important changes quickly and reliably. The device also uses less energy when conditions are stable.

Example

This example uses these settings:

  • Temperature Report Delta: 5 C
  • Sensor Sample Period: 1 minute
  • Reporting Period: 5 minutes
  • Sample Window: 1
  • Average Window: 1
Time Temperature Sample (C) Action Reason
0 25 Send Sensor Report Reporting Period
1 31 Send Sensor Report Temperature Report Delta
2 20 Send Sensor Report Temperature Report Delta
4 21 - -
5 22 Send Sensor Report Reporting Period
6 22 - -
7 23 - -
8 24 - -
9 28 Send Sensor Report Temperature Report Delta
10 28 Send Sensor Report Temperature Report Delta

Data Caching

Data Caching V1 is available in firmware v0.60.0 and later. Data Caching V2 is available in firmware v0.136.0 and later.

The Data Caching function keeps failed confirmed uplinks on the device. You can get these uplinks at a later time.

  • Set configuration parameter 0x0D to activate Data Caching. Refer to Configuration.
  • Data Caching supports only MQPS uplinks at this time.
  • Data Caching V1 keeps only confirmed uplinks. Use configuration parameter 0x0A to set confirmed uplinks.

Caching Operation

When Data Caching is active, the device waits for the acknowledgement of each confirmed uplink. If the device does not get the acknowledgement in 30 seconds after it sends the uplink, the device keeps the uplink. For the first 30 minutes after power-on, this time is 15 seconds. The device keeps each uplink with a timestamp in non-volatile memory.

  • Data Caching V1 uses UTC time for the timestamp. Data Caching V2 uses GPS time.
  • The device keeps more than 3000 records.
  • When the record memory is full, the device deletes the oldest records first to keep new records.
  • Operations such as FUOTA delete all records.

Yes

No

No

Yes

Yes

No

Device sends a confirmed MQPS uplink

Acknowledgement received in the time limit?

No record is necessary

Is Data Caching active?

Is the record memory full?

Delete the oldest record

Keep the uplink with a timestamp in non-volatile memory

Note: The time limit is 30 seconds after the device sends the uplink. For the first 30 minutes after power-on, the time limit is 15 seconds.

Note: Under good RF conditions, Data Caching has no appreciable effect on battery life. If the PER is high, confirmed messages cause the device to send more often to make sure that the LNS acknowledges the messages. In extreme conditions, the device joins the network again more often. This decreases battery life.

Common Questions

Question Answer
What is the capacity of the cache? The capacity is a number of records, not a time period. The cache keeps at least 3000 records. This is about 21 days at a 10-minute reporting interval.
What happens when the cache is full? The device overwrites the oldest messages to make room for new messages.
What happens to the records after the device joins the network again? When the device joins the network again, it sends its cached data to the gateway. The device keeps these records. You can get them again with a Get Records request.

Changes in Data Caching V2

Change Description
Time format The timestamps are in GPS time (seconds since 1980-01-06, no leap seconds). V1 uses UTC.
Uplink format The uplink format for cached records is slightly different. More records fit into one uplink.
Automatic send You do not have to request cached records. The device sends them 5 minutes after it joins the network. The device then sends them every 5 minutes while records remain. After a reset, the device continues from the last position.
Manual request You can still request cached records. The opcode in the request selects the V1 format or the V2 format.
Always cached The device always keeps unsent sensor data. In V1, the device did not keep data when it had no LoRaWAN connection.
Optional configuration bit An optional configuration bit makes the device send all sensor uplinks in the V2 Get Records Response format. Each uplink then has a timestamp. The decoder parses live records and cached records in the same way. This format uses more bandwidth.

Yes

No

Device joins the network

Device waits 5 minutes

Are there cached records?

Device sends cached records in a V2 Get Records Response

Device waits 5 minutes

No send is necessary

Data Caching Commands

Use downlink commands to:

  • Get the number of records in a date and time range.
  • Get the records in a date and time range.

All Data Caching messages use FPort 219.

0x00 Get Status

0x01 Get Records, UTC

0x02 Get Records, GPS time

Yes

No

Send a downlink on FPort 219

Opcode?

Device sends the number of records found

Device sends the records found

Do all records fit in one uplink?

Complete

Device sends more uplinks until it reports all records

Get Status

The Get Status Request finds records in the range of the timestamps (Unix Epoch) that you give. The end value must be larger than the start value.

  • To get a count of all records, use 0x00000000 for the start and 0xFFFFFFFF for the end.
  • To find records in a specific time window, use specific values.

Note: 0xFFFFFFFF as an end time is a special value that means "get all records". Also, 0x00000000 is a special start time.

Field Size (bytes) Range / Value Description
Opcode 1 0x00 Get Status Opcode
Start Timestamp 4 0x00000000 to 0xFFFFFFFF UTC timestamp. Start of the range for the record search.
End Timestamp 4 0x00000000 to 0xFFFFFFFF UTC timestamp. End of the range for the record search.

The Get Status Response gives the number of records found.

Field Size (bytes) Range / Value Description
Opcode 1 0x00 Get Status Opcode
Record Count 2 Count: 0 to 32767. Error: -1 Number of records found, or an error because the request is not valid

Get Records

The Get Records Request has the same format as the Get Status Request. But the response contains the records found in the range. If necessary, the device sends more than one response uplink to report all of the records in the request window.

There are two opcodes. They use different time formats:

  • Opcode 0x01 uses UTC time. This time does not include leap seconds, so it is 18 seconds different from GPS time.
  • Opcode 0x02 uses GPS time (seconds since 1980-01-06, no leap-second offset). This opcode is available in firmware v0.136.0 and later.
Field Size (bytes) Range / Value Description
Opcode 1 0x01 to 0x02 Get Records Opcode
Start Timestamp 4 0x00000000 to 0xFFFFFFFF 0x01: UTC start. 0x02: GPS start.
End Timestamp 4 0x00000000 to 0xFFFFFFFF 0x01: UTC end. 0x02: GPS end.
Field Size (bytes) Range / Value Description
Opcode 1 0x01 to 0x02 The opcode of the request. For an automatic send of cached unsent messages, the opcode is 0x02.
First Record - - The field is empty if the device finds no records.
Next Record - - The field repeats for each record found. The format depends on the opcode.

First Record Field

Field Size (bytes) Range / Value Description
FPort 1 0 to 63 FPort of the record
Timestamp 4 0x00000000 to 0xFFFFFFFF 0x01: UTC time when the device made the record. 0x02: GPS time when the device made the record.
Payload 1 to 10 - Record payload with a variable length

Next Record Field

For opcode 0x01, the Next Record field is the same as the First Record field. For opcode 0x02, the Next Record field has this format:

Field Size (bytes) Range / Value Description
FPort 1 0 to 63 FPort of the record
Time Offset 1 to 2 0x00 to 0xFFFF Offset from the time of the previous record, in units of 10 seconds. The most significant bit (MSB) of the first byte sets the size of the field.
Payload 1 to 10 - Record payload with a variable length

The Time Offset field has two forms:

  • If the MSB is 0, the field is 1 byte. Time = previous time + offset × 10 seconds.
  • If the MSB is 1, the field is 2 bytes. Time = previous time + (offset & 0x7FFF) × 10 seconds.

Example: Get All Records

This example requests all available records:

  • The first record has the timestamp 1 January 2023 at 00:00. It is a temperature report of 23.0 C.
  • The second record has the timestamp 2 January 2023 at 00:00. It is a temperature report of 22.9 C.
  • The full report does not fit in one uplink. The device sends more uplinks until it reports all records.

The number of records in one uplink changes with the size of the records. It also changes with the maximum uplink size when the device sends the uplink.

Description Downlink / Uplink
Request the count of all records 0000000000FFFFFFFF
Response of 4 records 000004
Request all records, opcode V1 0100000000FFFFFFFF
Response of the first 2 records (V1) 010163B0CD0000E60163B21E8000E5
Response of the second 2 records (V1) 010163B37E4C00E70163B3859000FF
Response of all 4 records at the same time (V1) 010163B0CD0000E60163B21E8000E50163B37E4C00E70163B3859000FF
Request all records, opcode V2 0200000000FFFFFFFF
Response of the first 2 records (V2) 020150DB8F9200E601A1C000E5
Response of the second 2 records (V2) 020150DE40DE00E70180BA00FF
Response of all 4 records at the same time (V2) 020150DB8F9200E601A1C000E501A32E00E70180BA00FF

Example: Decoded V2 Payload

This decoded payload has one report:

json
{
  "data": {
    "cache_records": [
      {
        "data": {
          "payload_type": "sensor_data",
          "temperature": 23.8
        },
        "timestamp": "2026-07-26T23:00:52Z"
      }
    ],
    "payload_type": "cache_records"
  }
}

This decoded payload has more than one report from a cached backlog. The example shows the first 3 of 15 records:

json
{
  "data": {
    "cache_records": [
      { "data": { "payload_type": "sensor_data", "temperature": 25 },   "timestamp": "2026-07-23T00:27:35Z" },
      { "data": { "payload_type": "sensor_data", "temperature": 25.2 }, "timestamp": "2026-07-23T00:35:35Z" },
      { "data": { "payload_type": "sensor_data", "temperature": 24.8 }, "timestamp": "2026-07-23T00:50:35Z" }
    ],
    "payload_type": "cache_records"
  }
}

Battery Depassivation

The battery looks like a standard alkaline AA battery. But the device uses a high-capacity, long-life, lithium thionyl chloride battery. The property that gives the battery a long shelf life can cause problems at first use. This condition is passivation. Passivation is a thin film that grows around the anode. The film is an insulator that stops the battery from self-discharge.

If the device detects a high level of passivation, the device starts a 2-minute depassivation cycle. During this cycle, the LED gives a slow orange blink. At the end of the depassivation cycle, the device restarts and joins the network again.

No

Yes

Device starts

High level of passivation detected?

Normal operation

Device starts a 2-minute depassivation cycle. LED gives a slow orange blink.

Device restarts

Device joins the network again

What's Next?