Development and Implementation of Low-Cost, Real-Time Soil Moisture Monitoring System: Optimizing Pineapple Water Management, A Case Study
Tikhon S. Kozlov*
Urbana High School, 3471 Campus Dr, Ijamsville, MD 21754, USA
*Corresponding Author: Tikhon S. Kozlov, Urbana High School, 3471 Campus Dr, Ijamsville, MD 21754, USA.
Received: 17 February 2025; Accepted: 21 February 2025; Published: 25 March 2025
Article Information
Citation:
Tikhon S. Kozlov. Development and Implementation of Low-Cost, Real-Time Soil Moisture Monitoring System: Optimizing Pineapple Water Management, A Case Study. International Journal of Plant, Animal and Environmental Sciences. 15 (2024): 20-26.
View / Download Pdf Share at FacebookAbstract
The green tops of pineapple fruits create a concerning amount of waste. To reduce this waste, the green tops can be recycled by growing indoor pineapple plants and donating fresh fruits to underserved communities. However, growing pineapple plants indoors is not trivial due to the plant’s sensitivity to the amount of water in the soil. To overcome this barrier, this study developed a new device – Ananas Moisture Assessment Tool or AMAT for short – calibrated under pristine conditions (absorbent paper containing a known volume of water) and controlled conditions (soil samples with known moisture levels). Five LED lights representing different moisture levels communicated these conditions to the user. Furthermore, blind testing of this device demonstrated reproducible performance. Finally, a 3D printer was used to create a protective case for indoor use for the finished device. The AMAT is expected to solve three problems: 1) pineapple waste reduction, 2) freshwater conservation, and 3) maintaining optimal soil moisture for pineapple plants grown indoors. In the long run, this device can be adapted for other plants and larger-scale use, such as that used by farmers.
Keywords
Tikhon S. Kozlov. Development and Implementation of Low-Cost, Real-Time Soil Moisture Monitoring System: Optimizing Pineapple Water Management, A Case Study. International Journal of Plant, Animal and Environmental Sciences. 15 (2024): 20-26.
Embedded systems articles; Circuits articles; Plant sciences articles; Agriculture and agronomy articles
Article Details
1. Introduction
Pineapples are perennial plants growing along coastlines in tropical areas. While native to South America and the Caribbean, pineapples can be grown naturally in tropical Asia. According to USA Today, Costa Rica, Indonesia and the Philippines were the leading producers of pineapples in 2021 [1]. The global pineapple market is expected to earn 36.80 billion USD by 2028 [2]. Pineapple fruits are popular treats in the US. However, their thick green tops create concerning amounts of waste that are hard to recycle. A recent study shows 20,000–25,000 tons of pineapple leaves are left per acre after harvesting [3]. Various efforts have been undertaken to reduce pineapple waste by using green tops to remove toxic contaminants from water and to produce bags and other consumer products [4].
To reduce waste and alleviate hunger in Maryland, where pineapples struggle to grow outdoors, I planted the green tops to grow indoor plants and produce fruits for children in underprivileged areas. Growing pineapples indoors, however, is not a trivial task because these plants are sensitive to the amount of water in the soil. A device continuously monitoring the water concentration within the soil would help overcome this challenge. This device would measure the water concentration within the soil with minimal human intervention.
When the soil becomes too dry, the Ananas Moisture Assessment Tool (AMAT) activates light, signaling the user that a pineapple plant needs to be watered. Due to its simple design, the AMAT can be adjusted to other plants by recalibrating the sensitivity using the Arduino IDE software. Eventually, it can be customized for use in farms to assist farmers in watering plants when the amount of water in the soil is not optimal. The collateral benefit of using such a sensor is the conservation of freshwater because watering will occur only when the soil the plants grow in is underwatered. It is expected that using such sensors will help to reduce the use of fresh water for agriculture while supporting plant health.
Therefore, this research project aimed to design such a device, calibrate it using soil samples with various water concentrations, and test it in a real environment with pineapple plants.
2. Methods
The AMAT is composed of the following components:
- • SparkFun soil moisture sensor
- • 400 tie-point solderless breadboard
- • ELEGOO UNO R3 microcontroller
- • ELEGOO Power supply module
- • 9V battery holder + alkaline 9V battery
2.1 Research Questions:
- Can a soil moisture sensor, a breadboard, and a microcontroller be combined to create a stand-alone device for sensing soil moisture concentration?
- Can the said device distinguish between extreme conditions – excess water and dehydration?
- Can the sensor distinguish between intermediate conditions of varying humidity levels between excess water and dehydration?
- Is the performance of this device reproducible under pristine conditions (using a clean environment)?
- Are the calibration curve and performance of this revised reproducible in soil (using soil samples with various humidity levels)?
2.1 Engineering Goals:
- Using a soil moisture sensor, a breadboard, and a microcontroller, create a device for indoor use.
- Using the Arduino IDE software, prepare a code to support the operation of the
- Test the device under pristine and controlled conditions using soil
- Using a 3D printer, create an external body of the device to complete the finished
- Test and validate the effectiveness of the finished product in a natural
3. Materials
SparkFun soil moisture sensor, 400 tie-point solderless breadboard, LED lights, the power supply module that came with the breadboard, ELEGOO UNO R3 microcontroller, absorbent paper, 1 mL pipette tips, and ELEGOO UNO R3 microcontroller, absorbent paper, 1 mL pipette tips, and P-1000 Gilson pipette were purchased on Amazon. The soil was from Home Depot. The plastic cups were from Giant. House tap water was used for calibration.
4. Results and Discussion
4.1 Assembly and design of the device
The device was created by assembling three main components - SparkFun soil moisture sensor, 400 tie-point solderless breadboard, and ELEGOO UNO R3 microcontroller. Five LED lights of different colors – blue, green, white, yellow, and red – were positioned on the breadboard regularly from left to right. The LED anodes were connected to the microcontroller through different terminals: blue was connected to terminal 8, green – to terminal 9, white – to terminal 10, yellow – to terminal 11, and red – to terminal 12. The cathodes of the LEDs were connected to a central path with a 220 Ohms resistor that led to the microcontroller’s ground. The soil moisture sensor’s power terminal was connected to the microcontroller’s A0 terminal, the ground terminal of the sensor was connected to the microcontroller’s ground terminal, and the sensor’s signal terminal was connected to the microcontroller’s A1 terminal. The device was named the Ananas Moisture Assessment Tool (AMAT), which reflects its functionality and applicability to pineapples. The schematic design is shown in Figure 1A. The initial assembled device is shown in Figure 1B. The improved device containing an ON/OFF switch and a 9V battery holder is shown in Figure 1C. Finally, a 3D printer code was created to create a case for the device. Figures 1D and 1E show the final device enclosed in a 3D-printed case.

