Heltec Data Format Document
Click here for the decoding code: JavaScript decoding example code
The following is a detailed description of the data format
1. LoRaWAN Node Data Upload Format
1.1 Overall Data Packet Format
Note: Each LoRaWAN packet can contain data from multiple sensors, each sensor can contain multiple types of sub-data.
1.2 Sensor Data Packet Format
Sensor Data Packet |
ID Data Type Inside the Sensor Data Packet |
Total Valid Data Length (bytes) |
Valid Data of This Sensor Packe |
---|---|---|---|
4bits |
4 bits |
1byte |
… |
Note: Total Valid Data Length (bytes) This field is only present for arrays, omitted for other data types.
Data Type |
Value |
Bytes Occupied |
---|---|---|
array |
0b0000 |
max 64 |
double |
0b0001 |
8 |
float |
0b0010 |
4 |
bool |
0b0011 |
1 |
int8_t |
0b0100 |
1 |
uint8_t |
0b0101 |
1 |
int16_t |
0b0110 |
2 |
uint16_t |
0b0111 |
2 |
int32_t |
0b1000 |
4 |
uint32_t |
0b1001 |
4 |
1.3 Sensor Raw Data Conversion Instructions
All data types (except for arrays) are split in the same way as floats. When packing, the low byte comes first.
typedef union
{
union bits_32_raw_data
{
uint32_t uint32_t_raw_data;
int32_t int32_t_raw_data;
float float_raw_data;
};
uint8_t bits_32_convert_data[4];
}bits_32_type_convert_t;
data[0] = bits_32_convert_data[0];
data[1] = bits_32_convert_data[1];
data[2] = bits_32_convert_data[2];
data[3] = bits_32_convert_data[3];
1.4 Data Packet Decoding Example
This is an example of a complete LoRaWAN data packet upload. (The data below is in hexadecimal):
04 00 0A 02 2B 34 BB 41 12 88 C5 B3 41 00 00 02 05 07
0X04 0X00 |
This section is the parent ID, looking up the sensor table, this is the temperature and humidity sensor GXHTC |
0X0A |
Represents the GXHTC data length is 10 |
0X02/0b0000 0010 |
High 4 bits represent sub ID, looking up the table, it represents the temperature of GXHTC. The low 4 bits represent the data type is float |
0X2B 0X34 0XBB 0X41 |
This temperature data converts to 23.40047264099121 |
0X12/0b0001 0010 |
High 4 bits represent sub ID, looking up the table, it represents the humidity of GXHTC. The low 4 bits represent the data type is float |
0X88 0XC5 0XB3 0X41 |
This humidity data converts to 22.471450805664062 |
0X00 0X00 |
This section is the parent ID, looking up the sensor table, this is battery power |
0X02 |
Represents battery data length is 2 |
0X05/0b0000 0101 |
High 4 bits represent sub ID, looking up the table, it represents battery percentage. The low 4 bits represent the data type is uint8_t |
0x07 |
Represents the battery has 7% remaining |
2. Special Circumstances
2.1 Sensor Data Reading Error
When a sensor reading error occurs, the data length field is set to 0, and no data for this sensor is filled afterward. However, if there are multiple sensors and one sensor encounters an error, it does not affect the data transmission of other sensors.
This is an example of a complete LoRaWAN data packet upload. (The data below is in hexadecimal):
04 00 00 00 00 02 05 07
The GXHTC sensor reading error, so the length field is set to 0. However, the battery data transmission is not affected.
3. Sensors
3.1 Sensor ID Summary Table
Sensor Name |
Parent ID |
Data Name |
Sub ID |
Data Type |
Decimal Places |
Measurement Range |
Unit |
Description |
---|---|---|---|---|---|---|---|---|
Battery Power |
0X0000 |
Battery Percentage |
0X00 |
uint8_t |
0~100 |
|||
Charging State |
0X01 |
uint8_t |
0: uncharged; 1: charging |
|||||
RS485 |
0X0001 |
uint8_t |
485 uploads array data |
|||||
BMP280 |
0X0002 |
Atmospheric Pressure |
0X00 |
float |
2 |
300~1100 |
hPa |
|
Temperature |
0X01 |
float |
2 |
-40~85 |
°C |
|||
BH1750 |
0X0003 |
Light Intensity |
0X00 |
float |
1 |
1 - 65535 |
lx |
|
GXHTC |
0X0004 |
Temperature |
0X00 |
float |
2 |
–40 to +125 |
°C |
|
Humidity |
0X01 |
float |
2 |
0~100 |
%RH |
|||
DA217 |
0X0005 |
X-axis Acceleration |
0X00 |
float |
2 |
±16 |
g |
|
Y-axis Acceleration |
0X01 |
float |
2 |
±16 |
g |
|||
Z-axis Acceleration |
0X02 |
float |
2 |
±16 |
g |
|||
OUTDOOR_VALVE |
0X0006 |
VALVE_0_STATUS |
0X00 |
bool |
||||
VALVE_1_STATUS |
0X01 |
bool |
||||||
PULSE_COUNTER_0 |
0X02 |
uint32_t |
||||||
PULSE_COUNTER_1 |
0X03 |
uint32_t |
||||||
IO |
0X0007 |
IO_NUMBER |
0X00 |
uint8_t |
Number of IOs |
|||
IO_EDIT |
0X01 |
int16_t |
Whether IO mode is adjustable (each bit represents an IO, 0 non-adjustable, 1 adjustable) |
|||||
IO_MODE |
0X02 |
int16_t |
IO mode (each bit represents an IO, 0 input, 1 output) |
|||||
IO_STATUS |
0X03 |
uint16_t |
IO status (each bit represents an IO, 0 low, 1 high) |
|||||
PT100 |
0X0008 |
Temperature |
0X00 |
float |
1 |
°C |
||
DOOR_MONITOR |
0x0009 |
DOOR_MONITOR |
0X00 |
bool |
true: door open; false: door closed |
|||
BODY_DETECTOR |
0x000A |
BODY_DETECTOR |
0X00 |
bool |
true: presence; false: no presence |
|||
SEN0563_HCHO |
0X000B |
HCHO |
0X00 |
uint16_t |
0-3 |
ppm |
This is a qualitative sensor |
|
SEN0564_CO |
0X000C |
CO |
0X00 |
uint16_t |
5-5000 |
ppm |
This is a qualitative sensor |
|
SEN0565_CH4 |
0X000D |
CH4 |
0X00 |
uint16_t |
1-10000 |
ppm(C3H8) |
This is a qualitative sensor |
|
SEN0566_VOC |
0X000E |
VOC |
0X00 |
uint16_t |
1-500 |
ppm |
This is a qualitative sensor |
|
SEN0567_NH3 |
0X000F |
NH3 |
0X00 |
uint16_t |
1-300 |
ppm |
This is a qualitative sensor |
|
SEN0568_H2S |
0X0010 |
H2S |
0X00 |
uint16_t |
0.5-50 |
ppm |
This is a qualitative sensor |
|
SEN0569_EtOH |
0X0011 |
EtOH |
0X00 |
uint16_t |
1-500 |
ppm |
This is a qualitative sensor |
|
SEN0570_SMOKE |
0X0012 |
SMOKE |
0X00 |
uint16_t |
10-1000 |
ppm |
This is a qualitative sensor |
|
SEN0571_ODOR |
0X0013 |
ODOR |
0X00 |
uint16_t |
0.5-50 |
ppm |
This is a qualitative sensor |
|
SEN0572_H2 |
0X0014 |
H2 |
0X00 |
uint16_t |
0.1-1000 |
ppm |
This is a qualitative sensor |
|
SEN0574_NO2 |
0X0015 |
NO2 |
0X00 |
uint16_t |
0.1-10 |
ppm |
This is a qualitative sensor |