Intelligent Fishpond Monitoring System Based on STM32 and Zigbsee

The study is designed to monitor the temperature and dissolved oxygen content in the fishpond, especially to ensure that dissolved oxygen content in the fishpond is enough for aquaculture. This fishpond monitoring system is designed based on stm32 and Zigbee wireless transmission technology. This study uses Zigbee to build up a sensor network to monitor multi fishponds. Data acquisition unit consist of temperature sensor and dissolved oxygen sensor. The sensor data is transfered from the data acquisition unit to the stm32 master controller. These data can be used to generate a control strategy, which can control the oxygen-enriching machine to produce enough oxygen for aquaculture in the most optimized way. The data transformation between master controller and data acquisition is through Zigbee protocol radio communication, which is a reliable means to transfer data. Experiments results show that this fishpond monitoring system can achieve remoting monitoring and control dissolved oxygen content in an effective way. By controlling the dissolved oxygen in the fishpond, the system can increase the production of the aquaculture and decrease the breeding cost.


INTRODUCTION
The fish is sensitive to the dissolved oxygen content in the water.Only when dissolved oxygen content reaches a certain value, fishpond can provide enough dissolved oxygen for fish to maintain vital activities.Growth rate and feed conversion ratio of fish will increase when dissolved oxygen content increases within limits.Low oxygen content is unfavorable for fish's survival.
Conventional way to determine whether fish lack of oxygen is observing fish hypoxia directly.This way is not particularly economical because it relies on experience and spends lots of effort.And it's unscientific because human can't always make the right decision just based on experience.Automation aquiculture is a new development direction of aqua cultural industry.Automation techniques can increase aquaculture production and reduce the cost of breeding.When dissolved oxygen is less than 1mg/L, fish hypoxia will happen in the fishpond.And when dissolved oxygen is less than 0.5mg/L, fish will die.So it's necessary to monitor fishpond environment (Pan et al., 2010).
The main topic of this study is to design a monitoring system to auto control the dissolved oxygen content in the fishpond.Zhao et al. (2015) designed a DO monitoring circuit by using G80F927 single computer and the system he designed was tested by field experiment.Jia et al. (2014) used GPRS technology and HT46RU232 controller to design a water quality monitoring system.Zhou and Wang (2015) designed a water quality monitoring system based on GIS.Zhang et al. (2013) and Li et al. (2009) used RF technology to transmit sensor data.Li et al. (2010) and Ren et al. (2011) designed an aquiculture detection system based on micro controller.Liu (2014) used GSM technology to realize the remote control of oxygen-enriching machine.This study designs a fishpond monitoring system based on Zigbee sensor network.The NRF905 is a kind of low-power RF module.It can be used for wireless transmission.But it doesn't has a transport protocol, which means it's difficult to use it to build up a high-performance sensor network.Zigbee has a high-performance transport protocol, called "Zstack".This protocol and Zigbee hardware module make Zigbee become an advanced transmission system.Last but not least, Zigbee transmission system can add sensor nodes easily, which means the system can monitor one or more fishponds by just using one master controller.Intelligent fishpond monitoring system possesses functions as follows: Temperature and dissolved oxygen measurement: Sensor module consists of DO-18 and DS18B20.DO-18 is Electrolytic dissolved oxygen electrode sensor.The electric currents it generated are related to dissolve oxygen content in the fishpond.To ensure sensor signal is large enough for controller to detect, this study designs a current amplification circuit to amplify sensor signal.DS18B20 is digital temperature sensor.Dissolved oxygen automatic control: All control strategies will be make in master controller according to sensor data.Then stm32 sends command to oxygenenriching machine via Zigbee.The strategies it makes will make sure there is enough dissolved oxygen available for aquaculture.

Dissolved oxygen alarm:
The monitoring system has sound and light warning function.Warning value of dissolved oxygen and temperature can be set according to practical needs.It can alert staff to an emergent problem before bigger problems coming.

LCD display:
The LCD display can show temperature and dissolved oxygen data transmitted from different fishponds.And also it will display the working state of the oxygen-enriching machine.All the historical sensor will be store in ROM for convenient search and analysis.

MATERIALS AND METHODS
Hardware overall designed: This study designs an intelligent fishpond monitoring system.The system hardware design contains the following modules: stm32 minimum system, cc2530 minimum system, temperature sensor module, dissolved oxygen sensor module, oxygen-enriching machine driver, LCD display module.
In Fig. 1, STM32F103ZET6 is used as master controller in this monitoring system.The stm32 controller receives sensor data from the sensor module via Zigbee wireless transmission.And all the sensor data will be displayed in LCD12864.There are two key components in this design.One is to build up a reliable wireless transmission system.The other is the control strategy of oxygen-enriching machine.Transmission system is based on cc2530 minimum system and Zstack protocol.Control strategy is belonging to the software design part.The controller will make the strategy according to the fishpond temperature sensor data, dissolved oxygen saturation and the actual dissolved oxygen sensor data.Then the controller will send command to oxygen-enriching machine and control the warning module.

