Introduction

In this article, I'll show you how to create an automatic plant watering system using Arduino Mega interfacing with Android mobile. This project is fully based on soil moisture irrigation.
Requirements
Connections
GSM
  • RX to RX1
  • TX to TX 1
  • Gnd to Gnd
Bluetooth
  • RX to TX
  • TX to RX
  • Vcc to Arduino 5v
  • Gnd to Gnd
Led
  • Anode to the digital pin 5
  • Cathode pin to the Gnd
Soil Moisture
  • Vcc pin to the 5v
  • Gnd to Gnd
  • Data pin to the Analog A0
Programming
  1. #include<SoftwareSerial.h>
  2. SoftwareSerial firstSerial(15,16);
  3. int led = 5;
  4. int pin=A0;
  5. int moisture=0;
  6. String readString;
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. firstSerial.begin(9600);
  11. Serial.begin(9600);
  12. pinMode(led, OUTPUT);
  13. delay(100); // Baud Rate
  14. }
  15. void loop()
  16. {
  17. while (Serial.available()) //Send data only when you receive data
  18. {
  19. delay(4); //delay time
  20. char c = Serial.read();
  21. readString += c;
  22. }
  23. if (readString.length() > 0)
  24. {
  25. Serial.println(readString);
  26. if (readString == "ON")
  27. {
  28. digitalWrite(led, HIGH); // LED ON
  29. }
  30. if (readString == "OFF")
  31. {
  32. digitalWrite(led, LOW); //LED OFF
  33. }
  34. readString = "";
  35. }
  36. int soilmoisture=analogRead(pin);
  37. if(soilmoisture>=100){
  38. digitalWrite(led,HIGH);
  39. firstSerial.println("AT+CMGF=1");
  40. delay(1000);
  41. firstSerial.println("AT+CMGS=\"+xxxxxxxxxx\"\r"); //Enter Your Mobile Number instead XXXX while Testing
  42. delay(1000);
  43. firstSerial.println("Hai there I need some water");
  44. delay(100);
  45. firstSerial.println((char)23);
  46. delay(1000);
  47. }
  48. else{
  49. digitalWrite(led,LOW);
  50. }
  51. Serial.println(soilmoisture);
  52. Serial.print("%");
  53. delay(20);
  54. }
Android App
Explanation
The Automatic plant watering system is based upon soil irrigation. In the program first, we want to set the header file to the GSM Module and set the RX and TX Pin to the GSM Module. In the setup function, we want to set the baud rate for GSM and the Arduino Board as 9600 and here we are using the HC-05 Bluetooth device for pairing between Android mobile and the Arduino when it is paired, which means completely controlled through the Android device. Here's the procedure:
Working Procedure
Output
Read more articles on Arduino: