Nov 18, 2016

GSM Pump Motor Controller Circuit using Arduino

In this post we are going to construct a farmer friendly GSM pump motor controller circuit which could turn on and off the irrigation system remotely from anywhere in the world via SMS and return you with an acknowledgement message. The idea was requested by Mr. PG Ragavandir.

By: Girish Radhakrishnan  

The Request

Dear Sir,

Greeting for the day, sir I'm looking for a circuit which Pump Motor get 'ON' & 'OFF'by using Remote or by mobile message for around 10 Km surrounding, it will be used for Farmers for there land (which they can be bit tension free). if possible can you help me for supporting them please.

Thanks & Best Regards
PG Ragavandir



The Design

Agriculture is one of biggest industry in India which serves food for more than a billion people every year. Producing vast amount of food is never an easy task; irrigation is one of the factor. 

Most of the agriculturist’s crop field is situated far from their residence, just turning on the water pump costs huge for their transportation per year.

India is known for IT skills and space programs and reached mars less than cost of movie “Gravity”, this signify the great potential among Engineers and Scientists. But, the skills are not uniformly distributed across different fields; agriculture is one of the field where technological development is slow.  


This Arduino based GSM pump motor controller circuit takes a baby step towards agricultural development, this may not be a revolutionary project but, it may bring delight among agriculturists.

Let’s dive into technical part of the project.


The project is designed with minimal hardware components so that a beginner can accomplish it with ease. 

The circuit consists of power supply, which powers the whole setup. 

The arduino is the brain of the project which take decisions and GSM modem which sends and receives text SMS and communicate with the user and relay which controls the motor.

The Circuit:





GSM Pump Motor Controller Circuit using Arduino

 
 

The transformer step down the 230VAC to 12VAC and bridge rectifier convert AC onto DC current and the current passes through an electrolytic capacitor to smooth the power supply.

A fixed 12V voltage regulator gives power to arduino, GSM modem and relay. The GSM modem is connected to arduino at pin #0 and pin #1, which are RX and TX respectively.


The RX of GSM is connected to TX of arduino and TX of GSM is connected to RX of arduino. If you are confused, just look at the below diagram, misconnection will not send or receive SMS.

                     ARDUINO       TX----------------------RX     GSM modem
                                              RX----------------------TX

Ground to ground connection is also established between arduino and GSM modem.


Try to get a male jack power connector for the GSM and arduino, if not just solder the wires directly from power supply to arduino and GSM, which might increase the mess in the project.


The transistor drives the relay and the diode protects the circuit from high voltage spikes while switching the relay ON/OFF. 


The LED indicator shows the status of the relay. If the LED glows the relay activated and if the LED is off the relay is deactivated.


Insert a valid SIM on the GSM modem and try to take advantage of the offers availed by the network provider for SMS such as rate cutters, which will reduce the expenses for SMS.



Program:


//----------------Program developed by R.Girish------------//
int LED = 8;
int motor = 9;
int temp=0;
int i=0;
char str[15];
void setup()
{
  Serial.begin(9600);
  pinMode(motor,OUTPUT);
  pinMode(LED,OUTPUT);
  digitalWrite(motor,LOW);
  digitalWrite(LED,LOW);
  delay(20000);
  delay(20000);
  delay(20000);
  Serial.println("AT+CNMI=2,2,0,0,0");
  delay(1000);
  Serial.println("AT+CMGF=1");
  delay(500);
  Serial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
  delay(1000);
  Serial.println("System is ready to receive commands.");// The SMS text you want to send
  delay(100);
  Serial.println((char)26); // ASCII code of CTRL+Z
  delay(1000);
}
void loop()
{
  if(temp==1)
  {
    check();
    temp=0;
    i=0;
    delay(1000);
  }
}
 void serialEvent()
 {
  while(Serial.available())
  {
    if(Serial.find("/"))
    {
      delay(1000);
      while (Serial.available())
      {
      char inChar=Serial.read();
      str[i++]=inChar;
      if(inChar=='/')
      {
        temp=1;
        return;
      }
      }
    }
   }
 }
