Farming and Gardening are not trivial jobs. There is a range of crops and plants and numerous varieties of each plant or crop. Different plants and crops have different requirements of water, fertilizer, and sunshine. The fertility of soil for any farming or gardening effort is usually judged by the level of nutrients and moisture in it. A number of times the farmers or gardeners are not able to nourish the soil with sufficient fertilizer or water while at many times they just over do it. This project is to help farmers and gardeners keep a check on the soil health by real-time tracking the moisture level of their soil.

The project utilizes DHT sensor to keep a track of ambient temperature and humidity and a moisture sensor to record soil moisture. The RTC DS1307 is used keep track of real time so that the moisture rating could be logged and relayed over fixed interval of time in a real-time fashion. The project sends out the real-time alert of inappropriate moisture levels through SMS using a GSM/GPRS modem to a registered mobile number of the farmer or caretaker. The system is able to automatic control a water pump which can be switched on through SMS in response to the real-time alert. Once the water pump is switched on through SMS it automatically switches off after the appropriate moisture level is attained.

Fig.1 : Prototype of Arduino based Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

The farmer or caretaker can also switch off the water pump in between by sending an SMS or manually operating the project interface. The data log of message alerts can also be cleared through the project interface. The human interface attached to the project consists of a 16X2 LCD display which runs the mobile registration process on the start of the system and allows mobile registration update and display of current soil health readings when prompted. The input to the system is fed through a numeric keypad and all the instructions feed to the system are also numeric codes.

The project has the following execution cycle-:

1) As the system is powered on, it prompts the user for mobile number registration by displaying initial messages on the LCD display. The user has to press "*", enter his mobile number and press "#" to complete the mobile number registration. If the user has already registered his mobile number on the device, he can cancel the process by pressing "#" without entering the mobile number.

2) The registered mobile number is saved to the internal memory of the Arduino Mega.

3) After the mobile number registration, the Arduino board fetch the real time from RTC module, humidity, and temperature using DHT11 sensor and moisture level through the moisture sensor and start displaying all the readings on LCD display.

4) Once the system is initialized, the user needs to set the time interval for SMS alerts of the moisture level. The system can accept any time duration as required by the user for SMS alerts of moisture level.

5) When the system will find the moisture level below the set level, warning SMS alert is sent to the registered mobile number.

6) The user can respond to the warning SMS alert by replying back an SMS "ON MOTOR" which will switch ON the water pump for a duration until the moisture level increases to the set level. The water pump automatically switches OFF once the required moisture level is attained.

7) The user can also turn OFF the water pump manually if finds that suitable.

Once the project is initialized after mobile number registration and it starts displaying moisture, date-time, and temperature and humidity readings, it is ready to accept the following numeric instruction codes.

• Run time phone number update: When the device starts it always prompts the user to register the phone number. The phone number can also be updated during the run time of the project which can be initiated by pressing “0”. Thereafter, the user has to enter the new mobile number for renewing registration and press "#" to complete the registration process.

• Deleting SMS log: By pressing ‘*’ during runtime the user can delete all the messages saved to the SIM card inserted in GSM/GPRS module.

• Setting time interval for SMS alerts: By pressing hash ‘#’ user can initiate setting the time interval in seconds and pressing ’#’ again saves the entered time interval to the internal memory of the board.

• Manual Moisture Level Check: User can check the moisture level manually by pressing ‘1’ on the keypad.

• Registered Mobile Number Check: User can check the registered mobile number pressing '2' on the keypad.

• Time Interval Check: User can check the time delay set to wait for the response by pressing ‘3’ on the keypad.

Components Required

• Arduino Mega2560

• GSM/GPRS Module SIM900

• RTC module-DC1307

• Moisture sensor with analoge output.

• DHT11 humidity and temperature sensor

• 16x2 LCD

• Capacitor 25v, 4700uF

• Transformer 18-0, 2Amp -1pc

• 1N4007 diode -4pcs

• 12v Relay-1pc

• BC 547 transistor-1pc

• 1K ohm resisters -3pcs

• 4x3 keypad-1pc

• Voltage regulator -7805 and 7812

• LED -5mm RED- 2

• Wire to carry 2A, 230v AC

• Two pin Plug

Fig. 2: Block Diagram of Arduino based Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

Circuit Connections

As is clear from the block diagram the heart of the project is Arduino Mega board and all other circuit sections are connected to it. There are following sections of the project circuit -:

1) Power Supply Regulator

2) Relay Circuit as Power Switching Unit.

3) RTC Module DS1307

4) LCD Display

5) 4x3 Keypad

6) GSM/GPRS Module

7) DHT11 sensor

8) Moisture Sensor

The Arduino Board is the programmable Unit controlling the entire functionality of the project and every module is interfaced to it. The circuit is connected in the following manner -:

1) Power Supply: While the water pump will need AC supply, the project circuit needs 12V and 5V DC supply. The 12V supply is provided via 7812 voltage regulator and supplied to the 12V relay and 7805 voltage regulator. The other components need a 5V DC supply which is provided through 7805 voltage regulator that is converting the input 12V supply to 5V DC.

2) Relay Circuit: The water pump is connected to the circuit through a 12V relay. The relay is connected to the pin 24 of Arduino Mega board and have a BC547 transistor circuit of a common emitter configuration for interfacing with the board.

