Design of Electronic Soil Micro Nutrient Sensor using Machine Learning to Detect N, P, K and pH Parameters

Macro-nutrients like Nitrogen, Phosphorous and Potassium commonly known as NPK are the values used for soil or fertilizers that are critical for a suitable growth of plants. Like, if you want to grow vegetables that are green and leafy you may have to use a fertilizer that has a higher nitrogen rati

2025-06-28 16:31:57 - Adil Khan

Project Title

Design of Electronic Soil Micro Nutrient Sensor using Machine Learning to Detect N, P, K and pH Parameters

Project Area of Specialization Artificial IntelligenceProject Summary

Macro-nutrients like Nitrogen, Phosphorous and Potassium commonly known as NPK are the values used for soil or fertilizers that are critical for a suitable growth of plants. Like, if you want to grow vegetables that are green and leafy you may have to use a fertilizer that has a higher nitrogen ratio because nitrogen is largely responsible for the growth of leaves on the plant. For Bloomy flowers, the ratio of phosphorous should be greater because phosphorus is largely responsible for root growth, flower and fruit development. Similarly, potassium can also be used in appropriate amount along with nitrogen and phosphorous to help the plants function properly. Moreover the pH level of the soil is as important as its NPK ratios because, if the soil fails to lie within a specified range of pH then it is going to leech out the nutrients affecting the overall growth of the plants or crops. The NPK ratios of the soil are compared with NPK ratios of the fertilizers so that a specific fertilizer can be used for a specific soil in order to yield more crops. The tests that are being performed to know the different ratios of NPK and pH levels are way too expensive and doing it with a soil NPK sensor does not give us accurate readings.
So, we are going to implement a machine learning algorithm into the previously working “Aqua Agro Project” that is a smart irrigation system currently being used for monitoring different water levels of the soil and is successful in saving water up to 40 percent. The ML algorithm will efficiently going to improve the readings present in the cloud, taken out from a soil NPK sensor having probes underground by deriving a relationship between independent and dependent variables. Nitrogen, Phosphorous and potassium are dependent variables. They are dependent on soil pH, moisture, temperature and cation exchange capacity i.e. on independent variables. This implementation will enhance the effectiveness of the Aqua Agro Project and allow farmers to reduce cost, maintain optimal plant level and potentially increase plant production.

Project Objectives

We want to find out the relationship between soil moisture- temperature, soil pH-CEC and NPK values
respectively by them NPK sensor and Machine Learning Algorithm. The knowledge about the soil will
empower the farmers to better use the fertilizer. The understanding of the relationship between soil moisturetemperature,
pH-CEC and NPK values will enable the farmers to increase the crop yield.
We are first going to design the sensors and calibration software (through Machine Learning) which will
increase the accuracy of the electronic sensors approximately equal to the results of chemical test. This will
eliminate the need for physical testing of NPK values which is quite expensive. It will enable farmers to use
the correct fertilizer without extensive testing and expenditure.

Project Implementation Method

Hardware:
Electronic nutrient sensors
IoT embedded systems(RasberryPi controller)

LCD Screen, Probes 
Software:
Python (Jupyter Notebook and anyother environment)
Pyserial
ML tools(pandas, numpy, tensorflow)

First we are going to design a voltmeter using RasberryPi, LCD and steel or copper probes and then afterwards will find out the potential difference of different soils with that. At the same time we will be collecting soil samples and note down their pH through pH strips. Then we will map the IoT based voltmeter and the pH readings in the same integrated RasberryPi. Then we are going to make a Machine Learning algorithm and will train it using the data collected from several soils. pH readings collected from the soil will help us find out the N,P,K values. We will further integrate the N,P,K values in our learning model. This way we will end up with a effective device that will give us accurate N,P,K and pH readings as compared to the devices available in the market.

Benefits of the Project

Agriculture is an important sector of Pakistan's economy. This sector directly supports the country's
population and accounts for 26 percent of gross domestic product (GDP). The NPK ratio of the soil
informs the farmers about the ratio of the fertilizer. For example, if the soil has high amounts of
Phosphorus and Potassium, but not nitrogen, then farmers shall use a fertilizer that has more nitrogen and
less Phosphorus and Potassium. However, farmers in emerging countries still have no idea how to use the
information to their advantage. The fertilizer companies print NPK values on fertilizer bags. However,
farmers are unsure of how to use the values correctly. It is impossible to find NPK values with the naked
eye. Detailed analysis is required to understand the NPK values. Therefore, farmers often misuse
fertilizers, and as a result, the crop yield is reduced, or it is not perfect. Every plant has a different NPK
requirement. Some plants require more nitrogen, while others require more potassium and phosphorus.
The lack of data on soil nutrients forces farmers to plant crops on unsuitable soil, and they eventually
misuse the fertilizer as they have no idea about the soil nutrients. The farmers mismanage land and other
precious resources. As a result, developing countries like Pakistan suffer from water shortage and low crop
yield. The misuse of resources puts a strain on food security in the region. Pakistan is an emerging country.
It has a large agriculture sector. However, the industry is not even close to its true potential. Pakistan
produces large quantities of different crops. The country still has low exports and high imports. The main
reason is the low- quality crops. It is mind-boggling that a country with 47% of agricultural land suffers
from low quality of crops. The farmers in Pakistan do not know how to calculate NPK values. They are not
aware of how NPK values affect crops. Therefore, they inappropriately use the fertilizer and as a result,
crops suffer. Pakistan has the potential to lift its economy through agriculture. If the crop yield is anywhere
near the maximum potential, then the country will benefit from the high exports. Also, the growth in
agricultural production would provide sufficient raw materials to the industrial sector of the country.

Technical Details of Final Deliverable

Our final product will be an Electronic based pH and N,P,K values sensor with a trained Machine Learning Model in it. It will be able to predict the values accurately and will be more effective than the products available in the market whose readings are not up to the mark. With the help of this product we will get rid of expensive chemical testing and farmers will be able to use the correct fertilizers and will end up yielding large amount of crops.

Final Deliverable of the Project HW/SW integrated systemCore Industry AgricultureOther Industries Food Core Technology Artificial Intelligence(AI)Other Technologies Internet of Things (IoT)Sustainable Development Goals Good Health and Well-Being for People, Decent Work and Economic Growth, Responsible Consumption and ProductionRequired Resources
Item Name Type No. of Units Per Unit Cost (in Rs) Total (in Rs)
Total in (Rs) 32300
Respberry Pi 4 MODEL 8-GB Equipment12400024000
pH strips Equipment218003600
LCD screen Equipment110001000
wires for solding and probes Equipment1050500
copper and steel probes Equipment2100200
printing and other overheads Miscellaneous 120002000
PVC pipes and structure cost Equipment110001000

More Posts