This solution shows how to create an environmental data sensor node. The sensor node measures air temperature, air humidity, barometric pressure and gas levels. After the node joins to server successfully, It then transmits this data periodically to a LoRaWan® server.
Byte1 | Byte2 | Byte3 | Byte4 | Byte5 |
---|---|---|---|---|
1 | Temperature1 | Temperature2 | Humidity1 | Humidity2 |
Byte6 | Byte7 | Byte8 | Byte9 | Byte10 | Byte11 | Byte12 | Byte13 |
---|---|---|---|---|---|---|---|
Barometric1 | Barometric2 | Barometric3 | Barometric4 | Gas1 | Gas2 | Gas3 | Gas4 |
- Byte 1 is a marker for the data type, here always 1
- Every value is MSB first
- Temperature is sent as two bytes, enlarged 100 times for accuracy. For example, 2510 means 25.01 C, sent as 0x09 0xCE
- Humidity is sent as two bytes, enlarged 100 times for accuracy. For example, 4173 means 41.73 %, sent as 0x10 0x4D
- Barometric pressure is sent as four bytes, enlarged 100 times for accuracy. For example, 100945 means 1009.45 hPa, sent as 0x00 0x01 0x8A 0x51
- Gas resistance is sent as as four bytes, For example, 63560 Ohm, sent as 0x00 0x00 0xF8 0x48
If this examples is implemented for the Region US915, DR0 cannot be used because the package size is too large to fit into the allowed payload.
To build this system, the following hardware are required:
- WisBlock Base RAK5005-O * 1pcs
- WisBlock Core RAK4631 * 1pcs
- WisBlock Sensor RAK1906 * 1pcs
- Arduino IDE
- RAK4630 BSP
- ClosedCube BME680 library
- SX126x-Arduino library
The code for the environment sensor node can be found in the sketch file
10:30:07.777 -> =====================================
10:30:07.777 -> Welcome to RAK4630 LoRaWan!!!
10:30:07.777 -> Type: OTAA
10:30:07.777 -> Region: EU868
10:30:07.777 -> =====================================
10:30:07.777 -> Chip ID=0x61
10:30:12.974 -> OTAA Mode, Network Joined!
10:30:33.999 -> Sending frame now...
10:30:33.999 -> result: Tem:28.70C Hum:67.00% Pres:948.50KPa Gas:27646Ohms
10:30:33.999 -> lmh_send ok count 1
10:30:53.979 -> Sending frame now...
10:30:53.979 -> result: Tem:28.70C Hum:67.00% Pres:948.50KPa Gas:242488Ohms
10:30:54.012 -> lmh_send ok count 2
10:31:14.006 -> Sending frame now...
10:31:14.006 -> result: Tem:28.70C Hum:67.00% Pres:948.50KPa Gas:457174Ohms
10:31:14.006 -> lmh_send ok count 3
10:31:33.997 -> Sending frame now...
10:31:33.997 -> result: Tem:28.69C Hum:67.00% Pres:948.50KPa Gas:74102Ohms
10:31:34.032 -> lmh_send ok count 4
Data arrives at LoRaWAN® server.
LoRa® is a registered trademark or service mark of Semtech Corporation or its affiliates. LoRaWAN® is a licensed mark.