void check()
{
   if(!(strncmp(str,"motor on",8)))
    {
      digitalWrite(motor,HIGH);
      digitalWrite(LED,HIGH);
      delay(1000); 
      Serial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("Motor Activated");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);
    } 
   else if(!(strncmp(str,"motor off",9)))
    {
      digitalWrite(motor,LOW);
      digitalWrite(LED,LOW);
      delay(1000); 
      Serial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("Motor deactivated");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);

else if(!(strncmp(str,"test",4)))
{
      Serial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("The System is Working Fine.");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);
}
}  
//----------------Program developed by R.Girish------------//



 NOTE 1: While compiling the program it shows a warning, which you can ignore it. The program is verified and tested.


NOTE 2: Please remove TX and RX connection from arduino while uploading the code.


NOTE 3: Replace “xxxxxxxxxxxxx” with recipient’s phone number in 4 places in the program. 


NOTE 4: Please purchase a GSM modem without power button in the module; in case of power failure it won’t latch in into mobile network unless you manually press the button, so avoid such type of GSM modems. The GSM modem one without power button will latch into mobile network directly after power retains.

Author’s Prototype of
GSM Pump Motor Controller Circuit:


 
 
How to use the above setup:


•    Use /motor on/ to activate the relay.


•    Use /motor off/ to deactivate the relay.


•    Use /test/ for testing the response from the circuit.


Start the command with”/” and end with “/” otherwise it won’t accept as valid request.


•    /motor on/ will turn ON the relay and return with an acknowledgement SMS “Motor Activated.”


•    /motor off/ will turn off the relay and return with an acknowledgement SMS “Motor Deactivated.”


•    If you send /test/ it will return with an acknowledgement SMS “The System is Working Fine.”


•    The above message signifies that your setup is working fine.      


•    If no acknowledgement is returned to you can assume that no action is preceded on the motor and you may troubleshoot the problems.


•    After powering the setup ON wait for 1 minute the system will send an acknowledgement SMS “System is ready to accept commands.” once you receive this SMS your project is ready to serve. 


The above commands are fool proof and never trigger the motor falsely, the setup will not respond any SMS other than the above specified commends.