Figure 1: AMAT Device. (A) TinkerCAD design of the electrical components system. (B) AMAT comprises a SparkFun soil moisture sensor, a 400 tie-point solderless breadboard, and an ELEGOO microcontroller connected to the computer. (C) The AMAT is refined with an ON/OFF switch and a 9V battery holder. (D, E) The finished product, in which the AMAT from image C is enclosed in a 3D-printed case. These images show the step-by-step design and construction of the device from concept to the finished product.
4.2 Creation of computer code to operate the AMAT device
Next, a computer code was created using the Arduino IDE software to enable communication between the three main components. The code was adapted from a template from reference [5] and was as follows:
// C++ code
// Tikhon Kozlov - last updated 12/17/2023 int moisture = 0;
void setup()
{
pinMode(A0, OUTPUT); pinMode(A1, INPUT); Serial.begin(9600); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT);
}
void loop()
{
// Apply power to the soil moisture sensor digitalWrite(A0, HIGH);
delay(10); // Wait for 10 millisecond(s) moisture = analogRead(A1);
// Turn off the sensor to reduce metal corrosion
// over time digitalWrite(A0, LOW); Serial.println(moisture); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); if (moisture < 200) {
digitalWrite(12, HIGH);
} else {
if (moisture < 400) { digitalWrite(11, HIGH);
} else {
if (moisture < 600) { digitalWrite(10, HIGH);
} else {
if (moisture < 800) { digitalWrite(9, HIGH);
} else {
digitalWrite(8, HIGH);
}
}
}
}
delay(100); // Wait for 100 millisecond(s)
}
4.3 First iteration verification under pristine conditions
The proof-of-concept experiment involved two extreme conditions – excess water and dehydration. Two pieces of absorbent paper of identical size (3 cm × 3 cm × 0.5 cm) were prepared to create these conditions. One piece was kept dry, while the second was immersed in water. Upon contact of the dry piece with the moisture sensor, the sensor’s light was red. In contrast, the light turned blue when the sensor contacted a wet piece (Figure 2). Next, the device was calibrated using a series of conditions with different levels of hydration ranging from dehydrated to excess water. Thirteen (13) pieces of absorbent paper with identical sizes (3 cm × 3 cm × 0.5 cm) were prepared to create such conditions. The dehydrated sample was kept as is. The excess water sample was prepared by immersing a piece of absorbent paper in water. The intermediate samples were prepared by applying various volumes of water (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, and 1000 microliters (µL)) onto a piece of absorbent paper, one volume per piece. The paper then was allowed to absorb the water before measurements were taken. This calibration experiment was repeated three times, and the results are summarized in Figure 2 and Table 1. The dehydrated sample produced red light; the light in the excess water sample was blue. The light colors in other samples were as follows: 50 µL of water sample was yellow in all experiments (N=3); 100 µL – white in two experimental replicates and blinking between yellow and white in one replicate, suggesting that this water level is a borderline condition; 200 µL – white (N=3); 300, 400, 500 and 600 µL – all generated a green light (N=3 for each condition); 700 µL – blinking between green and blue (N=3); 800, 900 and 1000 µL – blue light (N=3 for each condition). These results are also summarized in Table 1.
Experimental Condition |
Experiment 1 |
Experiment 2 |
Experiment 3 |
Dehydrated |
RED |
RED |
RED |
50 µL |
YELLOW |
YELLOW |
YELLOW |
100 µL |
WHITE |
WHITE |
WHITE/YELLOW |
200 µL |
WHITE |
WHITE |
WHITE |
300 µL |
GREEN |
GREEN |
GREEN |
400 µL |
GREEN |
GREEN |
GREEN |
500 µL |
GREEN |
GREEN |
GREEN |
600 µL |
GREEN |
GREEN |
GREEN |
700 µL |
GREEN/BLUE |
GREEN/BLUE |
GREEN/BLUE |
800 µL |
BLUE |
BLUE |
BLUE |
900 µL |
BLUE |
BLUE |
BLUE |
1000 µL |
BLUE |
BLUE |
BLUE |
Dip-Coated |
BLUE |
BLUE |
BLUE |
Table 1: The first iteration of AMAT verification under pristine conditions. The AMAT’s light color changes upon contact with a water sample. This table summarizes the results, and representative images are shown in Figure 2. The data demonstrates that light color changes depending on the moisture level.

