Tuesday, April 12, 2016

Remote control for irrigation pump

I don't have a house in the farm at this time. Therefore I am living in a place few kms away from the farm. Karnataka state (my farm is in Karnataka) had been producing far less electric power than the demand. Therefore power companies take a easy route - stop power to villages to supply power to towns and cities. Power shutdown in villages is very common. Scheduled power shutdown is at least for 6 hours in a day. There can be more power shutdown depending on situation like less water availability in hydro power generation stations, less water availability for thermal power generation stations etc. during summer months when the electricity need peaks (for cooling and irrigation). Also there is this practice of "single phasing" (meaning one or two phases are disconnected or too low voltage is provided) during day time to prevent running 3 phase irrigation pumps. Because of these reasons it is possible to run irrigation pumps only during night time for few hours when the electricity supply is available and stable. This situation makes it very difficult to irrigate the farm for people living away from farm like me. It is a major hassle to walk to the pump house in the night to operate the pump even for people living close to the farm or in the farm. There are also instances of people dying of snake bite when they went to the farm in the night to operate the irrigation pump!

What is the solution to this problem? I thought of 2 possibilities:
  1. Sun is far more reliable than anything else in this part of the world. Use the Sun, install a solar pump. It runs only during day time when Sun is shining bright. That works very well for irrigation pump.
  2. Have some way to operate the pump remotely when there is power in the farm.
Solar pump solution does not work for me because solar panels can be stolen or damaged by miscreants since there is nobody living in the farm at this time to protect the panels. Therefore solar pump is not feasible option for me. Only way I can operate the pump is through some kind of remote control.

First thought coming to mind to solve this problem is running the pump using a timer. This timer needs to be little intelligent to run the pump for specified duration even when there are power interruptions in between. For example - if I set the timer to run for 10 minutes, it should remember to run the pump for remaining duration of 4 minutes if the power shuts down when the pump has run for 6 minutes. It is not difficult to have such an implementation. However, there is one problem here. I may not want to run the pump for a fixed duration every day. For example - I may want to irrigate more on the previous day if I am traveling out of town for a day or two. Then the pump has to run for extra duration that day. Another example - I may not want to run the pump for a day or two when there is some rain. Summary is - fixed timer based pump controller is not flexible; it is not practical.

I need an implementation where I can decide how long to run the pump on any day/time or even not to run the pump on any given day/time. Call it "on-demand" remote pump switch. It should be like a remote control to control the pump from anywhere. That means I need some kind of wireless communication to the pump controller.

SIM900 module I bought off Amazon
Thanks to GSM mobile phone technology, anybody can have wireless communication today. I decided to use a GSM module for wireless communication. A GSM module is a cell phone signal transceiver with serial communication interface for programming it through a micro processor. For micro processor I used a Raspberry Pi gifted to me by some engineering students when I helped them as their final year project guide. Instead of buying a new micro processor I decided to use Raspberry Pi which was lying around idle. Pi is an overkill for this application. I will buy Arduino nano If I have to buy a micro processor for this.

I bought a SIM900 module, relay board, a power relay (10A @ 250V) to switch the pump on/off, and 5V 2A power supply online. I added a 12V transformer for supplying power to GSM module. Hooked up Tx and Rx pins of SIM900 module to Rx and Tx pins of Raspberry Pi (Tx of GSM module goes to Rx of Pi and Rx of GSM module goes to Tx of Pi). I added some circuits soldered on a general purpose PCB to detect over voltage and under voltage to stop the pump if the voltage goes above or below certain levels. Programmed Pi using Python language to process messages sent to GSM module. In the program I baked in intelligence to work around power interruptions to ensure pump runs for the specified duration. Bought an electric switch board container box to house the whole thing. Drilled some holes on it for ventilation (obviously all the electronic stuff generates some amount of heat which should be dissipated). Popped in a SIM in the SIM holder of GSM module. This is how it looks when completely wired up. People with some electronics knowledge can make out which board is what. Please feel free to ask if you need any more information about the controller.

Pump controller as installed in the farm


Conversation between my cell phone and pump controller
This is a sample of conversation between my cell phone and the pump controller. Don't bother sending messages (if you can somehow figure out the complete cell number of pump SIM card) to hack into my pump controller, it won't work because I have programmed the controller to take messages from specific phone numbers only :-) Messages from other phone numbers are ignored and deleted. Controller has been tested under field conditions to ensure it works fine. There were some hiccups initially. I added a USB storage device to Raspberry Pi for collecting logs from the application. Logs were used for debugging the code running inside Pi. Controller had been running reliably from Oct/Nov-2015.
Next step to this is having moisture sensors in the farm to decide when the plants need water and turn the pump on/off as per needs of the plant. That will be a dream come true because then the plants will be watered automatically whenever they need water.

Update on 22-Sep-2016:

Pump controller had a major problem after being operational for around 7-8 months (excluding the monsoon months when I had switched it off). Yesterday evening I switched the pump on for 2 hours  to irrigate growing paddy crop. Pump controller responded with messages when it switched the pump on and 2 hours later when it switched the pump off. However, I was surprised to see the water flowing through the pipe when I visited the farm today morning. Pump had been running for last 16 hours! Further investigation showed that the relay used for switching the pump on/off had failed in permanently closed position. In fact relay contacts got welded in on position keeping it on irrespective of on/off indications coming from the controller.

Why did it happen? Simple - pump is an inductive load. Theoretically pump winding offers very low resistance to current flow when the pump is not running - called inrush current. Therefore very high current flows through the windings for a moment until the pump picks up speed. After that current flow through the pump drops to normal running current. Therefore a surge of power flows through the relay contacts when the relay contacts close to switch the pump on. According to some estimates momentary current (ampere-age) when the pump is switched on is up to 10 times the normal running current. Another surge runs through the contacts when switching off the pump because of back EMF (I am not sure whether it holds good for AC motors). These very high momentary currents cause arcing. That can either cause welding or decaying/wearing off of relay contacts. Unfortunately my relay contacts got welded in permanently on position. Fortunately I found it soon, by next morning, before the motor was killed!

What is the solution? Use something to absorb the surge. Either varistors or capacitors or a capacitor/resistor network (suitable values calculated to match the load) called snubber network is used across the relay contacts to absorb the surge. I knew it is needed. But did not use it because I thought relay can handle the surge from my motor because normal running current of my motor is around 3 amps and the relay is rated for 10 amps. Obviously relay rating was not enough, I should have used heavier relay.

Unfortunately I don't have access to much heavier electro-mechanical relays. Instead of heavier relay I could have used a snubber network. But I don't know the inductance of the motor to calculate the snubber network component values. Therefore I decided to try the SSR (solid state relay) I had in my collection. I have Autonix brand SSR rated @ 40 amps. It has a built-in snubber network. I assumed it takes care of some surges at least, though it is not calculated to match the surge from the motor I have. I connected the relay, switched on the pump and the relay failed within few seconds! I had another one. Removed the failed one and connected the new SSR - that survived for several minutes but produced lot of heat. Message on the relay package reads "External heat sink is needed for currents more than 3 amps." I don't like to add a crown (heat sink) on top of my controller. Therefore I dropped the idea of using SSR (solid state relay) for pump controller.

What is next? There are devices called "contactors". These are like relay but much bigger and heavy duty with heavy connector points. I have ordered a contactor online and waiting for it to arrive. Let us see how the contactor does :-)


1 comment:

  1. WOW Ravi garu great solution. Today we were discussing about similar solution in our friends group, found below article before we read this

    https://blog.serverdensity.com/automatically-watering-your-plants-with-sensors-a-pi-and-webhooks/

    ReplyDelete