A Design of Online Tobacco Moisture Monitoring System

This paper introduces a moisture monitor based on NB-IoT which can be used to remotely measure the moisture of tobacco packet that will be stored for a long time. The sensor section of the device uses a capacitive method to complete capacitance to voltage conversion and the monitor uses STM32 to control the sensor work. The measured data is transmitted to the web server through NB-IoT, and further data analysis and processing can be performed on the server side. The moisture monitor designed by us in this paper has achieved high precision, low power consumption and low packet loss rate after being used in the tobacco warehouse. The device can work for two years and the status of tobacco moisture was monitored steadily.


Introduction
Tobacco leaves are the raw material basis of tobacco companies, the quality of which directly affects the economic benefits of enterprises. It is especially important to control the moisture of the tobacco leaves during storage fermentation. Because the tobacco leaves are very hygroscopic, it is easy to cause large areas of insects, discoloration and even mildew. Tobacco leaves need to be stored for a long time, possibly about two years. The monitoring of moisture in tobacco leaves during this period directly affects the quality of the product. Traditional moisture measurement methods such as resistance method, microwave method, infrared method, etc. all require large power consumption. Besides, manual sampling is required, and the measurement accuracy is low, which is inconvenient. Some existing wireless communication technologies, such as ZigBee is easy to lose data [1]. Meanwhile, its signal is unstable and it cannot work for a long time. To solve these problems, we have designed the moisture monitoring equipment by capacitance method in this paper, and gives the NB-IoT data transmission scheme. Our equipment is battery-powered, easy to install, and accurate in measurement. Also, it is convenient for periodically observing the moisture content of the warehouse products.

Overall design of moisture monitor
The moisture monitor mainly consists of three parts: measurement, control and communication. The architecture of the overall solution is shown in Fig.1 Figure 1. Overall scheme architecture diagram The measuring circuit adopts the capacitance method to complete the circuit design. When the moisture content of the tobacco leaves changes, the capacitance value of the sensor changes correspondingly. Then the C/V circuit converts the change of the capacitance value into an electrical signal. The control section is responsible for sampling the voltage signal of the sensor, completing the conversion and optimization of the moisture data, and controlling the overall system power consumption. The communication part circuit is mainly an NB-IoT module circuit, which is responsible for transparently transmitting data between the controller and the base station.

Measurement system hardware design.
I have experience in the design and use of resistive moisture measuring equipment for some time. For the resistance measuring instrument, the mechanical pressure of the tobacco bundle bundling must be consistent during the test. That is, the tightness of the wrap of the tobacco leaves to the plunger should be the same, leading to high sampling requirement. In addition, the resistance method has poor antiinterference ability, small signal strength, and is very difficult to handle. These disadvantages can be better overcame by the capacitive method. Combined with NB-IoT's stable data upload, real-time monitoring of the moisture content of the warehouse's tobacco packs can be ensured.

Sensor circuit design.
As shown in Fig. 2(a), the two cylindrical electrodes are composed of a stainless steel tube tapered end and a tube body, separated by a high insulating material. An alternating electric field is established between the two electrodes by a constant excitation source. Meanwhile, a temperature sensor is placed at the right end of the insulating material, and the measured tobacco packet temperature data is used to correct the moisture linearity. Figure 2(b) shows the basic operation of the moisture measurement of the tobacco pack. The measuring rod is inserted into the tobacco packet, and the actual moisture content of the tobacco packet is calculated from the measured moisture and temperature data.
The capacitance of the sensor part of the moisture meter is proportional to the dielectric constant between the two cylindrical electrodes. The dielectric constants of the different measured objects are not equal. The dielectric constants of the same substance are not equal. For example, in the dry state, the dielectric constants of tobacco is 2 to 5. However, the dielectric constant of pure water is very high, reaching 80 or more. The data curve of the moisture meter equipment is based on strict calibration, and the moisture content ratio is correlated with the electrical signal to realize the conversion of the moisture to voltage signal. The signal conditioning circuit mainly uses the NAND gate CD4011 and the crystal oscillator. Since the chip adopts the CMOS process, the power consumption is very low. Because the 2M quartz crystal oscillator is connected in series, the sampling signal waveform is stable and reliable. After the C/V conversion, the output sampling voltage signal is directly sent to the single-chip microcomputer for A/D conversion. The corresponding relationship between the moisture content of the tobacco leaves and the output voltage is shown in Fig. 3(a).
The control circuit mainly completes the collection, processing and uploading of moisture data. Its core controller uses ST's STM32L151 as the main controller. Considering the system power consumption, we have chosen the L series low power chip STM32L151. The STM32L151 can work from a frequency of 32 KHz to 32 MHz with a supply voltage of 1.65 V to 3.6 V[2]. The operating frequency of moisture monitor system is set to 8MHz, and is about 5mA before entering the STOP mode the power consumption. After entering the STOP mode, the power consumption drops below 10μA. The STM32 internal 12-bit ADC is used to collect the converted voltage signal of the sensor, and compensate the original data based on the tobacco packet temperature data. Finally, the USART of STM32 is used to control the communication module to complete the data upload.

