A Multi-Interface Data Acquisition Gateway Based On 6lowpan For Multi-Sensor Situation
A Multi-Interface Data Acquisition Gateway Based On 6lowpan For Multi-Sensor Situation
School of Control Science and School of Control Science and School of Control Science and
Engineering Engineering Engineering
Dalian University of Technology Dalian University of Technology Dalian University of Technology
Dalian, China Dalian, China Dalian, China
[email protected] [email protected] [email protected]
Abstract—The IPv6 over Low Power Wireless Personal Area Things (IoT) based medical service framework. Kumar et al. [4]
Network (6LoWPAN) has been used in many areas. How to used 6LoWPAN to construct wireless sensor network to create
reduce the number of 6LoWPAN nodes in multi-sensor situation an autonomous, self-regulating system. In literature [5],
needs to be studied. This paper describes the design and researchers designed a fire monitoring system based on multi-
implementation of a multi-interface data acquisition gateway gas and thermal imaging, and the sensors are connected
based on 6LoWPAN. The gateway has 6 kinds of data acquisition wirelessly over 6LoWPAN. These researches have made great
interfaces, including RS485, CAN, LoRa, ZigBee, 4G and GPRS. contributions to the 6LoWPAN popularized. However, there
Modbus is the protocol of these interfaces’ application layer. The
are still some problems need to be considered. One of these
gateway is designed with a modular approach, which is easy to be
problems is how to reduce the number of 6LoWPAN nodes in
extended or tailored for other applications. Since the acquisition
task quantity of the gateway changes with the configuration, and
the multi-sensor situation. The multi-sensor situation includes
has the characteristics of multi-task synchronization and real- two aspects, multiple sensors of the same type and multiple
time response, the software design of the gateway is based on the different types of sensors. Generating one 6LoWPAN node for
FreeRTOS real-time system to meet the above requirements. In each sensor in the multi-sensor situation will result in an
the 6LoWPAN network, the acquisition gateway acts as a increase in the number of 6LoWPAN nodes and the routing
6LoWPAN node. After configuring the gateway through serial complexity of 6LoWPAN network will increases, and the
port, the gateway first reads sensor data from the interface and system cost and power consumption too. This problem has
then sends the data to the 6LoWPAN module. The test results attracted the attention of some researchers. Macayana et al. [6]
show that the gateway can read the sensor data correctly used the combination of 6LoWPAN and CAN to build
according to the configuration requirements. The purpose of hydroponics sensor network to reduce the number of
using the multi-interface and bus protocol is to reduce the 6LoWPAN nodes in the system. Luo [7] studied the smart
number of 6LoWPAN nodes required in the multi-sensor campus data collection based on 6LoWPAN, and the
situation, thus reducing the routing complexity of the 6LoWPAN 6LoWPAN node had several types of sensor data interfaces.
network, system cost and power consumption. Their researches were helpful to reduce the amount of
6LoWPAN nodes in multi-sensor situation. However, literature
Keywords—6LoWPAN, multi-interface, Modbus, FreeRTOS [6] only considered the interface of CAN. Although there are
I. INTRODUCTION many interfaces in [7], most interfaces were Transistor-
Transistor Logic (TTL), and only RS485 supported individual
6LoWPAN is a low power wireless personal area network devices. There is still some work to do to solve this problem,
protocol based on IPv6, and its physical level standard is IEEE and that is the purpose of this paper.
802.15.4. It has the features such as low power and low rate,
and this technology makes it possible for the resources limited This paper designs a multi-interface data acquisition
devices to support Internet Protocol (IP). In recent years, it has gateway based on 6LoWPAN, covering six interfaces,
attracted the attention of many researchers. 6LoWPAN has including RS485, CAN, LoRa, ZigBee, 4G and GPRS. RS485
been used in many areas, such as construction, electric power, and CAN are field bus communication technologies widely
medical services, agriculture and fire monitoring. For example, used in industry. LoRa is a wireless communication technology,
6LoWPAN was used to establish a wireless communication which is based on spread spectrum modulation technology and
network of various operators and sensors in the building enables wireless communication to transmit long distance at
environment, which helps to reduce the cost and deployment low rate, which only includes the physical layer. The physical
complexity of smart building monitoring and controlling layer protocol of ZigBee is IEEE 802.15.4, and the ZigBee
system [1]. GUO et al. [2] designed a remote meter reading standard defines the network layer and application layer. It
module based on 6LoWPAN, and compared with other supports star connection, tree connection and mesh connection
systems, 6LoWPAN provides better network stability and and has been applied in many fields. In addition, considering
lower power consumption. Singh et al. [3] proposed using that some applications require the gateway to collect remote
6LoWPAN to collect sensor data with integrated temperature, sensor data, this paper selects 4G and GPRS for remote data
electrocardiogram and pulse parameters to build an Internet of acquisition. The physical layer of the above six kinds of
Authorized licensed use limited to: UDESC - Universidade do Estado de Santa Catarina. Downloaded on September 08,2021 at 21:03:05 UTC from IEEE Xplore. Restrictions apply.
communication varies. In this paper, the actual application include 4G and GPRS, and their communication with the
layer protocol used in these six kinds of communication is microcontroller are UART. As well as the ZigBee module, the
Modbus, which is due to the fact that Modbus protocol can working mode of 4G and GPRS module can be modified
support multiple devices and its simplicity. through the UART interface. The configuration interface
provides configuration support for the gateway. It connects to
II. HARDWARE DESIGN the UART of the microcontroller and converts UART
communication to USB communication through USB to TTL
chip (CH340G). In this way, the gateway can be connected to a
RS485 computer via a USB cable, and the gateway can be configured
UART
CAN Interface
UART
6LoWPAN Modlue communicates with the microcontroller through UART. The
LoRa Modlue microcontroller sends the collected data to the 6LoWPAN
SPI
ZigBee
STM32F407 module, through which the devices in the 6LoWPAN network
UART UART UART
Module can read the data collected by the gateway. The gateway is
Configuration designed according to the idea of modularization, which is
UART
interface.
Fig. 2. Software architecture.
In this gateway, the UART of ZigBee module can be
connected to the configuration interface through the selection Software architecture is shown in Fig. 2. The first is the
of jumper cap, and the ZigBee module can be configured by system and peripherals initialization, which includes
the computer. Remote wireless data acquisition interfaces initialization of clock, interrupt, UART, CAN, SPI, and so on.
65
Authorized licensed use limited to: UDESC - Universidade do Estado de Santa Catarina. Downloaded on September 08,2021 at 21:03:05 UTC from IEEE Xplore. Restrictions apply.
The next is FreeRTOS initialization, which calls FreeRTOS C. Acquisition Task
API function to create six acquisition tasks, configuration task Begin
and 6LoWPAN network forwarding task, and create two event
flag groups for synchronizing tasks and managing shared
resources respectively. Finally, FreeRTOS scheduling is started, List Head
and each task executes under the FreeRTOS kernel scheduling.
Traverse the linked
B. Configuration Task list of configuration
The serial port configuration task completes the functions information
of adding, deleting, changing and checking the configuration
information table. The configuration information table contains Send reading
the interface's physical layer, Modbus application layer instruction
information and acquisition cycle. The configuration
information at the physical layer is for RS485, CAN and LoRa Timing starts
interfaces, while the configuration information at the physical
layer of ZigBee, 4G and GPRS interfaces is stored in the Waiting Received data
modules’ own memory, and their configuration is realized by
the computer. The physical configuration information of
RS485, CAN and LoRa is stored in the FLASH of Timing ends
microcontroller, which is set by configuration interface. The
RS485 interface configuration information includes
communication baud rate, data bits, stop bits, parity. The CAN No Are all
devices
interface configuration information includes communication traversed ?
speed and frame ID. The LoRa interface configuration
information includes working frequency and the Yes
communication rate.
Fig. 4. The acquisition task workflow on the RS485 interface.
next 6,ĂĂ next 7,ĂĂ next 5,ĂĂ null The acquisition task sends the reading messages on the
communication interface according to the configuration table,
and saves the received data. The work flow of the six
Head acquisition tasks is the same, and the acquisition task of RS485
Fig. 3. Example of device Modbus information linked list on RS485 interface is taken as an example to illustrate here. The
interface. workflow of the acquisition task of RS485 interface is shown
in Fig. 4. The acquisition task traverses the Modbus
The Modbus application layer information includes device configuration information table of RS485 interface. First, the
address, start register address, register length and other read data instruction is sent out according to the configuration
information. It is for devices, and each device has a table. Then, it sets a timer and waits for the response. If the
configuration information table corresponding to it. For response is received during the timing period, the received data
devices under the same interface, their configuration is saved and then waited until the end of the timing before
information table is stored in a linear linked list, which makes continuing to read the next device on the linked list. If no data
the operation of adding and deleting devices very convenient. is received during the timer period, the next device on the list is
For example, if three devices are created on the RS485 read directly after the timer ends. In the process of RS485
interface with the addresses of 5, 7, and 6 respectively, the list acquisition task waiting for the end of timing, it will be blocked,
as shown in Fig. 3 will be generated. Each interface in the and the task with the highest priority in the ready task list will
software has a linked list of configuration information be executed. For example, if the CAN acquisition task gets the
corresponding to it, and all the linked pointer are stored in an execution right, the devices on CAN interface will be traversed.
array for quick query. The timing time set here is the device acquisition cycle on the
RS485 interface divided by the number of devices on RS485
The data acquisition cycle is specific to the interface, that is,
interface. After the traversal, the reading continues from the
all devices on an interface in the gateway have the same data
list’s head.
acquisition cycle. The collection cycle is configured by the
serial port, and each interface has a collection cycle, which is D. 6LoWPAN Forwarding Task
stored in an array. When a message is received from the The 6LoWPAN network forwarding task is responsible for
configuration serial port, the configuration task parses the forwarding the data received by the acquisition task to the
message. During parsing, if an illegal field is found, the parsing 6LoWPAN module, so that other devices in the 6LoWPAN
operation is terminated and an error report is printed on the network or in the Internet can read the data collected by the
serial port. After parsing, modify the configuration information gateway. The process of this task is to traverse the linked list of
table and save it to the FLASH of microcontroller, and print device configuration information for each interface, and then
the configuration results in the serial port. send the collected data to the 6LoWPAN module. The
66
Authorized licensed use limited to: UDESC - Universidade do Estado de Santa Catarina. Downloaded on September 08,2021 at 21:03:05 UTC from IEEE Xplore. Restrictions apply.
microcontroller sends the gateway's last data collected to the should be noted that the physical interfaces of these sensors are
6LoWPAN module, and the transmission cycle is fixed at different, and it will not have any effect even if these devices
100ms. have the same Modbus address. Named items give physical
meaning to the sensor data to increase the readability of the test
IV. EXPERIMENT TESTS results.
A. Construction of the Test System B. Testing Process
In the test of the gateway, the gateway needs to be
1.PM2.5 sensor
2.Temprature sensor
configured first. During the configuration, a USB cable is used
3.Light sensor
to connect the gateway to the computer. After the configuration
4.VOC sensor of the gateway with the help of computer software, the system
5.Humidity sensor test starts. The connection relationship of the system is shown
6.CO2 sensor in the Fig. 6.
7.Acquisition gateway
The working principle is as follows. Firstly, the IPv4 router
8.Ipv4 router
9.6LoWPANEdge router
allocates IPv4 addresses to the computer and the 6LoWPAN
edge router, generating the LAN. Then, the 6LoWPAN edge
router creates the RPL network as the ROOT node. Moreover,
Fig. 5. Physical photos of the test system. the 6LoWPAN acquisition gateway is added to the RPL
network. The 6LoWPAN edge router maps the IPv6 address
TABLE I. SENSOR INFORMATION
and port of the 6LoWPAN acquisition gateway to a port on its
own IPv4 address with the NAT technology, thus
Type Interface Device Start Register Name communication between the computer and the 6LoWPAN
address address length
PM2.5 RS485 1 0 1 “PM25(ug/ml)”
acquisition gateway is established. The resources of the
Temperature CAN 1 0 1
6LoWPAN acquisition gateway can be accessed on the
“Temp(℃/100)”
computer using the Firefox browser with the Coap protocol
Light LoRa 1 5 1 “Light(Lux)” debugging plug-in, where the 6LoWPAN acquisition gateway
VOC ZigBee 1 19 1 “VOC(ppm)” acts as the Coap server and the Firefox browser acts as the
Humidity 4G 1 3 1 “Humi(%RH/10)” Coap client.
CO2 GPRS 2 1 1 “CO2(ppm)”
CAN
LoRa
67
Authorized licensed use limited to: UDESC - Universidade do Estado de Santa Catarina. Downloaded on September 08,2021 at 21:03:05 UTC from IEEE Xplore. Restrictions apply.
C. Test Results configuration. This research has great significance on how to
Fig. 7 shows the interface of 6LoWPAN sensor/485 apply 6LoWPAN in multi-sensor situation. In the future, we
resource accessed in Firefox. The incoming line reads will further study based on engineering needs, test, analyze and
"PM25(ug/ml):26". It means the PM2.5 density was read as 26 evaluate various performance indexes of the multi-interface
ug/ml on the RS485 interface. The access results for each acquisition gateway, compare and study the performance of
interface are shown in Table Ⅱ. The data collected by each 6LoWPAN network under two different modes, single sensor
interface can be correctly read on the browser, indicating that single node and multi-sensor single node, to promote the
the gateway is working normally in accordance with the application and development of 6LoWPAN.
expected configuration and its functional indicators are ACKNOWLEDGMENT
qualified.
This work is supported by CERNET Innovation Project
TABLE II. THE RESULTS ACCESSED BY EACH INTERFACE (NGII20190303), and by National Natural Science Foundation
Interface Result
of China (61803067), and by the Fundamental Research Funds
for the Central Universities of China (DUT20JC45,
RS485 “PM25(ug/ml):26ā DUT20JC15).
CAN ĀTemp(℃/100):3037ā
LoRa ĀLight(Lux):412ā REFERENCES
ZigBee ĀVOC(ppm):152ā [1] M. Vo, N. Do, V. Tran, Q. Ma, C. Le and L. Mai, “A multi-storey
4G ĀHumi(%RH/10):500ā building actuator and sensor system using 6L0WPAN based Internet of
GPRS ĀCO2(ppm):614ā Things: Practical design and implementation,” 2018 2nd International
Conference on Recent Advances in Signal Processing,
Telecommunications & Computing (SigTelCom), Ho Chi Minh City,
2018, pp. 176-181.
V. CONCLUSION [2] S. Guo, W. Luan and X. Su, “The design of a remote meter acquisition
This paper presents the design and implementation of a module based on 6LoWPAN,” 2016 China International Conference on
multi-interface data acquisition gateway based on 6LoWPAN, Electricity Distribution (CICED), Xi'an, 2016, pp. 1-4.
and validates its functionality. Six physical interfaces are [3] I. Singh and D. Kumar, “Improving IOT Based Architecture of
Healthcare System,” 2019 4th International Conference on Information
electrically independent and do not affect each other. Modular Systems and Computer Networks (ISCON), Mathura, India, 2019, pp.
design improves the tailoring and expansion of gateway. At the 113-117.
same time, the physical layer of each interface is configurable, [4] N. H. Kumar, S. Baskaran, S. Hariraj and V. Krishnan, “An
which expands the scope of application of gateways. The Autonomous Aquaponics System Using 6LoWPAN Based WSN,” 2016
Modbus protocol is used in the application layer of the IEEE 4th International Conference on Future Internet of Things and
interface, so that multiple devices can be connected on one Cloud Workshops (FiCloudW), Vienna, 2016, pp. 125-132.
interface. Compared with the mode of one sensor with one [5] E. D. Dimaunahan, A. D. S. Santos, E. F. H. Paloma, et al., “A
6LoWPAN-Based Thermal Measurement, and Gas Leak for Early Fire
6LoWPAN node, the size of the 6LoWPAN node is greatly Detection Using Artificial Neural Network,” In Proceedings of the 2019
reduced if this gateway is used, which directly reduces the 5th International Conference on Computing and Artificial Intelligenc,
routing complexity, system cost and power consumption of the Association for Computing Machinery, New York, NY, USA, 2019,
6LoWPAN network. Software design is based on FreeRTOS pp.170̽174.
real-time system, With the resources provided by FreeRTOS to [6] Y. L. K. Macayana, V. A. Coronel, I. C. Fernandez, et al.,
manage and schedule each task, the program can run stably and “Implementation of 6LoWPAN and Controller Area Network for a
Smart Hydroponics System,” 2019 Global IoT Summit (GIoTS), Aarhus,
improve the overall performance of the software. Denmark, 2019, pp. 1-4.
In order to verify the function of the gateway, a test system [7] L. Luo, “Data Acquisition and Analysis of Smart Campus Based on
is built. The test results show that the gateway can complete the Wireless Sensor,” Wireless Pers. Commun., vol. 102, pp. 2897̽2911,
2018.
multi-interface data acquisition task according to the expected
68
Authorized licensed use limited to: UDESC - Universidade do Estado de Santa Catarina. Downloaded on September 08,2021 at 21:03:05 UTC from IEEE Xplore. Restrictions apply.