The stm32 minimum system:
In Fig. 2, JTAG interface is a necessary part to debug and download code.The power supply to the stm32 is 3.3v.To guarantee system's stabilization, this study puts several 0.01uf capacitances between the power and the ground to reject the clutter from the power.OCS8 and OCS32 are crystals circuit for stm32.Figure 3 is the reset circuit for user to reset the whole system.This design uses STM32F103ZET6 as master controller, which is based on 32bit ARM Cortex™-M3 processor.Its design provides for high-performance and low power consumption.

The cc2530 minimum system:
The CC2530 is a true System-on-Chip (SoC) solution for IEEE 802.15.4,Zigbee and RF4CE applications.Combined with the industry-leading and golden-unit-status ZigBee protocol stack from Texas Instruments, the CC2530F256 provides a robust and complete ZigBee solution.In Fig. 4, to build wireless sensor nodes, this study designs a cc2530 minimum system.There are three kinds of device in Zigbee network: Coordinator, Router and End-device.Coordinator is responsible for startup and configuration of the whole Zigbee network.After the   Temperature sensor module: Water temperature affects not only the dissolved oxygen in the water, but also fish breeding.Fish are poikilothermic animals whose body temperature changes as the ambient water temperature changes.The change of the temperature may cause the death or illness of the fish.The temperature suitable for fish to live is between 12~30°C.Temperature in Northeast China is relative low compared with that in other places.So the fish living there grows slower.Temperature is an important factor of dissolved oxygen in the water.In order to make a good control strategy, we should study about the relation between temperature and dissolved oxygen saturation.In Table 1, the higher the temperature, the less oxygen is dissolved in water.When the temperature reaches 30°C, the dissolved oxygen in the pure water is only 7.56mg/L.For intensive fishponds, this situation is unfavorable for fish to live and the fish population will decrease.Therefore it's necessary to detect temperature in the fishpond.This study chooses DS18B20 as temperature sensor.Its internal structure is shown in Fig. 6. Figure 7 is the interface circuit for DS18B20.Pin DQ on DS18B20 is connected to Pin1.6 on cc2530.Then cc2530 can read temperature data via Pin1.6.
Dissolved oxygen sensor module: Dissolved oxygen is an important condition for aquatic organisms to live on.Low dissolved oxygen can cause the death of the fish.There are two sources of dissolved oxygen: Oxygen in the air and oxygen generated by algal photosynthesis.Therefore it's necessary to detect dissolved oxygen in the fishpond.This study uses DO-18 to detect dissolved oxygen.DO-18 is electrolytic dissolved oxygen electrode sensor.Its specific parameters can be found in DO-18 datasheet.For Do-18, the current response of the electrode is proportional to dissolved oxygen in the medium.Electrode response formula is showed as follow: where, I : Electrode stable response current.To change current to voltage, we parallel connect a large resistance R6 in the output port.But output voltage signal is too weak to measure.Its output range is from 1mv to 100mv.Therefore we need to amplify the output signal.This design uses amplifier AD623 to make the signal become large enough to measure.To reject the clutter from the power, we parallel connect several capacitances to DO-18.The gain of AD623 can be calculated through formula provided by AD623 datasheet: 100 ( 1) where, V o : The output voltage of amplifier.
where, G = The gain of the amplifier.This study setsGat 21.
Then R G can be calculated: After amplification, the maximum value of output voltage is 2.1v.It's large enough for Zigbee to measure.This module uses on-module ADC to measure the output voltage of AD623.

