The following system measures the Soil Moisture percentage and it will be notified by two ways. i.e In section 6.2 measured quantity will be displayed on the LCD display, and in 6.3 it is sent to the given mobile phone number as an SMS.
6.1.
Interfacing soil moisture sensor with Arduino
In order to receive the sensed data from the soil moisture
sensor to arduino, power supply of 5V is provided from arduino by connecting
Vcc of sensor to 5V of arduino and GND of sensor to GND of arduino. Readings
are retrieved at analog pin of arduino by connecting A0 of soil moisture sensor
to any analog pin of arduino. Those retrieved values are displayed via LCD
display or sent as SMS using GSM-SIM 900.
Soil moisture sensor
|
Arduino
|
Vcc
|
5V
|
Gnd
|
Gnd
|
A0
|
A0
|
D0
|
NC
|
6.2. Soil moisture sensor with LCD
6.2.1. Circuit diagram:
6.2.2. Arduino program:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 2, 3, 4, 5);
int soil=0;
// the setup routine runs once when you press reset:
void setup()
{
//
initialize serial communication at 9600 bits per second:
Serial.begin(9600);
lcd.begin(16,2);
}
// the loop routine runs over and over again forever:
void loop() {
lcd.clear();
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
sensorValue = constrain(sensorValue,
485, 1023);
// print out the value
you read:
//Serial.println(sensorValue);
//map
the value to a percentage
soil = map(sensorValue,
485, 1023, 100, 0);
// print out the soil
water percentage you calculated:
Serial.print(soil);
Serial.println("%");
lcd.print("Soil
Moisture");
lcd.setCursor(0, 1);
lcd.print(soil);
lcd.print(" %");
delay(1000); // delay in between reads for
stability
}
6.2.3. Output of the System
6.3. Soil moisture sensor with
GSM-SIM 900
6.3.2. Arduino program:
int soil=0;
// the setup routine runs once when you press
reset:
void setup() {
// initialize serial
communication at 9600 bits per second:
Serial.begin(9600);
Serial1.begin(9600); //Baud rate of the GSM/GPRS Module
Serial1.print("\r");
}
// the loop routine runs over and over again
forever:
void loop() {
// read the input on
analog pin 0:
int sensorValue =
analogRead(A0);
sensorValue = constrain(sensorValue,
485, 1023);
// print out the value
you read:
//Serial.println(sensorValue);
//map
the value to a percentage
soil = map(sensorValue, 485, 1023, 100, 0);
//
print out the soil water percentage you calculated:
Serial.print(soil);
Serial.println("%");
delay(1000);
// delay
in between reads for stability
Serial1.print("AT+CMGF=1\r");
delay(1000);
Serial1.print("AT+CMGS=\"+919542081456\"\r"); //Number to which you want to send the SMS
delay(1000);
Serial1.print(soil); //The text of
the message to be sent
Serial1.print("%");
delay(1000);
Serial1.write(0x1A);
delay(20000);
}
Please Let me know if you have any queries?
ReplyDeleteNice information..
SENA Corporation | Tank Level Monitoring