MachineQ Developer Documentation logo DOCS

MQPS and Other Data Reporting

The device uses the MachineQ Payload Standard (MQPS) to encode sensor readings and configuration messages. MQPS is a very efficient packet format. This page gives the MQPS specification for the onboard temperature sensor and the onboard humidity sensor. The device also supports other commands, for example the last reset reason and the version request.

Packet Overview

MQPS is specific to LoRaWAN. MQPS uses the LoRaWAN packet FPort and the packet direction to encode more data.

  • FPorts 1 through 223 encode the contents and the format of the payload (data section) of each packet.
  • The direction (uplink or downlink) encodes more data.

The flow chart that follows shows how the FPort and the direction identify the packet types on this page.

1 to 3

217

220

221

222

Downlink

Uplink

Receive an MQPS packet

FPort?

Sensor Reading

Join Reason uplink

Reset Reason uplink

Direction?

Get Configuration downlink

Set Configuration

Configuration Report

Sensor Reading

The device sends sensor readings on FPorts 1 through 3. The device uses the FPort number as a bit mask. Each bit identifies one sensor. The decoder uses the bit mask to find the reading type and to parse the payload. The payload has no other format data or size data.

FPort Format

The device has only the temperature sensor and the humidity sensor. The device does not set bits 2 through 7.

Bit 1 0
Sensor Humidity Temperature
Data Size 1 2

Sensor Data Types

Sensor Data Type Measurement Unit Error Code / Values
Temperature int16 0.1 C 0x8000
Humidity uint8 0.5% 0xFF

Payload Order

The payload contains the readings for all sensors that have a bit set to 1 in the FPort bit mask. The readings are in bit order, from the least significant bit. If both bits are set, the temperature reading is first and the humidity reading follows.

Yes

No

Yes

No

Read the FPort bit mask

Is bit 0 set to 1?

Read 2 bytes for the temperature

Is bit 1 set to 1?

Read 1 byte for the humidity

Decode is complete

Sensor Errors

Note: If the device cannot read a sensor, the device reports an error. The device uses a special value. When an error occurs, the decoded_payload does not contain the field for that sensor. The decoder adds an error field. The decoder decodes all valid values in the same payload correctly.

The possible error messages are:

  • temperature reading
  • humidity reading

This example shows a decoded payload with valid humidity data and a temperature error:

json
"decoded_payload": {
  "humidity": "55.0",
  "error": ["temperature reading"]
}

Example 1: Temperature and Humidity

FPort: 0x03 (0000 0011)

  • Bit 0: Temperature reading.
  • Bit 1: Humidity reading.

Data: 0x00E611

  • The first 2 bytes are the temperature:
    • 0x00E6 = 230 → 230 × 0.1 C = 23.0 C.
  • The next byte is the humidity:
    • 0x11 = 17 → 17 × 0.5% RH = 8.5% RH.

Example 2: Temperature and Humidity Errors

FPort: 0x03 (0000 0011)

  • Bit 0: Temperature reading.
  • Bit 1: Humidity reading.

Data: 0x8000FF

  • The first 2 bytes are the temperature:
    • 0x8000 → Temperature error.
  • The next byte is the humidity:
    • 0xFF → Humidity error.

Configuration

Configuration packets control the operation of the device. Use a LoRaWAN downlink to set the configuration or to get the configuration from the device.

Packet Type FPort Direction Function
Set 221 Downlink Set the device configuration
Get 222 Downlink Request the device configuration
Report 221 Uplink Send the requested configuration settings

221 Set

Yes

No

222 Get

Send a downlink

FPort?

Are all parameters and values valid?

Device sends a Report on FPort 221. The Report is an exact copy of the Set request.

Device sends 0xFF

Device sends a Report on FPort 221 with the requested values

Configuration Message Format (Set and Report)

Configuration Parameter (1) Parameter Value (1) Configuration Parameter (2) Parameter Value (2) … Configuration Parameter (N) Parameter Value (N)
1 byte 1-X bytes 1 byte 1-X bytes … 1 byte 1-X bytes

Configuration Message Format (Get)

Configuration Parameter (1) Configuration Parameter (2) … Configuration Parameter (N)
1 byte 1 byte … 1 byte

