Soil Moisture Sensor with Arduino, XBee and Node-Red

IMG_0266I have planted some chilli seeds and I am supposed to keep them moist, only trouble is I am rubbish at remembering to water my plants. I bought three cheap soil moisture sensor kits off ebay and hooked them up to an Arduino. The Arduino has an XBee shield and sends messages to my Raspberry Pi over a Zigbee network. The Pi is running Node-Red on node.js. When the soil moisture goes above a certain threshold it sends a message via Prowl to my iPhone. 

IMG_0271Everything worked fine for three days then the sensors failed and I was continually receiving prowl alerts. Thank heavens for iOS "Do Not Disturb" otherwise I would have been woken up by constant alerts! It turns out that putting a continuos DC current through moist soil causes electrolysis on the soil moisture probes. One probe on each sensor had lost nearly all it's conductive coating. Apparently the only real solution to this problem is to use AC current, swapping polarity across the probes at regular intervals. I can't see how that is possible with my soil moisture kits so I have now redesigned things so that the sensors are only powered up for a second every 30 mins to take readings. According to my calculations the probes should last about 10 years this way - that should be long enough for my chillies to grow. 

Assuming I can get this working, the next step will be to connect up 1 or 3 small water pumps to automate the watering. Although I think I might wait until the seedlings are big enough to put outside before I start spraying water all over the place in-doors.