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 :-)


Sunday, April 3, 2016

Power backup

I am living in a village after deciding to move out of city and buying the farm. Apart from being a farmer, I am still a software architect too. Every day I spend almost half a day on software projects. Therefore I need reliable electricity supply. Being a village there are some challenges for electric power. This post provides information about how I solved the problem. Please note - I don't have any affiliation or any relationship whatsoever to any brands I mention in this post. I am describing what I did to solve my problem hoping that will help someone with similar challenges.

As you know cities get major share of electric power. Villages are the most neglected places by the power sector. We have 6 hours scheduled power shutdown in this village. Apart from that power may go and return at any time - that is unscheduled. Mains voltage may vary anywhere between 170 to 240 V. Electric power is unreliable here. That is why I need a power backup. I ended up buying a lead acid battery backed inverter for power. General tendency is to buy some inverter and battery combination recommended by the dealer. Some dealers push whatever is best for them (who pays them more commission), not for the customer. Therefore I did my home work to decide which one to buy.

When it comes to large storage battery for the inverter currently available options are lead acid battery and Nickel Iron battery (also called as Ni-Fe battery or Edison battery - named after the inventor Thomas Edison). Almost all the batteries you have seen in an inverter installation are lead acid batteries (either a flat plate battery, tubular battery, tall tubular battery, absorbed glass mat or gel). Lead acid batteries are very toxic; both lead and sulfuric acid in the battery are toxic substances. Lead acid batteries need lot of careful maintenance and don't last more than 5-6 years even with best maintenance. Compared to this Nickel Iron batteries are less toxic and last really long. Frequent deep cycling does not damage Nickel Iron batteries. Nickel Iron batteries can last several decades. There is a study done on almost a century old Nickel Iron batteries indicating they are still working well! Looking at that Nickel Iron battery is the winner. But there are challenges in using Nickel Iron batteries. Lead acid and Nickel Iron battery charging and discharging characteristics are very different. All our mass market equipment are designed to run with lead acid batteries, not Nickel Iron batteries. Therefore if I decide to use Nickel Iron battery I will have to design and fabricate a special inverter for working with Nickel Iron battery. Another challenge with Nickel Iron batteries is difficulty of sourcing them. There are very few manufacturers and sellers of Nickel Iron batteries because of low demand. It will remain a maintenance nightmare even if I import few pieces of Nickel Iron batteries. Therefore practically only viable option was only one - some kind of lead acid battery. Tall tubular type is the choice out of flat plate, tubular, tall tubular, gel, and absorbed glass mat type lead acid batteries because tall tubular are the most widely used ones. My goal now is to make sure this battery I buy lasts as long as practically possible so that I don't need to throw another 15-20 thousand rupees for another heavy box of toxin [ unfortunately that is what a lead acid battery is :-( ]

Once it was a given that I have to live with a tall tubular lead acid battery I had to find an inverter which does the best job of charging the battery for longest battery life. I had a 6 year old Su-Kam brand Sturdy-i model inverter. This inverter has served me well so far. However this inverter does not consider fine variations between different lead acid battery types charging and discharging characteristics. Therefore it cannot maximize the battery life.

Another challenge is battery charging voltage vs. battery temperature. As the temperature rises battery electrolyte becomes more conductive. Therefore lower charging voltage should be used at higher temperatures and higher charging voltage should be used at lower temperatures. Any inverter not taking battery temperature into consideration for charging the battery will under charge the battery in winter and over charge the battery in summer. Both are damaging to the battery. That shortens battery life. Since my goal was maximizing battery life I wanted my inverter to adjust charging voltage according to battery temperature.

Once my requirements were clear, I spent some time on Google. I zeroed in on Su-Kam brand Falcon+ model inverter. Falcon+ has several innovations in it. You can set it to flat plate, tubular and tall tubular batteries to consider battery specific characteristics for charging/discharging. It also differentiates between a small size battery and large size battery (VA rating of the battery). Best thing about this inverter is - it reads battery temperature to decide battery charging voltage. This inverter also has ability to play well with solar charge controllers. I am planning to go completely off-grid when I build my farm house. This inverter implements 6 stage charging technology (de-sulphation, soft start charging, bulk charging, absorption charging, equalization, and float charging) controlled by a microprocessor. I believe this is the best inverter technology available in India at this moment. I have couploed a 200 AH tall tubular battery (60 months warranty) to this inverter. This gives me more than one full day autonomy for one wireless router, a desktop with LED monitor, 2-3 10-15 W LED bulbs (only in the evening), and 2-3 hours of a DTH receiver & 34 inch LED TV.