How to use Vegetronix soil moisture sensor (VG400) on Arduino
15.2 years ago arduino, moisture sensor
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 Serial.begin(9600); }void loop() { Serial.println(analogRead(0)); 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.
Tags: arduino, cheap, growbox, led, outdoor plants, vegetables
15.2 years ago
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!
15.2 years ago
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
10.5 years ago
The control you use will be the deciding factor. With a motor, their is an inductive kick on both startup and shutdown. This means that the switch you use should be horsepower rated, unless it is a very low (sub fractional horsepower motorlike the one you describe) current draw. A cheap arduino could be used for control with a relay for switching the power. I’ll dig into it, but in the mean time, try doing a search on arduino motor control. If the pump gets switched on and off frequently, then a solid state relay would be a better choice than a mechanical relay. If you see something that looks interesting, I’ll sketch up a schematic for you. I used to design control systems for various industries, and I have also taught electronics in a past life.
15.2 years ago
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.
15.2 years ago
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 …
15.2 years ago
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.
15.2 years ago
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
15.2 years ago
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
15.2 years ago
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
15.2 years ago
P.S. ordered an Arduino and parts to try http://www.make-digital.com/make/vol18/?folio=90
15.2 years ago
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…
15.2 years ago
Hi,The Vegetronix sensor is a very nice solution. There is also a more consumer packaged version available here: http://www.waterstik.com/Main.php?do=homeThere is a nice comparison between different types of soil moisture sensors here: http://edis.ifas.ufl.edu/AE266I 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: http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp 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:http://hulk.bu.edu/pubs/papers/2007/TR-05-02-2007.doc
James H Thompsonjht@lj.net
15.2 years ago
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
15.2 years ago
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.
15.2 years ago
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 Thompsonjht@lj.net
15.2 years ago
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
14.7 years ago
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.
14.7 years ago
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.
14.5 years ago
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?
14.5 years ago
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.
14.5 years ago
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 greenhouse.com. 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.
14.5 years ago
[…] (10K resistor and homemade soil sensor) or Vegetronix soil sensor […]
14 years ago
can I know what formula to get the value (0-614)=(0-3V) can somebody tell me.
Thank You
14 years ago
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
13.9 years ago
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?
13.8 years ago
Great resource. I can’t wait to try some of these ideas out via arduino.
13.8 years ago
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.
13.7 years ago
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.
13 years ago
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 🙂
12 years ago
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.
12 years ago
Hola a todos, una consulta, se puede conectar VH400 a la tarjeta WASPMOTE de Libelium. GrACIAS
11.9 years ago
[…] If the Vegetronix name sounds familiar, I use their moisture sensors in my grow box which I wrote here. […]
11.9 years ago
[…] If the Vegetronix name sounds familiar, I use their moisture sensors in my grow box which I wrote here. […]
11.7 years ago
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.
thanks
11.6 years ago
[…] (10K resistor and homemade soil sensor) or Vegetronix soil sensor […]
8.1 years ago
To get better resolution I had thoughts why not to use internal 3.3V regulator for reference. By doing this you will lose only 10% resolution compared to 3.0V reference.
Connect 3.3V output to AREF and then call analogReference(EXTERNAL)
In this case you should get the sensor voltage with this:
float sensorVoltage = analogRead(0) * (3.3 / 1023.0);
“3V3 pin: A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.”
“AREF pin: The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.”
To get even better resolution you can connect 3.3V output to AREF through 3.2kΩ resistor giving exact 3.0V reference. (Closest in E12 series is 3.3kΩ => 2,991501416V reference)
“You can connect the external reference voltage to the AREF pin through a 3.2K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 3.3V applied through the resistor will yield 3.3 * 32 / (32 + 3.2) = 3.0V at the AREF pin.”
In this case you should get the sensor voltage with this:
float sensorVoltage = analogRead(0) * (3.0 / 1023.0);