3) DHT11 connection: The data pin of temperature and humidity sensor DHT11 is connected to pin 10 of the Arduino Mega and ground and VCC connected to the relevant pins.

4) RTC Module: DS1307 RTC module is used in the circuit. The 5V DC supply and ground to the RTC module are provided by the 7805 voltage regulator. The SDA and SCL pins of the RTC are connected to the SDA and SCL pins of Arduino Board respectively. Learn more about RTC and its interfacing with Arduino UNO. The standard library of Arduino for RTC is used in the program code to run RTC specific project code.

5) GSM/GPRS MODULE: Here Arduino Mega is using TX1 and RX1 from its three USART ports. Vcc and ground are provided with the external power supply of 12v, 2Amp, and common ground. The TX terminal of GSM module is connected to the pin 19 (RX1) of Arduino Mega and its Rx terminal is connected to the pin 18 (TX1) of Arduino mega. Read more.

6) LCD Display: The 16X2 LCD display is connected to the Arduino board by connecting its data pins to pins 3 to 6 of the Arduino board. The RS and E pin of LCD is connected to pins 13 and 12 of the Arduino Mega respectively. The RW pin of the LCD is grounded.

Fig. 3: Table listing circuit connections between Arduino Uno and Character LCD The standard code library for interfacing Arduino is used in the project to program LCD with the Arduino board. Learn more about LCD interfacing with ARDUINO 4x3 Keypad: This is a numeric keypad having 12 input buttons arranged in 3 columns and 4 rows. In the keypad, 4 wires are used as ROWS and three wires are used as COLUMNS. The wire number can be count from the left-hand side to the right-hand side. The row and column wires are interfaced to the Arduino pins in the following manner.

Exclusive Digi-key Tools Embedded computers Hardware Integrated Circuits Connectors Transducers Circuit Protection



How the Circuit Works

The circuit works in following stages -:

1) Initialization of the circuit

As the circuit is switched on Arduino loads the imported libraries of LCD display, DHT library, EEPROM library, keypad library and RTC library. First Initial messages are flashed on the display screen prompting to complete mobile number registration. The user needs to enter his phone number and press "#" to complete the registration process. After that the current date and time are fetched from the RTC and humidity and temperature readings are fetched from the DHT11 sensor and they are displayed on the LCD screen.

2) After phone number registration, the user is prompted to enter a time interval for SMS alert of real-time soil health and the system goes into the operating mode. The device starts sending SMS containing details like moisture level, ambient temperature, and relative humidity by the interval set by the user.

3) Low moisture level detection: System checks the moisture level on a polling basis and whenever the system detects low-level moisture, it sends a warning SMS to the user. The device waits till the user switches ON the water pump or until the moisture level resumes to its best level.

4) SENDING SMS: When the user gets the warning SMS, he has to reply back by sending SMS “ON MOTOR” to the device in order to switch the water pump ON and he can send “OFF MOTOR” SMS to switch the water pump OFF.

Programming Guide

The code utilizes standard libraries of the Arduino. Therefore, first of all, predefined libraries for LCD display, DHT sensor, EEPROM library, keypad library and RTC library are imported in the code. An LCD object is instantiated and mapped to pins 13, 12, 6, 5, 4 and 3 of the Arduino. An object of RTC type and an object dht of DHT type is declared. For keypad interfacing, two constants representing a number of rows and columns of the keypad are defined and used in the declaration of arrays for representing individual keys of the keypad. The keys are mapped to Arduino pins as mentioned in the table given above. The variables to hold values of temperature, relative humidity, and moisture level are declared. A string object is declared to hold SMS text and a flag is set to check the status of SMS alert. A 'relay' variable is declared and assigned to the pin 24 where relay has been connected. The numeric representation of keys is assigned by a two-dimensional array and variables to hold time and phone number are declared. A keypad object is declared and assigned key map.

Fig. 4: Screenshot of initialization in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

The baud rate for the Arduino and the GSM module is set to 9600 bits per second. The pinMode() and digitalWrite() functions are used to set the input/output mode and pin status of the Arduino IC pins. The LCD object is initialized and initial messages are flashed on the display screen. The RTC is tested to fetch current date and time.

Fig. 5: Screenshot of Setup Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

A loop() function is called where the key pressed by the user is detected and messages are flashed on the LCD screen prompting user to register mobile number. The registered mobile number is saved using saveNUM() function and the display screen is cleared by detecting the "#" pressed.

Fig. 6: Screenshot of Loop Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

A function moistureAlertSMS() is declared where the analog reading from moisture sensor is fetched and the reading is saved as an SMS in proper format to GMS module.

Fig. 7: Screenshot of Moisture Alert SMS Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

A lowalertSMS() function is called where the mobile number is fetched from the EEPROM and an SMS for low moisture level is pushed to the GSM module.

Fig. 8: Screenshot of LowAlertSMS Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

A processSMS() function is called which detects the reply SMS and operates the relay to switch the water pump on or off. The current status of the motor pump is displayed on the LCD screen simultaneously.

Fig. 9: Screenshot of ProcessSMS Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller

Finally a function matchTIM() is declared where the time interval to send the SMS alert is set and the SMS is pushed out according to the set time interval. The message "TIME MATCHED" is displayed on the LCD screen at the instant SMS is sent to the registered mobile number.

Fig. 10: Screenshot of matchTIM Function in Arduino Code for Soil Moisture Detector and Mobile operated Automatic Water Pump Controller