Figure 2: The first iteration of AMAT verification under pristine conditions. The AMAT was brought in contact with absorbent paper containing different water levels. Shown in row A from left to right are dehydrated samples, and samples containing 50 µL, 100 µL, and 200 µL of water, respectively. Shown in row B from left to right are samples containing 300 µL, 400 µL, 500 µL and 600 µL of water, respectively. Shown in row C from left to right are samples containing 800 µL, 900 µL, 1000 µL, and excess water, respectively. The sample containing 700 µL was skipped due to a change in reading from green to blue. Representative images are shown, and the results are summarized in Table 1. The images show that the light color changes depending on the moisture level.
4.4 Verification of the AMAT’s performance under pristine conditions
Five pieces of absorbent paper with known amounts of water falling within the range of the quantities used in the calibration experiment were prepared and blindly tested to verify the AMAT’s performance, to enable blind testing and reduce sampling bias, sample preparation and moisture measurements were performed by two people independent of each other. The sample maker and sample tester did not communicate with each other during the experiment and compared their notes after the experiment. The control samples were as follows: sample 1 – dehydrated; sample 2 – 1000 µL of water; sample 3 – 600 µL of water; sample 4 – 200 µL of water and sample 5 – 50 µL of water. The results demonstrated accurate recognition of the moisture in the test samples in that the light colors of the devices were red, blue, green, white, and yellow for samples 1, 2, 3, 4, and 5, respectively (Figure 3 and Table 2). The sensor required 1-5 seconds to equilibrate before the light color stabilized. It was also noted that accidentally touching the sensor with fingers could interfere with the recorded measurements and thus should be avoided.
Experimental Condition |
Experiment 1 |
Experiment 2 |
Experiment 3 |
Sample 1 |
RED |
RED |
RED |
Sample 2 |
BLUE |
BLUE |
BLUE |
Sample 3 |
GREEN |
GREEN |
GREEN |
Sample 4 |
WHITE |
WHITE |
WHITE |
Sample 5 |
YELLOW |
YELLOW |
YELLOW |
Table 2: AMAT’s verification under pristine condition. A blind test was performed to determine the AMAT’s output upon contact between the soil moisture sensor and a control sample containing a known amount as follows: sample 1 – dehydrated; sample 2 – 1000 µL of water; sample 3 – 600 µL of water; sample 4 – 200 µL of water; sample 5 – 50 µL of water. The images of samples summarized in this table are also presented in Figure 3. The data demonstrates that AMAT can accurately detect moisture levels under pristine conditions.