Oxygen-enriching machine driver:
To remote control oxygen-enriching machine, we need to design a drive circuit.To use small current to control highpowered machine, Liu (2014) uses single-phase ac solid state relay to implement the design.This design uses the same method as Liu did in this module.Figure 9 is drive circuit for relay.Pin1.7 isthe output pin of cc2530.When the pin outputs the low level, triode Q1 will be trigged into the on-state and oxygen-enriching machine will be started.When the pin outputs the high level, triode Q1 will be trigged into the off-state and oxygen-enriching machine will be turned off.
Software design: Figure 10 is the program flow chart for stm32.The stm32 receives sensor data from Zigbeevia serial port.When the data is received, stm32 begins to process data.At first, it determines whether the temperature is over 30°C.When the temperature is over 30°C, it is unfavorable for fish to live and dissolved oxygen is very low.So stm32 will send command to start the oxygen-enriching machine and start alarm.When thetemperature is under 30°C, it will compare the actual dissolved oxygen sensor data with Limit.Limit value can be set by user according to practical situation.If actual value is less than Limit.Then stm32 will send command to start the oxygenenriching machine and start alarm.
Figure 11 is the program flow chart for Zigbee.Its hardware layer is based on cc2530.Cc2530 has integration of enhanced 51 core.The program running in cc2530 is based on Zstack protocol.Zstack has already implemented physical layer and mac layer for wireless communication.And Zstack uses polling tasks as task scheduling method.That means Zstack is also a multitask system and the program can be multi process.This is why Fig. 11 is multitask program flow chart.Zstack is an event-driven system, mainly in data transmission and the coordination of the exchange.But reading sensor data is initiative trigger.DS18B20 is digital temperature sensor and its temperature data can be read directly by cc2530.Reading digital temperature data is bit-by-bit transmission.Every data requires 8 bits.To ensure data transmission is under right operation timing, cc2530 processor's frequency is 32MHz.
To get dissolved oxygen data, this design uses ADC to sample the voltage from dissolved oxygen module.The cc2530 has multichannel ADC.This module uses 3.3v voltage as its external reference voltage.
It has 12 bits data resolution and usescomplementary code to record sample value.That means its sample range is . This designuses pin0.0 on cc2530 tosample voltage and set ADC mode to 12 bits data resolution.So the formula to convert sample value to voltage is showed as follow:

RESULTS AND DISCUSSION
The intelligent fishpond monitoring system is tested in a small fishpond in Zhuhai on June 3 th , 2015.In Table 2 and 3, these are test results of the monitoring system.
There are three sensor node in different place near the fishpond.All of them can measure temperature and dissolved oxygen content and send sensor data to controller via Zigbee.In Table 2, the system has obtained temperature data and dissolved oxygen data successful.And the Zigbee wireless network also works well.Then stm32 gets all sensor data and shows them on LCD12864.The time and temperature changes and dissolved oxygen changes with them.Dissolved oxygen peaks at 14:00.This is because of the oxygen generated by algal photosynthesis.Sunlight enhances photosynthesis rate.This study sets the limit dissolved oxygen to 2.5mg/L.Because the system is tested in the daytime, photosynthesis is strong enough to generate a lot of oxygen and oxygen-enriching machine state is always off.This situation can test sensor network.But it can't test control strategy.So we test the system in low dissolved oxygen water.In Table 3, when dissolved oxygen is less than 2.5 mg/L, oxygen-enriching machine will start and alarm module start to alarm.So the system control strategy can also run successful.To test difference of communication, we test the system in 20, 50 and 70m.All the sensor data is showed in the LCD12864 successfully and the sensor data is also correct.So the system works well in all of these situations.All the sensor data from the fishpond is transferred successfully.
The result shows that this design is feasible.All sensor data from different position around the fishpond can be received successfully.Because of the Z-stack communication protocol, the communication of this design is reliable comparing with the design based NRF (Zhang et al., 2013;Li et al., 2009).The reliable communication distance of Zigbee is within about 1km (Niu et al., 2013).And this design can add sensor node easily by design a hardware circuit and program according to Fig. 4 and 11.So this design also has better communication distance and better extensibility comparing with the design based on NRF.

CONCLUSION
This design is based on Zigbee and stm32.This design uses Zigbee to build up a fishpond sensor network.This monitoring system can monitor multi fishponds in the same time by just using one master controller and all sensor data can be transmitted to master controller in wireless way.And because dissolved oxygen is so important for fish and dissolved oxygen is related to many factors.When dissolved oxygen is not enough for fish to live, it will reduce the production of aquatic product.If people turn on oxygen-enriching machine all the day, it will cost a lot of power.Therefore this design can auto control oxygen-enriching remotely according to dissolved oxygen sensor data.It is contributive to increase of aquatic production and decrease the breeding cost.

Fig. 1 :
Fig.1: Hardware overall designed Sensor data wireless transmission: This study establishes a wireless sensor network based on Zigbee transmission system.All the Dissolved oxygen sensor data and temperature sensor data from different fishpond will be transmitted to master controlled stm32.The sensor network can monitor multi fishponds in the same time.

Fig. 5 :
Fig. 5: The topology of sensor networkdevice should be always active.End-device is directly connected with sensor and it is responsible for acquiring data.The topology of fishpond monitoring system network is shown in Fig.5.To monitor multi fishponds, all End-device should be put near different fishponds.End-device will read data from the temperature sensor and dissolved oxygen sensor.And it will send all of these data to the router.The router device will rout these data packages to master controller stm32.Therefore this design can just use one controller to monitor all the fishponds.

2 op
: Oxygen partial pressure of the medium.T: Thetemperature of the oxygen permeable membrane.a,A: Two constants related to electrode material and electrode structure.

Table 1 :
Pure water dissolved oxygen saturation in different temperatures

Table 2 :
Test of monitoring system in Zhuhai on June 3 th , 2015