[TOC]
This solution shows how to create an agriculture soil pH value sensor node. The sensor node measures the soil pH value from a sensor with a RS485 interface. It then transmits this data frequently over LoRaWAN®to a LoRaWAN® server.
At the LoRaWAN® server the data arrives in the following format
Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 |
---|---|---|---|---|---|---|
8 | CON1 | CON2 | T1 | T2 | H1 | H2 |
where |
- Byte 1 is a marker for the data type, here always 8
- pH value is sent as
PH1PH2
e.g. 45 (would be 0x00 0x2D in the data package)
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.
If you want to know how to use the LoRa® communication with WisBlock. You can refer to the following document.
[LoRaWAN® ](/examples/RAK4630/communications/LoRa/LoRaWAN® /)
Modbus has become a standard communications protocol and is now the most commonly available means of communicating with industrial electronic devices. In this case, the wind speed sensor supports Modbus protocol over RS-485 physical layers.
All Modbus devices include a register map with the location and a description of the data stored in the registers. Modbus functions operate on register map to monitor, configure, and control the device’s inputs and outputs. You have to refer to the register map of your device to gain a better understanding of its operation. Modbus registers are organized into reference types identified by the leading number of the reference address. You can see below an example of how to read and write data in a Modbus device.
In our example, we are going to read the high precision pH value from our device. We can see in the register map on above, the default Device Address is 1, the pH value is stored in the register 0006H, and is accessible with the function ModbusRTUClient.requestFrom(), and is stored in 16 bits format (2 bytes).
ModbusRTUClient.requestFrom(1, HOLDING_REGISTERS, 0x0006, 2)
HOLDING_REGISTERS is 0x03. To get more detail, Please refer to Modbus protocol specification
If result is 0x0047.
0x0047(H) = 308 => pH is 3.08
To build this system, the following hardware are required:
WisBlock Base RAK5005-O * 1pcs
WisBlock Core RAK4631 * 1pcs
WisBlock IO RAK5802 * 1pcs
JXBS-3001-PH-RS * 1pcs
Note: To send the data of sensor node to LoRaWan® server, a LoRaWan® gateway is also needed. If you don't have, we recommend you use RAK7243.
The assembly of sensor node is as follows:
The code for the agriculture pH value sensor node can be found in the sketch file
The logs of sensor node is as follows:
=====================================
Welcome to RAK4630 LoRaWan!!!
Type: OTAA
Region: EU868
=====================================
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
OTAA Mode, Network Joined!
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
lmh_send ok count 1
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
lmh_send ok count 2
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
lmh_send ok count 3
-------ph------ = 7.000000
-----raw_ph = 0x2bc-----
The logs of LoRaWAN® Server is as follows:
LoRa® is a registered trademark or service mark of Semtech Corporation or its affiliates. LoRaWAN® is a licensed mark.