<figure><img src="image_1.png" /></figure>

HAL
open science

Research and Design of Wireless Sensor Middleware
Based on STM32

Jiye Zheng, Fengyun Wang, Lei Wang

► To cite this version:

Jiye Zheng, Fengyun Wang, Lei Wang. Research and Design of Wireless Sensor Middleware Based on STM32. 9th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2015, Beijing, China. pp.579-585, 10.1007/978-3-319-48354-2_60 . hal-01614206

HAL Id: hal-01614206

https://inria.hal.science/hal-01614206

Submitted on 10 Oct 2017

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Research and Design of Wireless Sensor Middleware Based on

STM32

Jiye Zheng¹,*, Fengyun Wang¹,†, Lei Wang¹,*,‡

¹S&T Information Institute of Shandong Academy of Agricultural Sciences(SAAS), Jinan250100,
China;

a:jiyezheng@163.com, b:wfylily@163.com, c:375901677@qq.com

**Abstract.** In order to make agricultural production become more convenient, also meet the requirement of the modern intelligent agriculture to make control equipment integrated and miniaturization, the paper designed a wireless sensor middleware based on STM32. This wireless gateway receives control command from the control software of agricultural IOT application which installed in the tablet computer through the WiFi/USART module, after the data processing and protocol conversion, then send the control signal to the wireless sensor network through the USART port. At the same time, if a particular model of agricultural sensor changes state, it also can timely feedback to the tablet computer to display through the gateway. This plan solved the problem of real-time monitoring of agricultural information and realized remote control. The experimental results show that, the wireless sensor middleware has the characteristics of light and handy, high control precision, data large quantity and high speed. It's very appropriate for intelligent agricultural system application.

**Keywords:** STM32; wireless sensor; Middleware; ZigBee

# 1 Introduction

With the rapid development of Internet of things, IOT middleware becomes one of the important research topics in related fields in recent years, also acquired a lot of research results, mainly divided into application service middleware, embedded middleware. Such as White [1] put forward a kind of typical middleware based on J2EE architecture, has a good scalability. Paper [2] proposed wireless sensor network middleware based on mobile Agent, the middleware has data management, integration, application target adaptive control strategy, Wang fan design and implemented an IOT middleware, that can filter the heterogeneous network data, integrate ZIGBEE and RFID (Radio Frequency Identification, RFID) data into a unified format [3]. Paper[4-7] proposed database based middleware, it views the entire network as a distributed database, users use similar to SQL query command to get the data needed, query is distributed to each node through the network, the nodes determine whether the sensory data satisfy the query conditions, and decide to send data or not. Deng Yihua etc. Put forward embedded RFID middleware on smart RFID read-write device [8], it can realize the management of multiple read/write devices, strengthen the deployment flexibility. The domestic scholars make use of the gateway hardware to research IOT system[8-11], however, the research and design of STM32 based wireless sensor network middleware is still relatively rare.

The research combines the ZigBee wireless sensor network with the STM32 MCU, it has the advantages of simple structure, strong generalization ability and others. The objective of this study is to
develop an easy method to implement the remote monitoring and control system for the agricultural production environment.

## 2 Wireless gateway hardware platform design

Wireless gateway is the data transfer station of the Agro-IOT control system and communication media, it is critical to the whole system design. The main frame of the hardware platform is shown as figure 1.

<figure><img src="image_3.png" /><figcaption>Fig. 1. Wireless gateway overall architecture diagram</figcaption></figure>

The hardware involved in this paper include wireless sensor nodes and gateway hardware, hardware design is introduced as follows.

### 2.1 wireless sensor nodes

