Skip to content

Latest commit

 

History

History
386 lines (296 loc) · 11.7 KB

File metadata and controls

386 lines (296 loc) · 11.7 KB

PAR Monitoring over LoRaWAN®

[TOC]

1. Introduction

exa-par-solution

This solution shows how to create an agriculture sensor node. The sensor node measures photosynthetically active radiation (PAR) 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
11 PAR1 PAR2
where
  • Byte 1 is a marker for the data type, here always 11 (0x0B)
  • PAR is sent as PAR1PAR2 e.g. 1009 PAR (would be 0x03 0xF1 in the data package)

1.1 LoraWAN®

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® /)

1.2 Modbus

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.

exa-par-regmap

In our example, we are going to read the PAR value from our device. We can see in the register map on above, the default Device Address is 1, the PAR 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) = 71 => PAR is 71 W/㎡

2. Hardware required

To build this system, the following hardware are required:

WisBlock Base RAK5005-O * 1pcs

WisBlock Core RAK4631 * 1pcs

WisBlock IO RAK5802 * 1pcs

JXBS-3001-GHFS * 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:

exa-par-assy

exa-par-assy

3. Software required

3.1 Install library

lib-manager

lib-rs485-install

lib-modbus-install

lib-sx12x-install

4. Example

The code for the agriculture PAR 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
=====================================
-------par------ = 23 w/m2
OTAA Mode, Network Joined!
-------par------ = 9 w/m2
-------par------ = 16 w/m2
Sending frame now...
lmh_send ok count 1
-------par------ = 41 w/m2
-------par------ = 43 w/m2
Sending frame now...
lmh_send ok count 2
-------par------ = 7 w/m2
-------par------ = 0 w/m2
Sending frame now...
lmh_send ok count 3

The logs of LoraWan Server is as follows:

exa-par-data

LoRa® is a registered trademark or service mark of Semtech Corporation or its affiliates. LoRaWAN® is a licensed mark.