TMCnet News

A Design of the IOT Gateway for Agricultural Greenhouse [Sensors & Transducers (Canada)]
[July 17, 2014]

A Design of the IOT Gateway for Agricultural Greenhouse [Sensors & Transducers (Canada)]


(Sensors & Transducers (Canada) Via Acquire Media NewsEdge) Abstract: This article put forward a method to realize the transmission between wireless sensor network and the Internet. The IOT (Internet of Things) gateway is used as part of the greenhouse monitoring system. The design compatible multiple access method such as LAN, Wifi, GPRS, EDGE, 3G and so on, also the data can stored locally. The IOT gateway uses STM32 as the MCU, µC/OS-III as the embedded operating system. The application demonstrates the gateway is reliable, compatible, and extendible. Because of this gateway the greenhouse monitoring system realized the real-time detection and control of the greenhouse, and improved the ability of the automation and the intelligent of the greenhouse monitoring. Copyright © 2014 IFSA Publishing, S. L.



Keywords: Internet of things, LAN, GPRS, Embedded operating system, STM32.

1. Introduction With the development of society, traditional forms of agriculture can't satisfy people's needs, so agriculture must be change to satisfy people's needs. The development of Internet technology has brought light to the development of agricultural modernization, agricultural Internet of things has become the inevitable trend of agricultural informatization. Through the remote monitoring and control of greenhouse, the greenhouse monitoring system realized the precise measurement and real time control of the greenhouse. Also the greenhouse monitoring system can implement the scientific management methods, improve crop disaster prevention ability and increase production [1], The greenhouse monitoring system is designed to satisfy the need of the remote monitoring and control of greenhouse. In this paper the design of the gateway will be introduced and the gateway is the core of the system. The IOT gateway is a join point of public network and wireless sensor network in greenhouse monitoring and control system. And the function of the gateway is realized data gathering, upload and processing remote user control information. The gateway is based on modularization method and the using of the method improved the compatibility and better meets the needs of complex agricultural environment.


Because of the electric and network is instability, the design can realize the cable and wireless communication between the gateway and the upper computer, if all the network lose connection, the data will be stored in the SD card, and send to the upper computer when established network connection.

2. The Structure of the Greenhouse Monitoring System This greenhouse monitoring and control system is designed to solve the problem when there are dozens of greenhouses in agricultural production base. If each greenhouse communicates with the remote server independently, the construction is big and the cost is high. So we need gateway to gathering data and send to the remote server unified.

As is shown on the Fig. 1 the greenhouse monitoring and control system is made up of the acquisition and control system in the greenhouses, the gateway and the upper computer, and the ZigBee coordinator is a part of the gateway [2], In terms of function, the greenhouse monitoring and control system includes acquisition and control two parts. The function of acquisition is transfer data from ZigBee coordinator to MCU, and then the MCU encapsulate data into the appropriate format and transfer to the upper computer. The function of control is transfer data from upper computer to MCU, and then the MCU encapsulate data into the appropriate format and transfer to the acquisition and control system through ZigBee coordinator.

3. The Hardware Design of the IOT Gateway 3.1. The System Design of the IOT Gateway As is shown on the Fig. 2 the hardware design of the IOT gateway is made up of Ethernet PHY, ZigBee module, GPRS module (replaceable) [3]. And the MCU using STM32F107, which based on Cortex-M3 [4], DP83848 is using as the Ethernet PHY and connected the Ethernet MAC of the MCU through MIL 3.2. The Design of ZigBee Coordinator ZigBee node devices have the feature in low energy consumption, simple network flexible, low cost and low equipment complexity, so they are suitable to using in the greenhouse IOT. The ZigBee module in the gateway adopts CC2530 of TI Company, is as the role of coordinator, and connected with STM32 through serial interface. This coordinator has the responsible to launch and configuration network, collect data and transfer realtime data to STM32 [5].

3.3. The Design of GPRS Module The communication of GPRS is coverage widely, transmission efficiency highly, also easy to use and flexible, and the TCP/IP data transmission reliability is highly [6]. This design use MG323 as an example to introduce the GPRS module. MG323 module is made up of GSM base band control, RF transceiver, power module, MCP storage, 26 MHz reference clock, RF front-end module, receiving filter. The serial port interface level of MG323 is TTL, so MG323 can connect with the serial port interface of STM32. The consumption of MG323 is low, so if the transmission speed is not request MG323 is suit to the greenhouse monitoring system.

For the greenhouse monitoring system which request the transmission speed MG323 can be replaced with SIM5216E, which is 3G module and the transmission speed can be 7.2 Mbps [7].