Figure 3: Verification of AMAT’s Functionality under pristine conditions. A blind test was performed to determine the AMAT’s output upon contact between the soil moisture sensor and a control sample containing a known amount of water as follows: sample 1 – dehydrated; sample 2 – 1000 µL of water; sample 3 – 600 µL of water; sample 4 – 200 µL of water; sample 5 – 50 µL of water. Representative images are shown. These results are also summarized in Table 2. The images demonstrate that AMAT can accurately detect moisture levels in the test samples under pristine conditions.
4.5 AMAT calibration under controlled conditions that mimic the natural environment of pineapples
The AMAT’s intended application is to measure soil moisture levels. Therefore, to understand the device’s performance and conduct necessary adjustments, several soil samples were prepared, including dry soil and soil samples containing various percentages of water: 20, 30, 40, 50, and 60%. The mass of each soil sample was 10 g. The formula for quantifying the moisture of a soil is (Mass of wet soil – Mass of dry soil)/Mass of wet soil) × 100. Therefore, the following formula was used to quantify the mass of water needed per 10g of soil to create a sample with a given percentage of moisture: Mass of water required per 10 g of soil = (X/Y) × 10, where X is the desired percentage of the soil moisture, Y is a value remaining at 100%. For example, to prepare a sample with 10% moisture, (0.1/0.9) × 10 = 1.1 grams of water were needed; for the sample with 20% moisture, (0.2/0.8) × 10 = 2.5 grams of water were required. The results are presented in Figure 4 and summarized in Table 3. The data demonstrated that the device can detect different levels of soil moisture. However, since the optimal soil moisture for pineapple is 60 % [6], the device code up until this moment appears to be suboptimal for indicating if the plant is overwatered.
Experimental Condition |
Experiment 1 |
Experiment 2 |
Experiment 3 |
Dry |
RED |
RED |
RED |
20% |
YELLOW |
YELLOW |
YELLOW |
30% |
GREEN |
GREEN |
GREEN |
40% |
GREEN |
GREEN |
GREEN |
50% |
BLUE |
BLUE |
BLUE |
60% |
BLUE |
BLUE |
BLUE |
Table 3: AMAT calibration under controlled conditions. The change in the device’s light color upon contact between the moisture sensor and a soil sample with the known moisture percentage. This table summarizes the results, and representative images are shown in Figure 4. The data demonstrates that light color changes depending on the soil moisture levels.

