Hydroponic system design with real time OS based on ARM Cortex-M microcontroller

Hydroponic is the process of growing plants without soil, plant root flooded or moist with nutrient-rich solutions in inert material. Hydroponics has become a reality for greenhouse growers in virtually all climates. Large hydroponic installations exist throughout the world for growing flowers, vegetables and some short period fruit like tomato and cucumber. In soilless culture, we must maintain stable pH and conductivity level of nutrient solution to make plant grow well, large variation of pH of certain time will poisoned plant. This paper describes development complete automation hydroponic system, from maintaining stable nutrient composition (conductivity and pH), grow light, and monitor plant environment such as CO2, temperature and humidity. The heart of our automation is ARM Cortex-M4 from ST Microelectronic running ARM mbed OS, the official Real Time Operating System (RTOS) for ARM Cortex-M microcontroller. Using RTOS gives us flexibility to have multithreaded process. Results show that system capable to control desired concentration level with variation of less than 3%, pH sensor show good accuracy 5.83% from pH value 3.23-10. Growing light intensity measurement show result 105 μmol/m2/s therefore we need turn on the light at least 17 hours/day to fulfil plant light requirement. RTOS give good performance with latency and jitter less than 15 us, system overall show good performance and accuracy for automating hydroponic plant in vegetative phase of growth.


Introduction
Healthy life by eating vegetables that are fresh and free of pesticides is everyone's dream. Vegetables are healthy for consumption must come from plants that are not contaminated by chemicals and microorganisms that are harmful to the body, such as pesticides, ova, and so forth. In Daily life, it cannot be denied that the vegetables consumed are not free from harmful chemicals such as pesticides. Data from Nishtar Hospital, Multan Pakistan during the years 1996-2000 there were 578 [1] patients poisoned, including 370 patients from pesticide poisoning (54 people died). In general, pesticide poisoning victims are farmers or agricultural workers, 81% of which are aged 14-30 years [1]. Besides, planting in a conventional that using land also has some deficiency. The first, soil is the origin of most types of pests and diseases. Second, the difference soul varies in each area so need to find land suitable for farming. Third, the area of soil required is directly proportional to the amount of vegetables that can be generated. Fourth, the use of fertilizers and water are less efficient. The weaknesses are the basis for the development of hydroponic farming method [2].

Hydroponic and related works
Hydroponics has five advantages. First, eliminate pests, fungi, and other diseases that come from the soil. Second, eliminate weeds so no need for herbicides. Third, reduce health risks and expenses in the handling and maintenance of soil pests. Fourth, reducing the time required for replanting because it is not necessary ground preparation. Fifth, increase yields and shorten the time of harvest [2].
Automated system to deliver nutrient on time basis in recirculating hydroponic show grow rate 40-50% faster than soil [3]. Controlling conductivity of nutrient solution according to plant needs can boost plant growth and productivity using ARM processor [4]. Conductivity Meter used in the system as an electrode. The amount of nutrients that plants need manually calculated and stored value in the processor. Conductivity Meter will compare the value of the amount of nutrients in plants by the amount of nutrients that have been calculated manually on the processor, if it is less than required, the pump will turn on automatically nutrients to get the right nutritional value. Better result achieves by controlling conductivity and pH of nutrient solution [5], pH plays important role for plant to absorb all elements.
Plant need light source for photosynthesis, the light requirement for plant measure in Daily Light Integral [6]. Plants have different responses when given the light sources of different LED colors, this can effect to plant growth and productivity [7]. Plant can response to difference light spectrum [8], we can make special recipe of light for specific plant [9].
To build completed growing chamber for plant, we need to control nutrient solution, light requirement, and climate. MIT MediaLab launch OpenAg initiative to build Food Computer, Tree Computer and Food Server for growing plant, with this food computer, we able to grow any plant by download the grow recipe in anywhere [10].
In this research, we build automation system for hydroponic that can regulate and maintain conductivity and pH of nutrient solution, controlling growing light according to plant DLI and monitor continuously environment variable such as temperature, humidity, CO 2 level, also pH and conductivity of nutrient solution. To build such system that can run several processes concurrently we use Real Time OS [11]. For ARM microcontroller there are many RTOS available, as freeware and licensed, in this research we use mbed OS, an opensource Real Time OS for ARM microcontroller.

