Description
The 5-in-1 soil sensor is a versatile tool that can be used to measure the key environmental factors that affect plant growth. It can measure pH, which is a measure of the acidity or alkalinity of the soil; NPK, which are the three major nutrients that plants need; temperature, which affects the rate of plant growth; humidity, which affects the availability of water to plants; and conductivity, which is a measure of the amount of dissolved minerals in the soil.
The 5-in-1 soil sensor is easy to use and can be inserted into the soil to measure the environmental conditions at a specific location. The data from the sensor can be used to optimize irrigation, fertilization, and other agricultural practices to improve plant growth and yield.
Here are some additional benefits of using a 5-in-1 soil sensor:
It can help you identify nutrient deficiencies in your plants early on, so you can take corrective action before the plants start to suffer.
It can help you optimize your irrigation schedule, so you don’t overwater or underwater your plants.
It can help you choose the right fertilizer for your plants, so you don’t waste money on unnecessary nutrients.
It can help you monitor the health of your soil over time, so you can make changes as needed to improve its quality.
5-in-1 soil sensor Features:
(1)Protection performance:Epoxy resin can be packed in high-temperature vacuum, which can prevent moisture from entering the inside of the fuselage, and the sealing performance is better.
(2)IP68 waterproof and dustproof:In addition to the combination part, we also do waterproof and dustproof treatment to the entire body to ensure the long-term operation of the components.
(3)Sensitive chip for metal probe:The probe is resistant to rust, electrolysis, and salt-alkali corrosion, ensuring long-term operation of the probe part, suitable for various soils, low power consumption, high sensitivity, and stable signal.
Monitoring parameters:
(1)Soil temperature detection:Easy to understand.Soil temperature determines the living environment of the plant to create a standard greenhouse for your soil.
(2)Soil pH test:Accurate control,Soil pH affects plant growth and protects your soil acid-base balance.
(3)Soil NPK detection:Test at any time,Soil NPK is an important nutrient element for plant growth and promotes plant growth.
(4)Soil conductivity test:Rational planting,Soil conductivity reflects soil salinity and affects soil nutrient conversion and effectiveness.
(5)Soil moisture detection:Easy to understand.Soil moisture determines the living environment of the plant to create a standard greenhouse for your soil.
Hardware required
- Soil NPK Sensor
- Arduino Un0
- MAX485 TTL To RS485 Module
- Jumper wires
Connecting the Hardware
Connect all the required components as shown in the below schematic diagram to interface Soil NPK sensor with Arduino Uno through MAX485 to display the Soil NPK values on Serial Monitor
Connect the R0 & DI pin of from the Modbus to D2 & D3 Arduino using Software Serial. Similarly, we have to enable DE & RE high. To do this connect the DE & RE Pins to the D7 & D8 pin of Arduino. The NPK Sensor has 4 wires. The brown one is VCC which needs a 9V-24V Power Supply. The GND pin which is black in color. So connect it to the GND of Arduino. The Blue wire which is the B pin is connected to the B pin of MAX485 & the Yellow Wire which is the A pin is connected to the A pin of MAX485.
Note: RO to pin 8 & DI to pin 9 when using AltSoftSerial
Setting up the library
Install the required libraries listed below before uploading the code:
- Adafruit SSD1306 – Adafruit_SSD1306.h – link
- Adafruit GFX Library – Adafruit_GFX.h – link
- AltSoftSerial Library – AltSoftSerial.h – link
Upload the Code
#include <AltSoftSerial.h> // RO to pin 8 & DI to pin 9 when using AltSoftSerial #define RE 6 #define DE 7 const byte temp[] = {0x01,0x03, 0x00, 0x13, 0x00, 0x01, 0x75, 0xcf};// const byte mois[] = {0x01,0x03,0x00,0x12,0x00,0x01,0x24,0x0F}; const byte econ[] = {0x01,0x03, 0x00, 0x15, 0x00, 0x01, 0x95, 0xce}; const byte ph[] = {0x01,0x03, 0x00, 0x06, 0x00, 0x01, 0x64, 0x0b};//0x0B64 const byte nitro[] = { 0x01, 0x03, 0x00, 0x1E, 0x00, 0x01, 0xE4, 0x0C }; const byte phos[] = { 0x01, 0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc }; const byte pota[] = { 0x01, 0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0 }; byte values[11]; AltSoftSerial mod; float envhumidity = 0.0, envtemperature = 0.0, soil_ph = 0.0, soil_mois = 0.0, soil_temp = 0.0; byte val1 = 0, val2 = 0, val3 = 0, val4 = 0,val5 = 0, val6 = 0, val7 = 0; void setup() { Serial.begin(9600); mod.begin(9600); pinMode(RE, OUTPUT); pinMode(DE, OUTPUT); // put RS-485 into receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); delay(3000); } void loop() { val1 = moisture(); soil_mois = val1/10.0; delay(1000); soil_temp = temperature()/10.0; delay(1000); val3 = econduc(); delay(1000); val4 = phydrogen()/10; soil_ph = val4; delay(1000); val5 = nitrogen(); delay(1000); val6 = phosphorous(); delay(1000); val7 = potassium(); delay(1000); Serial.print("Moisture: ");Serial.print(soil_mois);Serial.println(" %"); delay(1000); Serial.print("Temperature: ");Serial.print(soil_temp);Serial.println(" C"); delay(1000); Serial.print("EC: ");Serial.print(val3);Serial.println(" us/cm"); delay(1000); Serial.print("ph: ");Serial.print(soil_ph);Serial.println(" ph"); delay(1000); Serial.print("Nitrogen: "); Serial.print(val5);Serial.println(" mg/kg"); delay(1000); Serial.print("Phosphorous: ");Serial.print(val6);Serial.println(" mg/kg"); delay(1000); Serial.print("Potassium: ");Serial.print(val7);Serial.println(" mg/kg"); Serial.println(); delay(3000); } byte moisture() { // clear the receive buffer mod.flushInput(); // switch RS-485 to transmit mode digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); // write out the message for (uint8_t i = 0; i < sizeof(mois); i++) mod.write(mois[i]); // wait for the transmission to complete mod.flush(); // switching RS485 to receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); // read in the received bytes for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; } byte temperature() { // clear the receive buffer mod.flushInput(); // switch RS-485 to transmit mode digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); // write out the message for (uint8_t i = 0; i < sizeof(temp); i++) mod.write(temp[i]); // wait for the transmission to complete mod.flush(); // switching RS485 to receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); // read in the received bytes for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[3]<<8|values[4]; } byte econduc() { // clear the receive buffer mod.flushInput(); // switch RS-485 to transmit mode digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); // write out the message for (uint8_t i = 0; i < sizeof(econ); i++) mod.write(econ[i]); // wait for the transmission to complete mod.flush(); // switching RS485 to receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); // read in the received bytes for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; } byte phydrogen() { // clear the receive buffer mod.flushInput(); // switch RS-485 to transmit mode digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); // write out the message for (uint8_t i = 0; i < sizeof(ph); i++) mod.write(ph[i]); // wait for the transmission to complete mod.flush(); // switching RS485 to receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); // read in the received bytes for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; } byte nitrogen() { // clear the receive buffer mod.flushInput(); // switch RS-485 to transmit mode digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); // write out the message for (uint8_t i = 0; i < sizeof(nitro); i++) mod.write(nitro[i]); // wait for the transmission to complete mod.flush(); // switching RS485 to receive mode digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); // read in the received bytes for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; } byte phosphorous() { mod.flushInput(); digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); for (uint8_t i = 0; i < sizeof(phos); i++) mod.write(phos[i]); mod.flush(); digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; } byte potassium() { mod.flushInput(); digitalWrite(DE, HIGH); digitalWrite(RE, HIGH); delay(1); for (uint8_t i = 0; i < sizeof(pota); i++) mod.write(pota[i]); mod.flush(); digitalWrite(DE, LOW); digitalWrite(RE, LOW); // delay to allow response bytes to be received! delay(200); for (byte i = 0; i < 7; i++) { values[i] = mod.read(); // Serial.print(values[i], HEX); // Serial.print(' '); } return values[4]; }
Reviews
There are no reviews yet.