CC2530 on-chip system is used for the wireless sensor nodes with very low cost and ultralow power consumption. It integrates the microprocessor module and a wireless transceiver module in one single chip. It has the excellent performance of RF transceiver adapting to IEEE 802.15.4 with extra high reception sensitivity and anti-interference. Its core is industry-standard enhanced 8051 microcontroller unit with code prefetching function. CC2530 has four different types of flash memory version i.e. CC2530F32/64/128/256 separately with 32/64/128/256KB in-system programmable flash memory. The microcontroller has 8KB RAM with data remaining capacity under various power supply. CC2530 has various operating modes such as active mode RX (CPU idle), active mode TX 1dBm (CPU idle), power supply mode 1 (4us awake), power supply mode 2 (sleep timer), power supply mode 3 (external interruption), wide voltage range of power supply and so on which makes the energy consumption very low.

The wireless transceiver adopts zigbee technology. It has low power consumption, rapid response and large network capacity etc features. Figure 2 shows the wireless sensor nodes used in the system.

<figure><img src="image_4.png" /></figure>
<caption>**Fig. 2.** Wireless sensor node hardware structure diagram</caption>

According to the function, node types can be divided into three categories, namely the acquisition node (only responsible for data collection), routing nodes (responsible for data gathering and routing), and the coordinator node (network management). All kinds of nodes on the hardware adopts the above design, the coordinator needs a binding to the gateway via the serial port.

## 2.2 gateway hardware

Gateway is the key module of this system, it needs to bind with the coordinator, the gateway Circuit Diagram is shown in figure 3.

<figure><img src="image_5.png" /><figcaption>**Fig. 3.** Gateway Circuit Diagram</figcaption></figure>

Gateway hardware uses STM32F103ZET which core is ARM Cortex-M3. F1-series is the first generation microcontrollers of STM32 that is considered as its mainstream of ARM MCU. With the development of technology, F1 series has many improvements such as CPU speed, size of internal memory and type of peripherals. The excellent peripherals and low-power, low-voltage operation make it with high performance. It is highly integrated with the simple structure and easily used tools which cost is very low. STM32 is control core of the wireless gateway, it mainly divides into five modules, include WiFi module, RF module, a central controller module, power module, JTAG emulation debugging module respectively.

# 3 Wireless gateway software platform design

Wireless sensor network middleware software platform are actually established on the embedded development board wildfire STM32 ISO with transplantation of Linux system, and then Boa Web server, databaseSqlite3 was also set up in the Linux system.

The main task of the wireless sensor network gateway is as follows: access to information of each node in the wireless sensor network, processing a request from the Internet, the wireless sensor network
configuration management, and data statistics and analysis, etc. The main task of wireless sensor network is to monitor the state of the remote device. Literature [12] presents a so-called Cougar middleware system, Cougar views wireless sensor network as the distributed database and the network nodes are divided into clusters, cluster is a collection of multiple nodes, elects a node in the cluster as the cluster head. Paper [13] proposed a flexible wireless sensor network middleware system. The system using Web Service technology and middleware technology, the system views the wireless sensor network as middleware system, each node uses a different SOAP Engine, the coordinator node has a registration module, other sensor nodes have different event handlers, the user can use any SOAP proxy access coordinator node via TCP/IP protocol, and further access to the entire wireless sensor network.

In order to manage the wireless sensor network better and expand Internet connections to the wireless sensor network, through careful analysis of the wireless sensor network monitoring program, and combined with hardware gateway, this paper abstracts a new middleware model as shown in figure 4.

<figure><img src="image_6.png" /><figcaption>Fig. 4. Wireless sensor network middleware structure model</figcaption></figure>

Middleware structure model has many modules include Cluster model controller, Command interpreter, Boa server, database controller and Sensor network coordination interface and so on.

Web server provides HTTP service to external applications, and internally access to interpreter by CGI; The interpreter responds to explain users command, and give orders to the cluster model control layer and accept its response; Model control layer abstracts the clusters for the wireless sensor network, and provides the control interface; Sensor network coordinator interface provides an interface for gateway
to read and write in wireless sensor network, the actual implementation is divided into the gateway and the coordinator two part, the coordinator and the sensor nodes' communication uses data collection protocol.

## 4 Result and Discussion