4. The Design of Software 4.1. The System Design of Software As is shown on the Fig. 3, this system adopted development mode of layering [8]. The hardware layer is mainly to complete the hardware driver development of each module. Operating system layer is mainly to complete the transplantation of pC/OS-III embedded operating system. Application layer is mainly complete the development of application. The task of the system is made up of the task of Ethernet communication, GPRS communication, SD storage and ZigBee communication.

4.2. Transplant of pC/OS-III This design chooses STM32 as the MCU, so the design adopts pC/OS-III as the embedded operating system, because of the embedded operating system the application associated with the code of the upper only and has nothing to do with the processor. When making software transplant only need to modify the underlying function related to hardware. And it improves the portability and maintainability of the system.

Transplant of pC/OS-III [9] mainly contains OS, CPU and BSP, as follows: 1) OS CPU.H, OS CPU A.ASM, OS_CPU_C.C three files about core need to modification.

OSCPU.H contains processorand implementation-specific #defines constants, macros, and typedefs.

OS CPU C.C contains nine hook function and OSTaskStkInit().

OS_CPU_A.ASM contains five fairly simple assembly language functions.

2) CPU.H, CPU A.ASM, CPU_C.C three files about CPU need to modification.

CPU c. defines many data types.

CPU_A.ASM contains the assembly code, such as the interrupt function to open the interrupt function, count the reset function to wait.

CPU_C.C is an optional file, and keeps the CPU timer interrupt controller code.

3) Create BSP adapted to the target board of board support package level.

BSP.C and BSP.H help manage board of peripherals logically.

BSPJNT.C and BSPJNT.H hold function associated with the interrupt controller.

4.3. Protocol Conversion The gateway transfer data to acquisition and control system via ZigBee protocol, and transfer data to upper computer via GPRS or Ethernet. So protocol conversion is need when transfer data. Fig. 4 is the protocol conversion diagram [10].

We know that in TCP/IP protocol, the transfer of Ethernet data is recognized by MAC, and ARP complete the conversion between IP and the MAC of DLL. So ZigBee nodes also need a way to recognition when transfer data, just like the transfer of Ethernet data. Then the mapping relation is build between MAC of ZigBee and IP to realize the conversion of IP, and is completed in the address adaptation layer. Then data format convert is completed by using unified application protocol in application protocol layer. And application program layer realized the specific function of the gateway, and running as the form of the task of pC/OS-III.

4.4. Ethernet communication This design realizes Ethernet communication via LwIP protocol. LwIP protocol communicates with underlying hardware and top applications via interface. LwIP contains 4 layers; physical layer is to complete driver of Ethernet controller. Interface layer is to complete the recognition of MAC by ARP protocol. Network layer is to complete basic network transport protocol, contains IP, ICMP protocol and so on. Network transport layer ensures network data transfer according to certain format. LwIP initial should do first before the TCP_task start, the program of LwIP initial shows below. And Fig. 5 shows the flow chart of Ethernet sends data.

(ProQuest: ... denotes formulae omitted.) 4.5. GPRS Communication STM32 sets the parameters of MG323 via AT instructs. As the way to transfer data is via IP address, several steps is needed to set: 1) AT+CSQ This statement is to query network signal quality, and you may receive +CSQ 29, 99 as answer, 29 is the parameter we need.

2) AT+CREG? This statement is to query network register, and you may receive + CREG 0, 1 as answer.

3) Set the connection protocol via atAsics=0,conType,GPRS0; atAsics=0,passwd,gprs; atAsics=0,user,cm and atAsics=0,apn,cmnet. This is four statements, and each will get return of OK.

4) Set TCP/IP socket, atAsiss=l,srvType,socket; atAsiss=l,conId,0; atAsiss=l,address,"socktcp:// 60.10.130.168:7777". This is three statements, and each will get return of OK, and 60.10.130.168 is the internet IP, 7777 is the intranet port.

5) ATASIS0=1 to open connection, if you receive the answer of ASISW: 1, 1 then success to open TCP/IP connection, and the transfer of data are OK.

The flow chart of GPRS sends data to upper computer is shown Fig. 6. In order to avoid the operators to cut off the connection when GPRS communication in spare time, heartbeat packets is needed.

4.6. The Software Design of ZigBee Module ZigBee protocol is running in ZigBee coordinator, and the protocol is based on 802.15.4 protocol, and is made up of application layer, network layer, data link layer and medium access layer [11].

The gateway is responsible for the establishment of the ZigBee network and to monitor the ZigBee nodes, the flow chart of ZigBee coordinator is shown on Fig. 7. After pC/OS-III startup, initialize ZigBee will be the first, and the upper computer manage the MAC and network address unified.

