How to use Vegetronix soil moisture sensor (VG400) on Arduino

With the summer starting to come to a close it has been time for me to start thinking back to the computerized grow box.  I have been doing some considerable work on the electronics and software over the summer.  Better to break stuff while the plants are outside and not while killing them inside.

Though I have been happy with my homemade gypsum soil sensors I decided to try out a commercial option hoping for better accuracy and longer life.  This is important with my current plans to include automatic watering to the latest version of my grow box.  Don’t want to wake up to a flood in the garage due to a broken sensor.  After some looking I came across the Vegetronix VG400 which measures the dielectric constant of the soil using transmission line techniques.  Which I have no idea what that means but sounds impressive.

The hookup couldn’t be simpler, red wire to 3V, bare wire to ground, and black wire to an analog input.  As you can see below in my completely not to scale diagram below.


From here it all comes down to some simple code to write on the Arduino to get some values.

void setup()
// Setup serial
}void loop()

delay(200);  // wait 200 milliseconds

Upload the code to the Arduino and now I can get a moisture value from the analog input between 0 and 614 (0-3 volts) depending on the degree of water saturation.


Though not as hacky as my PS2 controller moisture sensor solution definitely more elegant and reliable.  Stay tuned for more details of other improvements to the computer controlled grow box.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  1. Have you had problems with your homemade gypsum soil sensors? How long do they last? Why do they break down?I was thinking of making some of those, so I was wondering what problems you encountered.Thanks for your informative articles!

  2. Cheap Vegetable Gardener, what a great resource you have created here. I am not nearly as techie as you, but I am searching for a "cheap" way to turn a 115v 1.3 amp submersible pump on when soil is dry and off when the soil is saturated. It sure looks like you have the solution here, but I am searching for more of a layman's explanation of how to make it happen ("insert tab A into slot B"). Probably too much of an imposition, but could you post such a thing? Again, probably too much to ask, but I thought would try…Cheers,Hank

  3. Anonymous, actually they have been pretty durable and unless you move them around a lot they should last for at least six months. The problem is their property of being porous is the reason they will slowly breakdown after repeated submersion in water.Hank, stay tuned will be including a write up of my latest version of my computerized grow box which may not be completely "insert tab A into slot B" but should be pretty basic.

  4. Thanks so much TCVG, your generous sharing of ideas is really super…In the meantime, I may try theVG400 and the VG-RELAY-DC from Vegetronics … not that i really know how to connect it all up, but I may get lucky …. if I can make it work, and if its of any interest, I'll post results …

  5. Hank, I should have thought of that. I haven't tried the VG-RELAY-DC but definately looks like a good programmingless solution. Just hook up the 3 sensor wires, + and – from power supply and split the cable to the pump (or better yet use a $2 extension cord from Home Depot.

  6. Excellent … thanks s much for the feedback … I ordered a sensor and a relay yesterday … will report back … I guess I just need to add a 12VDC power supplyI would really like to try my hand at the Arduino solution at some later date…Cheers,Hank

  7. Hank, would love to hear how it works out for you. Arduino is actually pretty easy once you get past the initial learning curve. Though if you want to plug in it and be working relay sounds like a good option

  8. Vegetable Gardener, received sensor and relay from Vegetronix. I think it will work very nicely for me: all I wanted to do right now was to turn my submersible pump on when soil is "dry" and off when "wet" and it seems to do exactly that. I tested it with the kind of wet and dry conditions I expect to see and adjusted the sensitivity on the relay board to get the on/off where I wanted it. Works beautifully. Easy to setup, even for me. Continuing thanks for your help..Cheers, Hank

  9. Hank, did you see the garduino kit? I believe it is the same as the article you mentioned, though not sure how safe the 120V that close to the arduino…

  10. Hi,The Vegetronix sensor is a very nice solution. There is also a more consumer packaged version available here: is a nice comparison between different types of soil moisture sensors here: think you could make your own sensors that measured the soil Dielectric constant, and thus soil moisture — see the project link below.I've tinkered with the idea of combining a moisture sensor like the Vegetronix with a wireless interface — for instance the xbee: It should be possible to program it so that it only wakes up a few times a day to report readings, so a battery would last a long time.Here is a paper that describes a project that did something similar:
    James H

  11. That's wonderful information, James. the Waterstik looks similar to the Vegetronix VG400, except better looking of course. too bad it doesn't have a little port to output to something like the Arduino …What do you think of the WiShield, combined with Arduino of course, as a potential wireless moisture monitor/control system? Could it be made relative easy for a neophyte such as myself? I don't think the wireless/net interface is absolutely necessary for my app, but it would be very cool!Cheap Vegetable Gardener, unfortunately, I missed the Garduino kit information – I ordered the parts individually. The kit would have been nice… maybe for my next one.Cheers,Hank

  12. I guess while we are at it should also mention Botanicalls Plant Twitter Kit which as the name sounds twitters you when you plants need watering.Though I haven't finished my latest version thoughts of a wireless grow box controller has defiantely been a consideration. As for Hank's question I am pretty sure there are enough example code out there you probably could do the wireless/networked solution shouldn't been too difficult.

  13. The WiShield is a really nice solution and would be simpler than using a zigbee based solution.But it depends on the scale of deployment, for one sensor its a great solution, but as the number of sensors goes up zigbee would be more economical.James H

  14. Hey Guys,I was able to get a webpage up that reports on the moisture content, light and air temperature of my garden. I used the WiShield and the included SimpleServer software(for simple people like me).At the moment I enter a local IP address on my LAN and the page serves up great. I did have a problem because my dlink router was an unreliable connection, but it works great on my linksys router.I hope to add ph reporting and maybe a way to be able to view the local IP address on the WAN, if I can figure that out.I love your Tweet application, Cheap Vegetable Gardener. I hope to try that out once I have time and how to incorporate your code into the my SimpleServer sketch. Cheers,Hank

  15. I wonder if you could drill some tight holes into a piece of terra-cotta? Terra-cotta is porous, allowing water to seep into it, but definitely does not break down quickly since its used for flower pots all the time.

  16. Chris, completely depends if terra-cotta conducts electricity when wet…I am thinking given ceramics were commonly used as insulators for telephone connectors probably not, but if you have a broken pot lying around probably worth a try. Let us knwo if it works.

  17. A query – if the plaster of paris finally breaks down after 6 or so months. How will the soil be affected? I plan to use it in my balcony pots, but am wondering if my soil, and finally my plants would be adversely affected by the broken plaster crumbling in the soli?

    • saurabh, what will normally happen is it will corrode away somewhat and then eventually fail. Where a majority of the materal will be intact just broken away from the metal probes. As for the amount that washes into your soil, this sediment should be minimal and will also provide a little calcium to your soil. I have heard of people using plaster of paris as a calcium supplement, though I personally would recommend sticking with bonemeal and/or egg shells.

  18. TCVG: I sent you an email the other day telling you that I am building the same sort of unit and maybe we can share ideas. I am not as far along as you are, but I figure in a week I will have temperature sensing and control, and I am in the process of implementing a misting system using poly mist nozzles I found at little I have the circuit design for heating the grow box but I can’t decide on what kind of heating element to use. I have thought hard about using the EASYHEAT HB Series Freeze Protection Cable, Pipe Heating System. If you want to coordinate and share ideas let me know.

  19. Pingback: How to make a grow box controller

  20. can I know what formula to get the value (0-614)=(0-3V) can somebody tell me.

    Thank You

    • The values are linear so it comes down to 614 moisture value per 3 volts or 614/3 = 204.6. Now you simply multiply this by your voltage reading.

      For example if you are reading 2.89 volts:

      moistureValue = 2.89 * 204.6
      mositureValue = 591.49

  21. Thanks a lot for the info. I really appreciate it and now my project done well. I can make the LED blinking followed the condition of the soil. I want to make water pump as well. Do u have any link which I can refer to?

  22. Great resource. I can’t wait to try some of these ideas out via arduino.

  23. I’ve successfully gotten various 168-based Arduinos to measure moisture off of Vegetronix VH400 sensors and transmit the data over XBee (XBee communication is easy so long as you have compatible XBees). I am currently using a Seeeduino Stalker v1.0 (Arduino 168 clone with build-in Bee, RTC, and Micro-SD logging support) which is currently timestamping my data, converting it from voltage to volumetric water content, and changing the color of an attached BlinkM LED to from red to green based upon voltage. I still have some improvements in mind:

    1. Addition of controls for a solenoid valve so I can use this to control irrigation outdoors. Any suggestions for a battery-powered one?
    2. Find a good outdoor enclosure.
    3. Add in datalogging functions. While this shouldn’t be an issue on 368-based Arduinos, they are an issue with 168-based ones due to RAM limitations (I suspect the library I am using, SDFat V2, takes up too much RAM, but it’s the only one I can get to work properly).

    I can upload my code if anyone would like- it contains the calibration curve for the Vegetronix VH400 sensor.

  24. Hi TCVG, Great little system you have here!!! Thanks!
    Dr. Guy, it would be great if you could upload your code. I am trying to make a wireless VH400 also.

  25. Nice try with the gypsum blocks! Very creative.

    About the vegetronics sensor:
    I bet this sensor is nothing more than an LC oscillator with variable capacitance, where the 2 traces act as a capacitor explaining the “transmissive line technology”. Add a RC filter in the end and you will have a DC voltage depending on the amount of water.

    I see the top is not more than a click system, can you open one up and make a picture? I’m really wondering if I am right :-)

  26. Dr. Guy: If you are still around (not likely I know), do you have that code for the VH400? I am making the exact same thing for my use and would be very much obliged.

  27. Hola a todos, una consulta, se puede conectar VH400 a la tarjeta WASPMOTE de Libelium. GrACIAS

  28. Pingback: Indoor gardening with 2 liter bottle and USB LED light

  29. Pingback: Indoor gardening with 2 liter bottle and USB LED light - The Cheap Vegetable Gardener

  30. I’ve just integrated the VH400 sensor (2 of them) with the PanStamp wireless arduino clone. Would be interested in seeing your code, as I’m having some inconsistent data logged.


  31. Pingback: How to make a grow box controller (Original) - The Cheap Vegetable Gardener