Wireless Sensor Middleware was used in livestock and poultry breeding, agricultural facilities accurate monitoring, Edible fungus production information collection and similar applications, the coordinator node on the packet is bound to the embedded gateway. Using TCP/IP protocol stack, the communication between monitoring instrument and upper computer was realized. The real time information on the upper computer is like figure 5.

<figure><img src="image_7.png" /><figcaption>Fig. 5. Real time data from the remote sensors</figcaption></figure>

## 5 Conclusions

The research analyzed the IOT middleware research status, and combining the wireless sensor network practice, proposed the Wireless Sensor Middleware Based on STM32. The software has two characteristics include embedded server and application services, it adopted the idea of components, reduced the coupling between modules, the configurable and customizable functionality improved reusability, lower development costs, solve the problems of mass data processing, and provide the visual configuration monitoring platform, the realization of Internet of things "content" of the administration and monitoring, eliminate information isolated island. This middleware application was used in Edible fungus production information collection system, and the results show that the feasibility and effectiveness of the above frameworks and methods.
Acknowledgment

Funds for this research was provided by the National Science and Technology Support Program
(2014BAD08B05-02), Shandong Academy of Agricultural Sciences(SAAS) Youth Scientific Research
Funds Project (2015YQN58),
Independent Innovation Projects of Shandong Province(2014ZZCX07104).

References

1. WHITE S, ALVES A, RORKE D. Web logic event server: a light-weight, modular application server for event processing [C] // Proceedings of the Second International Conference on Distributed E-vent-based Systems. New York: ACM Press, 2008: 193-200.

2. Haiping Huang etc. Wireless sensor network based on mobile Agent middleware [J]. Journal of Nanjing university: natural science edition, 2008, 44 (2) : 157-163.

3. Wang fan. Design and implementation of Internet of things middleware based on ZIGBEE and RFID [D]. Beijing: Beijing University of Posts and telecommunications, 2011.

4. Deng Yihua, sheng-li xie. The design and implementation of embedded RFID middleware [J]. Computer engineering and design, 2008, (7) : 1716-1718.

5. P Bonnet, J Gehrke, P Seshadri. Towards sensor database systems [C] In: Proc of the 2nd International Conference on Mobile Management. Berlin: Springer-Verlag, 2001. 3-14[19].

6. S R Madden, M J Franklin, J M Hellerstein. Tiny DB: An acquisitional query processing system for sensor networks [J] ACM Trans on Database Systems, 2005, 30(1): 122-173[20].

7. C Srisat hapornphat, C Jaikaeo, C Shen. Sensor information networking architecture [C] In: Proc of the Int. 1 Workshop Parallel Processing. Washington: IEEE Computer Society Press,2000. 23-30

8. Makoto ISHIGURO, Kenji TEI, Yoshiaki FUKAZAWA Shinichi HONIDEN, A sensor middleware for lightweight relocatable sensing programs[ C] International Conference on Computational Intelligence for Modelling, Control and Automation, 2006, Sydney Australia, 2006[37].

9. PK Biswas, H Qi, Y Xu. A mobile-agent-based collaborative framework for sensor network applications[C]IEEE International Conference on Mobile Adhoc & Sensor Systems, Vancouver, Canada, 2006[38].

10.Sharifi, Mohsen, Taleghan, Majid Alkaee, Taherkordi, Amirhosein. A middleware layer mechanism for QoS support in wireless sensor networks [C]. The Int. 1 Conf on Networking, Int. 1 Conf on Systems and Int. 1 Conf on Mobile Communications and Learning Technologies, Morne, Mauritius, 2006.

11. Heinzelman, W.B. Middleware to support sensor network applications[j]. IEEE network, 2004,18(1):6-14.

12. Pedro J M, Daniel M, Andreas L. TinyCubus: A flexible and adaptive framework for sensor networks[J]. Journal of Information Technology, 2005, 47(2):87-97.

13. IFIP International Federation for Information Processing[C]. Federal University of Rio de Janeiro: M. Endler and D. Schmidt (Eds.), 2003.