This solution shows how to create an weather monitoring node. The sensor node measures air temperature, air humidity, barometric pressure and environment luminosity values. 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 |
---|---|---|---|---|---|
Barometric1 | Barometric2 | Barometric3 | Barometric4 | Luminosity1 | Luminosity2 |
- 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
- Environment luminosity value is sent as as two bytes, enlarged 100 times for accuracy. For example, 10046 means 100.46 lux, sent as 0x27 0x3E
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 RAK1901 * 1pcs
- WisBlock Sensor RAK1902 * 1pcs
- WisBlock Sensor RAK1903 * 1pcs
- Arduino IDE
- RAK4630 BSP
- Arduino LPS22HB library
- Sparkfun SHTC3 library
- ClosedCube OPT3001 library
- SX126x-Arduino library
The code for the weather monitor node can be found in the sketch file
Here is the log output of the application:
09:41:40.546 -> =====================================
09:41:40.546 -> Welcome to RAK4630 LoRaWan!!!
09:41:40.546 -> Type: OTAA
09:41:40.546 -> Region: EU868
09:41:40.546 -> =====================================
09:41:40.546 -> shtc3 init
09:41:40.546 -> Beginning sensor. Result =
09:41:40.546 -> ID Passed Checksum. Device ID: 0b100001000111
09:41:40.546 -> OPT3001 Manufacturer ID21577
09:41:40.546 -> OPT3001 Device ID12289
09:41:40.546 -> OPT3001 Current Config:
09:41:40.546 -> ------------------------------
09:41:40.546 -> Conversion ready (R):0
09:41:40.546 -> Conversion time (R/W):0
09:41:40.546 -> Fault count field (R/W):0
09:41:40.546 -> Flag high field (R-only):0
09:41:40.546 -> Flag low field (R-only):0
09:41:40.546 -> Latch field (R/W):1
09:41:40.546 -> Mask exponent field (R/W):0
09:41:40.546 -> Mode of conversion operation (R/W):3
09:41:40.546 -> Polarity field (R/W):0
09:41:40.546 -> Overflow flag (R-only):0
09:41:40.546 -> Range number (R/W):C
09:41:40.546 -> ------------------------------
09:41:45.753 -> OTAA Mode, Network Joined!
09:42:06.746 -> Sending frame now...
09:42:06.746 -> result: Tem:27.88C Hum:70.61% Pres:75.97KPa Lig:529.92lux
09:42:06.781 -> lmh_send ok count 1
09:42:26.749 -> Sending frame now...
09:42:26.749 -> result: Tem:27.89C Hum:70.63% Pres:95.33KPa Lig:530.88lux
09:42:26.749 -> lmh_send ok count 2
Data arrives at LoRaWAN® server.
LoRa® is a registered trademark or service mark of Semtech Corporation or its affiliates. LoRaWAN® is a licensed mark.