Communication Scheme.
This paper mainly considers the amount of data and the stability of data transmission in the design of IoT solution. The narrow-band IoT device, i.e. the NB-IoT device, is a kind of IoT device with weak mobility and small data volume. NB-IoT consumes only about 180 KHz of bandwidth [3]. Although its bandwidth is small and it is not sensitive to delay, it is stable for small data transmission and can be used in an environment where the signal is weak and the device is relatively large [4]. The equipment designed in this paper is deployed in hundreds of tobacco warehouses, each of which are with hundreds of tobacco packages. Thus, hundreds of devices need to be deployed for data monitoring. The data collection interval is 8 hours, and the data is processed and evaluated after being uploaded to the server. Figure 3(b) is a circuit diagram depicting a simple application circuit for the M5310 (the NB-IoT module used in this design).
From the power point of view, the moisture meter uses M5310 to reduce energy consumption. Because the internal HiSi Hi2110 supports China Mobile's network Band 8, which can work between 3.1V and 4.2V. Its maximum instantaneous current peak is less than 0.5A, and the power consumption is less than 5μA in PSM mode.

Measurement system software design
In order to match the low-power design on the hardware, the software also needs to cooperate with the hardware to better meet the expected power requirements. First, the overall operating frequency of the system is reduced from the basic 32 MHz to 8 MHz, and the corresponding current is 2.15mA. The current of the sensor itself is about 3mA after power-on, and the overall power consumption is 5mA. In order to make the equipment work longer, the sensor part is controlled by the switching power supply. When the moisture data needs to be measured, the single-chip microcomputer turns on the power supply for the sensor. When the data is measured, the power supply of the sensor is disconnected, and then the system itself enters STOP mode. The communication module also goes to sleep. System power consumption is reduced to a minimum in this situation, and battery life can be stabilized for two years. The software design process is shown in Fig. 4(a).
The sensor converts the current into a voltage through an analog circuit. The MCU is responsible for collecting the voltage signal with the ADC. The sampling data is unstable when the system is initialized. We need to wait for a while before reading correct moisture data. Experiments show that the suitable delay time is about 20S. The specific data collection process is shown in Figure 4(b). In order to ensure the reliability of the data, 10 sets of data are collected each time, including moisture data and temperature data. After the maximum and minimum values are removed, the remaining data is averaged to obtain the moisture data and temperature data of the tobacco packet at a certain time. According to the linear relationship between moisture and temperature of tobacco leaves, the final moisture content of tobacco leaves was calculated.
After calculating the moisture data of the tobacco packet, data is uploaded through the NB-IoT module. Before configuring the module, use the reset pin to restart the module, let the internal program of the module initialize first, and wait until the module returns to OK, read the CIMI number of the SIM, and confirm that the SIM card is plugged in and can be used. Because each device is independent for the server, in order to distinguish different devices, each device has an ID number, and the CIMI card number of each SIM card is unique, so the CIMI number can be used as the ID number [5]. The process is shown in Figure 4(c).

Experimental results error analysis and network upload
The moisture content of tobacco leaves measured by the drying method is the most accurate. As mentioned above, the moisture meter equipment in this design is based on strict calibration. After calibration and temperature compensation, the results of moisture measurement and drying method are shown in Table 1. The measurement error is stable within 0.2%. This equipment can accurately measure the moisture of tobacco packets. After the moisture data received by the server is exported to the EXCEL form, it is displayed as follows. COLLECT_TIME is the time when the server receives the first UDP data, and IMPORT_TIME is the time when the server receives the second UDP data. COLLECT_TIME can be regarded as the measured time. It can be known from calculation that the two receiving intervals are basically within 2S, which means that with the NB-IoT network, its delay is basically around 1S, and one round trip requires 2s. Table 2. Moisture data exported from the server. 2019-10-17 08:10:10 2019-10-17 08:10:12 Through the two sets of table data, the accuracy of the measurement and the reliability of remote monitoring of the data can be ensured. In the current Internet of Things environment, NB-IoT is undoubtedly a big craze. The intelligence of agriculture is also one of the focuses of development.

Conclusion
The moisture monitoring system described in this paper not only achieves accurate measurement of data and low power consumption, but also miniaturizes the device. Moreover, the system combines the Internet of Things with agricultural production. The intelligentization of traditional industries reflects the development of science and technology. Given that traditional equipment is inefficient and inconvenient to use, this paper gives an improved design.