Figure 4: Calibration of AMAT under controlled conditions. Several soil samples were prepared and tested using the AMAT. Each measurement was repeated three times (N=3). (A) The soil samples with 20, 30, 40, 50, and 60 % moisture are shown left to right. (B) Shown left to right are representative images of the device’s light color after contact with samples shown in A. (C) Control sample of dry soil. The change in the device’s light color was recorded and summarized in Table 3. The images demonstrate that the light color changes depending on the moisture level in the soil sample.
4.6 Code Optimization
To optimize the device’s performance, the code was adjusted several times until the light’s color for the soil sample with 60% moisture became solid green. The code accepted for the final device is shown below and adapted from the following source [5]
// C++ code
// Tikhon Kozlov - last updated 1/1/2024 int moisture = 0;
void setup()
{
Serial.begin(9600);
pinMode(A0, OUTPUT); pinMode(A1, INPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT);
}
void loop()
{
// Apply power to the soil moisture sensor digitalWrite(A0, HIGH);
delay(10); // Wait for 10 millisecond(s) moisture = analogRead(A1); digitalWrite(A0, LOW);
digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); digitalWrite(12, LOW); if (moisture < 200) {
digitalWrite(12, HIGH);
} else {
if (moisture < 700) { digitalWrite(11, HIGH);
} else {
if (moisture < 830) { digitalWrite(10, HIGH);
} else {
if (moisture < 880) { digitalWrite(9, HIGH);
} else {
digitalWrite(8, HIGH);
}
}
}
}
delay(100); // Wait for 100 millisecond(s)
}
4.7 AMAT calibration under controlled conditions using soil samples after the code’s update
After adjusting the code to allow moisture detection above the optimal level, the experiments were repeated using soil samples containing 20, 30, 40, 50, 60, 70, and 80% water levels. The dry soil sample was used as a control. The results are summarized in Table 4, and representative images are shown in Figure 5. These results demonstrated that the device could detect both optimal (60-70 %) moisture levels and alert the farmer if the moisture is too low (≤ 50%) or too high (80%). At the moisture level of 70%, the light’s color in one replicate was blinking between green and blue. This result is unsurprising because 70% is at the borderline between the optimal and over-watered conditions.
Experimental Condition |
Experiment 1 |
Experiment 2 |
Experiment 3 |
Dry |
RED |
RED |
RED |
20% |
RED |
RED |
RED |
30% |
YELLOW |
YELLOW |
YELLOW |
40% |
YELLOW |
YELLOW |
YELLOW |
50% |
WHITE |
WHITE |
WHITE |
60% |
GREEN |
GREEN |
GREEN |
70% |
GREEN |
GREEN |
GREEN/BLUE |
80% |
BLUE |
BLUE |
BLUE |
Table 4: AMAT calibration under controlled conditions after the code’s adjustment. The device’s light color change was recorded upon contact between the moisture sensor and a calibration sample. Each measurement was repeated three times (N=3). Representative images of readings summarized in this table are presented in Figure 5. The data demonstrate that AMAT could detect both optimal (60-70 %) moisture levels and alert the farmer if the moisture is too low (≤ 50%) or too high (80%).