5. Application Results The software of the upper computer is designed by LabVIEW. LabVIEW is a virtual instrument platform developed by NI Company, which adopts powerful graphic language instead of procedure code. The program behavior of LabVIEW is described by graphic symbols, and eliminates the complicated grammar rules, so the development circle is short just need Interactive graphics front panel to show the control and result of the system [12]. And for LabVIEW it is easy to solve the problem of data collection, data analyze, file processing, waveform processing and arithmetic operations [13].

The upper computer works as is shown on Fig. 8.

In this software, users can choose manual or auto mode. Manual mode needs users to send control instruct by toggle switch on the interface. When choose the mode of auto, software will send control instruct automatic, but we should collect the suitable value for crop growth first.

In the analysis of the Fig. 8, the humidity in the greenhouse is low, so the irrigation instruct is sent. This kind of fine management ensures that the greenhouse crops grown in the most appropriate environment.

6. Conclusions The IOT gateway connect wireless sensor network with the Internet, ensure the operation of the greenhouse monitoring system, and make it convenient to remote monitoring large-scale greenhouse, also make it easy to fine planting. The practical application approved that the gateway run fine in the greenhouse monitoring system, the environment data of the greenhouse can transfer reliably, and the control instruction sent timely. This design realizes remote intelligent monitoring and control of greenhouse, and is helpful to farms to scientific and rational planting crops. So this design has certain of value to popularize.

References [1] . Burrell J., Brooke T., Beckwith R., Vineyard computing: Sensor networks in agriculture production, IEEE Pervasive Computing, Vol. 3, Issue 1,2004, pp. 38-45.

[2] . Zheng Qiang, Peng Lin, Zou Qiuxia, Gao Lutao, The Design of Remote Greenhouse Monitoring System Based on the Embedded Web Server, Agricultural Mechanization Research, Vol. 11, Issue 11, 2013, pp. 84-87.

[3] . Zhong Ke, Chen Xiangdong, Design on Smart Home Service Gateway based on IOT, Communications Technology, Vol. 45, Issue 8,2012, pp. 65-67.

[4] . Yin Jiting, Yuan Jia, Jiao Zhiman, Wu Bin, Research and Development of Smart Home Control System Based on ARM and ZigBee, Computer Measurement & Control, Vol. 21, Issue 9,2013, pp. 2451-2454.

[5] . Li Wen, Design of a Chicken House Environment Control System Based on ZigBee and Ethernet Technology, Agricultural Mechanization Research, Vol. 11, Issue 11,2010, pp. 126-129.

[6] . Jia Kejin, Han Yu, Qian Chunyang, Du Taihang, STM32-based Data Transfer Module in Monitoring System for Cold Chain Transportation, Control and Instruments in Chemical Industry, Vol. 2, Issue 40, 2013, pp. 136-141.

[7] . Wang Yonggang, Jia Kejin, Zhou Meng, Low-power Intelligent Irrigation System Based on LIN Bus, Water Saving Irrigation, Vol. 10, 2013, pp. 77-80.

[8] Li Meng, Yang Bin, Chen Weikun, Liu Meng, Design of Embedded Industrial Wireless Gateway Based on ARM, Automation & Instrumentation, Vol. 9,2013, pp. 29-32,57.

[9] . Micrium_uC-Eval-STM32F107_uCOS-III. [201302-08] ttp://micrium.com/downloadcenter/downloadresults/?searchterm=mp-uc-os-iii-1 &supported=true.

[10] . Xu Songsong, Zhou Xifeng, Guo Qian'Gang, Design of ZigBee gateway system based on ARM, Network and Communication, Vol. 32, Issue 16, 2013, pp. 51-53.

[11] . Jang Feng, Zhao Wei, ZigBee Technology Application in Green House Wireless Monitoring System, Agricultural Mechanization Research, Vol. 9, Issue 9,2013, pp. 218-222.

[12] . Rick Bitter, Taqi Mohiuddin, Matt Nawrocki, Lab VIEW Advanced Programming Techniques, CRC Press, 2001.

[13] . Zhu Fengwu, Zou Lina, Tu Chuanchuan, Yu Fenghua, Shen Xiao, The research of the pigpen temperature monitoring and control system based on LabVIEW, Journal of Chinese Agricultural Mechanization, Vol. 34, Issue 2,2013, pp. 127-130.

1 Guohong Li,2 Wenjing Zhang,2 Yi Zhang 1 North China Institute of Aerospace Engineering, Hebei Langfang, 065000, China 2 School of Information Engineering, Hebei University of Technology, Tianjin, 300401, China 2 Tel.: 18660683753 E-mail: [email protected] Received: 14 April 2014 /Accepted: 30 May 2014 /Published: 30 June 2014 (c) 2014 IFSA Publishing, S.L.

[ Back To TMCnet.com's Homepage ]