Experimental Setup
The system can perform automatic watering based timer in accordance with existing selection, capable of compounding levels of nutrients according to the levels desired, the system can read the levels of pH and nutrients on the nutrient content of hydroponics, the system can read temperature, humidity, CO2 levels and the intensity of the light in around the system, there are also three lines growing LED light with a different configuration on each line that is used for the lighting of plants, color of the light can be selected and the configuration of the system can be saved in SD Card. Figure 1 is a block diagram of the main system.

Fig.1 Main System Block Diagram
When the system is turned on, first the program will turn off the stir pump, water pump, and the dosing pump. After that the program will initialize LCD Module, then initialize serial and serial to PC for CO2 sensor. The program will read the system configuration data that stored in the SD Card and initialize global variables with the configuration. Then the program will update the LCD display. The program will begin running 6 pieces of thread, the sensor thread to read data sensors, Push Button thread to read the buttons provided, Mixing thread to perform compounding nutrients hydroponics, Timer Flush thread to set watering plants, Timer lights thread to regulate time lighting plants by LED lights and LCD Update thread to set the LCD display on the renewal of certain menu selected. The program then starts the timer as a clock generator for minimum water sensor to detect the presence of water in the container nutrients nutrition. The program will check if the watering timer from previously activated or not. If activated then timer will start watering plants according to the configuration of the time used before.  The pH sensor experiment performed by recording the initial pH value in the solution, then adding the pH solution Up 5 mL into the solution and comparing the pH sensor results with the measuring instrument. DHT22 Humidity sensor experiment taken for 600 seconds with data taking every 30 seconds in physics rooms, results will be compared with the measuring instrument. MH-Z19 sensor experiment taken for 25 minutes with data taking every 1 minute in rooms, results will be compared with measuring instruments,

Compounding Nutrients Experiment
The system will initially provide nutrients for 5 mL, and then the system recorded an increase of nutrients that happen to calculated the amount of giving nutrients needed to achieve the target.

Daily Light Integral Experiment
Data collection is using Quantum PAR Meter measuring instrument at 30 cm distance from LED to plant hole. The LED Coefficient can be obtained by dividing Average Light Intensity with Lux. By getting the coefficient of LED, then the Average Light Intensity can be obtained and can be used to find Daily Light integral (DLI). After getting amount of Average light intensity then use the DLI formula for 17 hours

RTOS Experiment
RTOS performance test we measure jitter and latency using square wave input and measure input signal versus output signal delay using oscilloscope [12] as show in

Experimental Result and Discussion
The following Figure 4 is the results of pH meter sensor experiment, the difference obtained is so small so that the pH meter sensor in this experiment can be used to read the pH. The following Figure 5 below is the results humidity data retrieval between DHT22 sensors and measuring devices at Physics Room. The difference obtained is so small.

Fig.5 Graph of humidity data results
The following Figure 6 below is the results CO 2 data retrieval between MH-Z19 sensor and measuring devices at Physics Room. The value of the difference for each room has a relatively equal amount, then for the sensor MH-Z19 in this case will using a correction factor, so the results obtained close to the results of measuring instruments. The correction factor that used for the MH-Z19 sensor is 260 ppm against the initial value.  Table 1 below is the result of the compounding of nutrients that had been done. Table 1 Compounding Nutrient Table   Experiment Early Nutrition  Graph of results CO 2 data retrieval between MH-Z19 sensors and measuring devices (Physics Room)

Conclusion
From the results, it showed that hydroponic automated system performed. RTOS give latency less than 15 µS, more than enough to run all the tasks. Environment sensor overall show good result, temperature reading error less than 4%, humidity reading less than 5.36%, and CO 2 sensor accuracy need to calibrate 260 ppm from initial value. System capable to mix nutrient in 80 sec with error less than 3.48%. Growing light intensity measurement show different result for different color spectrum, to fulfill daily light plant requirement we need to turn on the light at least 17 hours/day. Our growing test show vegetable can grow well and we harvest in 5 weeks. System need to improve in pH sensor stability, currently pH sensor need 10 minutes to stabilize data sensor reading.