Figure 5: Calibration of AMAT under controlled conditions after code adjustment. Several soil samples were prepared and tested using the AMAT. Each measurement was repeated three times (N=3). The change in the device’s light color was recorded and summarized in Table 4. (A) Shown left to right are representative images of the dry soil sample and samples with 20%, 30%, and 40% moisture. (B) Shown left to right are representative images of samples containing 50%, 60%, 70%, and 80% moisture. The data demonstrate that AMAT could detect both optimal (60-70 %) moisture levels and alert the farmer if the moisture is too low (≤ 50%) or too high (80%).
4.8 Verification of the AMAT’s performance under controlled conditions after the code’s adjustment
Five soil samples with known moisture levels falling within the range used in the calibration experiment were prepared and blindly tested to verify the device’s performance under controlled conditions. To enable blind testing, sample preparation, and moisture measurements were performed by two people independent of each other. The sample maker and the sample tester did not communicate with each other during the experiment and compared their notes after the experiment. The control samples were as follows: sample 1 – 30%; sample 2 – 80%; sample 3 - 60%; sample 4 – 40%; sample 5 – 70%. The results demonstrated accurate recognition of the moisture in the test samples in that the light colors of the devices were yellow, blue, green, yellow, and green for samples 1, 2, 3, 4, and 5, respectively (Figure 6 and Table 5).
Experimental Condition |
Experiment 1 |
Experiment 2 |
Experiment 3 |
Sample 1 |
YELLOW |
YELLOW |
YELLOW |
Sample 2 |
BLUE |
BLUE |
BLUE |
Sample 3 |
GREEN |
GREEN |
GREEN |
Sample 4 |
YELLOW |
YELLOW |
YELLOW |
Sample 5 |
GREEN |
GREEN |
GREEN |
Table 5: AMAT’s verification under controlled conditions. A blind test was performed to determine the change in the device’s light color upon contact between the moisture sensor and a control sample containing a known amount of soil moisture level as follows: sample 1 – 30%; sample 2 – 80%; sample 3 - 60%; sample 4 – 40%; sample 5 – 70%. Representative images of samples summarized in this table are presented in Figure 6. The data demonstrates that AMAT can accurately detect soil moisture levels under controlled conditions.

Figure 6: Verification of AMAT’s Functionality under controlled conditions. A blind test was performed to determine the change in the device’s light color upon contact between the moisture sensor and a control sample containing a known amount of soil moisture level as follows: sample 1 – 30%; sample 2 – 80%; sample 3 - 60%; sample 4 – 40%; sample 5 – 70%. Shown are representative images. These results are also summarized in Table 5. The images demonstrate that AMAT can accurately detect moisture levels in the soil.
5. Conclusion
The AMAT effectively solves three problems: 1) pineapple waste reduction, 2) freshwater conservation, and 3) maintaining optimal soil moisture for indoor pineapple plants. In the long run, this device can be adapted for other plants and for outdoor usage by farmers to support responsible and sustainable farming.
Acknowledgments
I am grateful to my family for their support and Morteza Sarmadi for helpful discussions.
Author
Tikhon Kozlov is a high school sophomore. His favorite subjects include calculus, physics, computer science, and acrylic painting. He is a first-place winner of the AMC10 and an AIME participant. He is also the founder of a non-profit organization, https://www.mysea.dev/, dedicated to community services involving science, engineering, and the arts.
References
- Livesay J. Where do pineapples grow? An inside look at the complex history of the fruit's USA Today (2024).
- Mordor Pineapple Market Size & Share Analysis - Growth Trends & Forecasts (2024-2029) https://www.mordorintelligence.com/industry-reports/global-pineapple-market.
- Kengkhetkit N, Amornsakchai T. A New Approach to “Greening” Plastic Composites Using Pineapple Leaf Waste for Performance and Cost Materials & Design 55 (2014): 292-299.
- Fouda-Mbanga BG, Tywabi-Ngeva Z. Application of Pineapple Waste to the Removal of Toxic Contaminants: A Review. Toxics 10 (2022): 561.
- Soil Moisture Detector. https://www.tinkercad.com/things/ds479RNrT97-soil-moisture- detector?sharecode=aKINhpv9PA_Z_7kpw_yUgcSgHk9qkZYCuLd6zsLln6s (2024).
- How to Care for a Pineapple Plant (Indoor Houseplant). https://empressofdirt.net/pineapple-containers/ (accessed June 2, 2024).