61 comments:

  1. Hai sir...I'm new for Aurdino...
    So pls tell the Model no of Aurdino...
    And How to program the Aurdino sir...

    ReplyDelete
    Replies
    1. Hi Kesava, you will have to go through an extensive course to learn Arduino, it cannot be taught here in comments or through a few articles.

      Delete
  2. Replies
    1. you can find many good online tutorials with videos...

      Delete
  3. Sir i have one doubt abt PIR SENSOR...
    I bought from Amazon.Using rest room Pir sensor out..connected with transistor & relay its working well...but sometimes its flashing..
    While flashing time i enter inside its working well...whats the reason for flashing..

    ReplyDelete
    Replies
    1. It could be due to some stray signal pick up, try connecting a 10uF or any high value capacitor across base/emitter of the transistor and check the response

      Delete
  4. Sir I need automatic water tank overflow control circuit Using microcontroller with full detailed coding.

    ReplyDelete
    Replies
    1. Naresh, if possible I'll try to include it soon.

      Delete
  5. Already i connected sir...10uf 63v electrolyatic capacitor...same prblm coming sir.....when i enter inside it glowing well the flashing will be stop...and after 3 min it will be off ...after 1 hour it will be flashing.
    Sensor problem means it won't work when we enter...

    ReplyDelete
    Replies
    1. try connecting a filter capacitor immediately across the supply pins of the PIR, and also connect an LED in series with the transistor base and PIR o/p pin.....just to monitor the PIR output response....

      Delete
    2. I'm using NPN transistor ...
      Transistor base want to connect ANODE of LED ?
      and CATHODE of led to PIR o/p....

      We want to use resistor & led in series or only led in series


      Delete
    3. anode will connect with PIR o/p, and cathode towards the transistor base with the resistor in series...the resistor can come at the LeD anode or at the LeD cathode.

      PIR------>|----^^^^-----base

      PIR------^^^^----->|-----base

      Delete
    4. In u r PIR post i see one..ckt
      In the transistor emitter and base across one capacitor 25V 470uf...

      I make in my circuit..Now its working fine sir...

      I want to know the reason ..
      1.Y its making flashing while I'm using 10uf capacitor...
      2.when we increase capacitor value it not flashing and working good..
      What is the function of capacitor in this PIR circuit...

      Now its working well..
      I'm so happy sir..

      Thank u very much sir..

      Delete
    5. Kesava, I am glad you could correct the fault, however flashing should not have happened, that's something you will have to identify yourself, or you can change the PIR and see if the fault persists.

      increasing the capacitor effectively grounded the stray signals which was causing the fluctuations, and therefore the flashing stopped

      Delete
  6. If u r using pir circuit pls give the link id sir

    ReplyDelete
    Replies
    1. http://www.homemade-circuits.com/search?q=PIR

      Delete
  7. Instead of using PIR .I have one idea by using IR ,PHOTO DIODE and CD4017...when we give one postive pulse to PIN 14 the CD 4017 One channel will active i seen this circuit in Infrared using on off for home appliance...
    .I'm modifying the circuit..I'm using IR bulb it will continuously glow when we enter inside the ir will reflect the signal to photodiode . The photo diode will give signal to PNP transistor to activate the CD4017..now the o/p will be active...when we go outside of the room the reflection will happen again and the o/p will be off...

    I didn't try this circuit....If it's correct means i will try sir....pls give me SUGGESTIONS sir....

    ReplyDelete
    Replies
    1. yes you can alternatively try other types of sensors for sensing an intrusion.

      you can try a proximity detector circuit for the same.

      surely a 4017 flip flop circuit can be used for implementing the toggling action of a relay by integrating it with any form of intrusion detector sensor.

      Delete
  8. Dear Sir,

    Thanks for your response for this circuit, and I thank Mr. Radhakrishnan too.

    I will try to make this, If I achieved this for sure will tell your name & Mr. Radhakrishnan's name to whom all I try to help.

    Great for you both, may GOD bless

    Thanks & Best Regards
    PG Ragavandir

    ReplyDelete
    Replies
    1. You are welcome Ragavan! Wish you all the best...

      Delete
  9. Dear Sir,

    As you told Circuit is working sir, I got the commend(System is ready to accept commands)when we switch "ON" the circuit.

    But after getting that how many calls I have to do? I tried calling that number (call is going) but Relay is not getting activated and LED is also not glowing. Please help me to solve this problem sir.

    Best Regards
    PG Ragavandir

    ReplyDelete
    Replies
    1. Dear Ragavan, Mr. Girish will answer your question soon.

      Delete
    2. Hi Ragavan,

      Your system is working fine if you receive "System is ready to accept commands".

      You must send text SMS to the number not calling.

      Use /motor on/ to activate the relay.

      Use /motor off/ to deactivate the relay.

      Use /test/ for testing the response from the circuit.

      Start the command with”/” and end with “/” otherwise it won’t accept as valid request.

      Try to read the complete article as it is mentioned in the post :)

      Regards

      Delete
    3. Dear Swagatam Sit & Radhakrishnan Sir,

      Thanks for your immediate reply.

      As you told I did sir but sorry for saying, same message is coming as ready,

      Now I connected Arduino with PC to check comment prompt. In that I gave comment as your instruction but same happening sir. Relay is not switching "ON or OFF"

      Sir if possible can you please share your phone number or Gmail ID so that call or chat. Please help

      Best Regards
      PG Ragavandir

      Delete
    4. Hi ragavan,

      I think you are totally confused!!!

      you must send SMS commands as mentioned earlier from your mobile (the number which you have entered in the code) to the number of sim card which you have inserted in GSM module. That's all, and you will receive an acknowledgement SMS from GSM module. Every time you power on you will get that test SMS.

      Command prompt??? you mean serial monitor? No need to type any comment on that and no need to connect arduino to PC other than uploading the code.

      Any problem we are here to help.

      Best Regards

      Delete
    5. Dear Sir,

      Thanks for your reply, sorry for my late reply.

      I have to send SMS from my phone to the SIM in GSM number like "Motor ON & Motor OFF" right?

      Your right as you told I have typed in serial monitor only sir, sorry.

      Now will try and tell the result.

      Best Regards
      PG Ragavandir

      Delete
    6. Hi ragavan,
      Send sms /motor on/, /motor off/
      Starting and ending with "/".
      Regards

      Delete
    7. Dear Sir,

      Working sir, thanks a lot, "HATS OFF" for both,

      but this is working through only sending SMS "motor ON" and "motor OFF"? or we can Call and control also?

      Best Regards
      PG Ragavandir

      Delete
    8. Hi ragavan,

      I am glad that it worked.

      It can be controlled only by SMS

      Regards.

      Delete
  10. Why gsm module don't send any acknowledgement message

    ReplyDelete
  11. Hi ranjan,

    Please check your wire connections. We can't spot the reason why your circuit didn't work. Please elaborate your quires.

    Regards

    ReplyDelete
  12. please help me sir i want to give this project in my final year project
    I study in diploma 3rd year in ELECTRICAL

    ReplyDelete
  13. Dear Girish sir,
    I copy the program and replace "xxxxxxxx" by phone no. and compiled it,uploaded by aurdino software 1.0.3 version
    Then I use gsm module sim800a
    It has 4 no. of pin Tx,Rx,gnd,5v
    I connect
    Rx of aurdino------->Tx of gsm
    Tx of aurdino------->Rx of gsm
    gnd of aurdino------->gnd of gsm
    5V of aurdino------->5V of gsm
    Then give the supply to aurdino uno board
    I use airtel 4g sim with 2g accessible
    But it doesn't give any reply to the programmed phone number

    ReplyDelete
    Replies
    1. Hi Ranjan,

      Replace "XXXXX" with your phone number with +91 country code at beginning.

      Do NOT use 5V arduino supply to GSM modem. You should power it separately from a wall adapter with 9V.

      Let me know whether your GSM modem has power button, if so you should to press the power button for 3 seconds.

      Make sure that your sim card is latched into mobile network. You can confirm this by looking at network LED blinking once every 3 seconds and not blinking at faster rate continuously.

      Regards


      Delete
  14. It has not any power button
    I also give phone number with our country code i.e.+91
    Its network led doesn't blink in 3 second

    ReplyDelete
    Replies
    1. Hi ranjan,

      if the network LED is not blinking for every 3 second, there may be chance that your GSM modem is defective or the SIM is defective. Please confirm this before proceeding further steps.

      Your may check your GSM modem by sending basic SMS:

      http://www.homemade-circuits.com/2016/09/how-to-send-sms-using-gsm-modem-and.html

      If your GSM modem can send SMS then its error with your wire connection.

      Regards

      Delete
    2. can you please share your GSM modem's picture top and bottom view and share the link. Let me take a look....

      Delete
    3. Hi Ranjan,

      You have a slightly different kind of GSM modem than what I imagined, no problem.

      you can test the GSM modem by following the link in the previous comment and comment your issues, let's resolve it.

      Regards.


      Delete
  15. In this gsm module there are 3 led red,green,yellow and a buzzer.When i give supply to the gsm module the buzer is beep and red and yellow led is blink fast 3-4 time then off up to 30sec and the green led is always on

    ReplyDelete
  16. My link from which I purchase gsm module.
    http://www.amazon.in/gp/aw/d/B01MSVR7NJ/ref=mp_s_a_1_17?ie=UTF8&qid=1487232078&sr=8-17&pi=AC_SX118_SY170_QL70&keywords=gsm+module#

    ReplyDelete
    Replies
    1. Hi ranjan,

      Looks good,

      Insert the sim and call the number, you should get ring back. If this is done, try to send basic sms using your module from the link in previous comments.

      Regards

      Delete
  17. But sir I shouldn't get any ring back sir.
    I think I purchage your module.
    Please sir send me your link from which you buy your module.

    ReplyDelete
    Replies
    1. Hi ranjan,

      I don't remember URL, but I purchased from amazon. Try searching SIM 800 and you may see a module similar to mine which is shown the link:

      http://www.homemade-circuits.com/2016/09/how-to-send-sms-using-gsm-modem-and.html

      Regards

      Delete
  18. Good morning,
    Very good work. I want to ask if I want to put four relay;
    What change in the code;
    And command if(!(strncmp(str,"motor on",8))). The number 8 it says;
    I tried the code on A6 GSM and it works fine.
    Thank you very much.

    ReplyDelete
  19. Good morning,
    Very good work. I want to ask if I want to put four relay;
    What change in the code;
    And command if(!(strncmp(str,"motor on",8))). The number 8 it says;
    I tried the code on A6 GSM and it works fine
    Thank you very much.

    ReplyDelete
    Replies
    1. Thank you Konstantinos, I hope Mr. Girish will see this comment and revert soon.

      Delete
  20. Dear swagatam ,
    Can you ask me ,how many times can i pogeram a aurdino ,or is there any chance to rectify the pogram after uploded

    ReplyDelete
    Replies
    1. Dear Kaushik,

      there are no such restrictions, you can program as many times as you want and rectify the codes anytime after the upload

      Delete
  21. swagatam,
    i have a doubt,can you guide me sir,in program front what will be the 1st line of program & what will be the last line of program to be copy for uploaded?

    ReplyDelete
    Replies
    1. kaushik, this article was submitted by Mr. girish who is one of the authors of this blog, I hope he will find your comment and respond soon.

      Delete
    2. Hi kaushik,

      The program starts with

      //----------------Program developed by R.Girish------------//

      and end with the same. The mentioned line is not necessary to operate the project.

      You can copy the codes between the above mentioned line.

      Regards

      Delete
  22. MR.GIRISH I AM WAITING FOR YOUR REPLY....I BOUGHT ALL THE COMPONENT BUT DUE TO THIS DOUBT I CANNOT CONSTRUCTE MY PROJECT......PLEASE REPLY AT MOST EARLIEST..........

    ReplyDelete
    Replies
    1. Kaushik, Please refer to the above comment for the reply.

      Delete
  23. thank you to both of you ;i will try this ,if faced any trouble then please have to be help me to fulfill this project.

    ReplyDelete
    Replies
    1. Hi kaushik, we will help you to accomplishing the project, you may ask any number of queries.

      Regards

      Delete
  24. BRO.....THANKX FOR YOUR COORDINATION ,ONE MORE DOUBT IS WHICH NUMBER HAS TO BE PUT TO THE PROGRAM IN THE PLACE OF "XXXXXX".......THE NUMBER FROM WICH I SENT SMS OR WHICH THE SIM TO BE INSERT TO THE MODULE?

    ReplyDelete
    Replies
    1. Hi kaushik,

      You have to place your phone number from where you send SMS to GSM modem.

      Regards

      Delete
  25. This comment has been removed by the author.

    ReplyDelete
  26. Girish Radhakrishnan sir
    i am gandhi,my hobby to do the electronics projects,its really very useful to agri pump on and off.i use your code with gsm perfectly 9th digital pin led working based on the sms command and serial monitor i got the acknlowdgement while i send "/test/".i need the technical help 4m your side.weather the relay which is connected to the motor is on or not.just we want to know the status through gsm to our mobile sim number via sms not in serial monitor means how i wants to modify the program.guide me when ever u found free time.
    thanks

    ReplyDelete
  27. dear Girish Radhakrishnan,

    thanks a lot,u did a great job by posting a pump motor ON/OFF with coding.i use the coding its work 100% perfectly.in serial monitor its give the status based on our sms command.i need your 4m your side.when the motor is switched ON-we wants to get the feed back message to our mobile "motor is ON"-i request you to give the coding for that it will be more useful for the former's and me too.

    ReplyDelete