Configuration Parameters

Parameter Name Size Units Range Default (v0.26.1 and later)
0x01 Reporting Period 2 bytes Seconds, 2 second increments 30-65535 (before v0.60.0: 3-65535) 0x0384 (30 minutes). Before v0.60.0: 0x01C2 (15 minutes)
0x02 Sensor Sample Period 2 bytes Seconds, 2 second increments 1-65535 0x00E1 (7.5 minutes)
0x03 Temperature Report Delta 1 byte 0.1 Celsius 0-255 0x64 (10 Celsius)
0x04 Humidity Report Delta 1 byte 0.5% Relative Humidity 0-200 0x0A (5% Relative Humidity)
0x05 Enable/Disable Sensor 2 bytes The first byte is the sensor bit mask (see Sensor Reading). The device does not use the second byte. Set the second byte to 0x00. First byte: 0-3. Second byte: 0 0x0100 (Activates Temperature only)
0x06 (v0.26.0) Sampling Configuration 1 byte Bits 0-3: Sample Window + 1. Bits 4-7: Average Window + 1 0-15 for the Sample Window. 0-15 for the Average Window 0x00 (Sample Window and Average Window)
0x0A (v0.26.0) Confirmed Message 1 byte Bit mask, sensor structure (see Sensor Reading) 0-3 in total (0-1 for each bit) 0x00 (Unconfirmed message for all sensors)
0x0B (v0.57.0) Advertising Interval 2 bytes 625 microseconds 0: not active. Minimum: 32. Maximum: 16384 0x0000 (Not active)
0x0D (v0.60.0) Data Caching 1 byte Bit mask 0-1 0x00

Note: Integers are unsigned. If a parameter has a different data type, the table gives the data type.

Note: The device does not support parameters 0x07 (Movement Threshold), 0x08 (Water Leak Monitoring Config), 0x09 (Pressure Report Delta), 0x0C (External Sensor), and 0x0E (RTD Delta). These parameters are for sensors that the device does not have.

Data Caching Bit Map

1 = Active. 0 = Not active.

Bit 7 6 5 4 3 2 1 0
Function RFU RFU RFU RFU RFU RFU RFU MQPS Sensor Reading Uplinks

RFU means reserved for future use.

Set and Report

Set packets and Report packets use the same format and the same FPort number. The packet format is a list of parameter and value pairs. When the device receives a valid Set request, the device sends a Report packet. The Report packet is an exact copy of the Set request. If a parameter or a value is not valid, the device sends 0xFF.

Example 1: Reporting Period and Sample Period

Packet: 01070802003c

Parameter and value pair 0: 010708

  • Parameter: 0x01 = 1 → Reporting Period.
  • Value: 0x0708 = 1800 → 1800 × 2 sec = 3600 sec = 1 hour.

Parameter and value pair 1: 02003c

  • Parameter: 0x02 = 2 → Sensor Sample Period.
  • Value: 0x003c = 60 → 60 × 2 sec = 120 sec = 2 minutes.

Example 2: Configure the Temperature and Humidity Sensors

Packet: 030a0402050300

Parameter and value pair 0: 030a

  • Parameter: 0x03 = 3 → Temperature Report Delta.
  • Value: 0x0a = 10 → 10 × 0.1 C = 1 C delta.

Parameter and value pair 1: 0402

  • Parameter: 0x04 = 4 → Humidity Report Delta.
  • Value: 0x02 = 2 → 2 × 0.5% RH = 1% RH delta.

Parameter and value pair 2: 050300

  • Parameter: 0x05 → Enable/Disable Sensor.
  • Value: 0x0300 → Bit mask → Activate the Temperature sensor and the Humidity sensor.

Get

Use FPort 222 to send a Get configuration downlink to the device. The packet format is a list of parameters. The device sends the requested configuration values on FPort 221.

Example: Get the Reporting Period and the Sensor Sample Period

Get request downlink on FPort 222: 0102

  • Parameter: 0x01 = 1 → Reporting Period.
  • Parameter: 0x02 = 2 → Sensor Sample Period.

Response uplink on FPort 221: 01070802003c

Parameter and value pair 0: 010708

  • Parameter: 0x01 = 1 → Reporting Period.
  • Value: 0x0708 = 1800 → 1800 × 2 sec = 3600 sec = 1 hour.

Parameter and value pair 1: 02003c

  • Parameter: 0x02 = 2 → Sensor Sample Period.
  • Value: 0x003c = 60 → 60 × 2 sec = 120 sec = 2 minutes.

Common Configurations

The tables that follow give the recommended configuration settings for common use cases of the device. The first table shows the related parameters. The values in bold are the parameters that change most often for different customer needs.

Parameter ID Name Periodic Temperature (Hex) Periodic Temperature (Value) Delta Temperature (Hex) Delta Temperature (Value)
0x01 Reporting Period 0101C2 15 min 010E10 2 hr
0x02 Sensor Sample Period 0200E1 7.5 min 02003C 2 min
0x03 Temperature Report Delta 03C8 20 deg C 0314 2 deg C
0x04 Humidity Report Delta - NA - NA
0x05 Enable/Disable Sensor 050100 Temp Only 050100 Temp Only
0x06 Sampling Configuration - Default 0604 Sample Window: 5. Average Window: 1
0x0A Confirmed Message - Unconfirmed 0A01 Confirmed
0x0B Advertising Interval - NA - NA
0x0D Data Caching - NA - NA

The table that follows gives the full configuration downlink for each common use case.

Description Configuration Downlink
Temperature periodic report 0101C20200E103C8050100
Temperature delta report with confirmed uplinks 010E1002003C031405010006040A01

Reset Reason

At startup, the device sends the last reset reason on FPort 220. The device uses this format:

Hardware Reset Reason Software Reset Reason
1 byte 1 byte

Hardware Reset Reason

Each bit in the Hardware Reset Reason byte identifies one cause of the last reset. If a bit is set to 1, the related cause started the last reset.

Bit 7 6 5 4 3 2 1 0
Description NFC field detected Entered into debug interface ANADETECT signal trigger (LPCOMP) DETECT signal trigger (GPIO) CPU Lock-up Soft Reset Watchdog Reset Pin

Software Reset Reason

The Software Reset Reason codes have these meanings:

Software Reset Reason Code Description
0 Unknown (not a Soft Reset, or an unknown source started the reset)
1 Stack Overflow
2 Radio Busy
3 Hard Fault
4 Assert Error
5 CLI Command
6 Factory Reset
7 Downlink Command
8 Reserved
9 App Error
10 (0x0A) LoRa IRQ
11 (0x0B) FUOTA (the device received all of the FUOTA packets and restarted to apply the update)
12 (0x0C) Uplink Timeout. The device did not send an uplink for more than 2 × Reporting Period.
13 (0x0D) Downlink Timeout. The device did not receive a downlink for more than 24 hours.
14 (0x0E) FDS Write Failure
15 (0x0F) Brown Out Mode
16 (0x10) De-Passivation
17 (0x11) Confirmed Retransmission Error (the device is in the retransmission state, but did not send a retransmission in the expected window)

Note: The device sends this uplink as a confirmed uplink.

Join Reason

After each successful join request and join response procedure, the device sends the reason for the join and related data. For the first join procedure after a power cycle, the device sends only the Reset Reason uplink.

The device sends the last join reason on FPort 217. The device uses this format:

RFU Join Count Other Info Join Reason
1 byte 1 byte 1 byte 1 byte

Yes

No

Join procedure is successful

First join after a power cycle?

Device sends only the Reset Reason uplink on FPort 220

Device sends the Join Reason uplink on FPort 217

Join Count

The Join Count field gives the number of Join Requests that the device sent before it received the Join Accept message. If the device sent more than 255 Join Requests, the Join Count is 255.

Other Info

The Other Info field gives more data about the join request.

Bit 7-2 1 0
Description RFU The button started the Join Request A Join Error occurred

Join Reason Codes

The Join Reason codes have these meanings:

Join Reason Description
0 Initial boot join
1 The device stopped the join procedure unexpectedly and started the join procedure again.
2 Rejoin because Confirmed ADR Adaptation failed
3 Rejoin because Unconfirmed ADR Adaptation failed
4 The device did not send a join request in the last 6 hours and started the join procedure again.

Note: The device sends this uplink as a confirmed uplink.

What's Next?