[TOC]
This solution shows how to create an agriculture soil conductivity sensor node. The sensor node measures the soil conductivity, soil temperature and soil humidity 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 |
---|---|---|---|---|---|---|
11 | CON1 | CON2 | T1 | T2 | H1 | H2 |
where |
- Byte 1 is a marker for the data type, here always 11 (0x0B)
- Conductivity is sent as
CON1CON2
e.g. 1009 (would be 0x03 0xF1 in the data package) - Temperature is sent as
T1.T2
e.g. 23.50 C - Humidity is sent as
H1.H2
e.g. 45.91 %
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.
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 Soil Humidity Soil Temperature and Soil Conductivity from our device. We can see in the register map on above, the default Device Address is 1, the humidity value is stored in the register 0002H, the temperature value is stored in the register 0003H, the conductivity value is stored in the register 0015H and is accessible with the function ModbusRTUClient.requestFrom(), and is stored in 16 bits format (2 bytes).
ModbusRTUClient.requestFrom(1, HOLDING_REGISTERS, 0x0002, 2)
ModbusRTUClient.requestFrom(1, HOLDING_REGISTERS, 0x0003, 2)
ModbusRTUClient.requestFrom(1, HOLDING_REGISTERS, 0x0015, 2)
HOLDING_REGISTERS is 0x03. To get more detail, Please refer to Modbus protocol specification
If result is 0x0110 0x00FA 0x001C.
0x0110(H) = 272 => Humidity is 27.2% RH
0x00FA(H) = 250 => Temp is 25 ℃
0x001C(H) = 28 => Conductivity is 28 us/cm
To build this system, the following hardware are required:
WisBlock Base RAK5005-O * 1pcs
WisBlock Core RAK4631 * 1pcs
WisBlock IO RAK5802 * 1pcs
JXBS-3001-EC-RS-4 * 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 soil conductivity 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
=====================================
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 267-------
OTAA Mode, Network Joined!
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 270-------
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 272-------
Sending frame now...
lmh_send ok count 1
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 272-------
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 272-------
Sending frame now...
lmh_send ok count 2
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 270-------
-----raw_conductivity = 28-------
-----raw_temperature = 250-------
-----raw_humidity = 272-------
Sending frame now...
lmh_send ok count 3
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.