What's new
  • Happy Birthday ICMag! Been 20 years since Gypsy Nirvana created the forum! We are celebrating with a 4/20 Giveaway and by launching a new Patreon tier called "420club". You can read more here.
  • Important notice: ICMag's T.O.U. has been updated. Please review it here. For your convenience, it is also available in the main forum menu, under 'Quick Links"!

VPD/Humidity controler build low budget (Arduino)

I've been planning this build for a little while and was hoping to get some feedback before I make the next step. Also, if people show interest in this, (& it works) I hope to post this as a how to DIY thread.

For those who don't know what an Arduino is:
It's a circuit board about half the size of a smart phone with a bunch of connector pins. You can plug it into a computer and program it to analyze what's happening on some pins and put out a signal on other pins.
Once the program is loaded it can be removing from the computer and will run the program when it's connected to DC power (you can use a 9v battery or a power adapter).
The programming is done in the language C (I know enough of that to make a light blink, also I can Google and copy paste).
The output pins put out about 5v DC and not much current, so you can't directly power much off it, you need something like a relay for big power.

That was probably a really bad explanation and if you're interested you should Google it or buy a book.

the hardware, mostly from amazon:

Arduino Uno clone ~$10
51ZvSLjTzrL._SY400_.jpg

Arduino relay board (4 relays, 120 vac 10A each ) ~$10
51lydF6k%2BWL._SY400_.jpg

DHT22 humidity and temperature sensor ~$10
41ZEcfZUYmL._SY400_.jpg

Ultrasonic fogger $14
41xQ4Yp02ZL._SY400_.jpg

Soldering iron, wire, heat shrink tubing, other junk ~priceless

The physical setup:
Sensor placed in the canopy in some easily adjustable manner.
Wire running back to control board
Control board hooked to relay board
One relay powers fogger
Other powers fan(s) or dehumidifier

Program:
Sensor readings are put into formula for VPD
If VPD number is too high,
-fogger turns on until VPD reaches lower limit of good
If VPD number is too low
-exhaust box until VPD reaches higher limit of good
Maybe turn on some lights so I can tell what's going on.
Edit: first draft of program on page 3 of this thread, newest version is at the end of this post

What I still need to find /figure out/reconsider:
What VPD is best for canibus and how far out of that is good/okay/fine/could be better/bad
What about at "night"
If I should use the second sensor (maybe average them, maybe to keep track of outside humidity)
The best place to put the sensor
Other stupid things I didn't think about


So any help or suggestions would be great. Feel free to ask questions, hijacked threads can turn into some of the best ones.
Thanks

Edit:
Program newest version as of March 8th:

//VPD Hhumidity Control writen March 3rd, 2017 by Can of Bliss icmag.com, open source, please improve and share
//updated 3/8/'17 with formula from VintageGreen
//This has not been tested!!!!
//For use with a DHT 22

#include <Adafruit_Sensor.h>

#include <DHT_U.h>
#include <DHT.h>
#include "DHT.h" //you'll need the "library" on your computer for this to work
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22
float vpd;
float vpdSetHigh = 12.5;
float vpdSetLow = 7.5;
int vpdHighLed = 12; //pin for low humidity light on
int vpdLowLed = 11; //pin for high humidity light on
int dehumidify = 10; //pin for dehumidify relay
int humidify = 9; //pin for humidify relay
int dehumidifyTimeOn = 5000;//set time on for your system in millisecondes
int humidifyTimeOn = 5000;//et time on for your system in millisecondes
int readDelay = 2000; //DHT 22 (AM2302) can only take a reading every 2 sec

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println("DHTxx VPD test");

dht.begin();

pinMode (vpdHighLed, OUTPUT);
pinMode (vpdLowLed, OUTPUT);
pinMode (dehumidify, OUTPUT);
pinMode (humidify, OUTPUT);
}
void loop() {

float h = dht.readHumidity();
int t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");// Check if any reads failed && exit early (to try again).
return;
}

vpd = ((1-h/100)*0.611*exp(17.27*t/(t+237.3))*10*10)/10.0;

if (vpd <= vpdSetLow){
digitalWrite (vpdLowLed, HIGH);
digitalWrite (humidify, HIGH);
delay (humidifyTimeOn);
Serial.print ("too wet");
}
if (vpd >= vpdSetHigh){
digitalWrite (vpdHighLed, HIGH);
digitalWrite (dehumidify, HIGH);
delay (dehumidifyTimeOn);
Serial.print ("too dry");
}

digitalWrite (vpdHighLed, LOW);
digitalWrite (vpdLowLed, LOW);
digitalWrite (dehumidify, LOW);
digitalWrite (humidify, LOW);
delay(readDelay);
}
 
Last edited:
the DHT22/11 requires 3 wires, V+, GND, and S. May I suggest that the wires you use for the connections be shielded wires to prevent any signal noises that may be emitted by ballasts.

Other than that, if a formula is not found, you can use a series of if else statements and comparable conditions to trigger the switch of the fogger/dehumidifier. I am also still learning about VPD and from what I see, a sophisticated program is probably best due to the fact that temps with light on and temps with light off varies. With that in mind, it may not be possible to have VPD at perfect levels given equipment constraints and it may not be needed to keep VPD at perfect levels as you can fall into an acceptable range.

GL and let us know how it goes
 

touringfunkband

Active member
Subbed.

I found this thread after searching for VPD and Arduino as I have been interested in setting up a system to control VPD after seeing a Raspberry PI>Arduino setup used for controlling the brewing temperatures for a friends home brew. I was told the program he is running logs the temperature and then activates a relay with a reptile heater to warm the keg if needed and a refrigerator to cool the keg if necessary. Love to see your setup if you are continuing with the process.
 
i should mention that that chart probably isnt specifically for cannabis but it might apply to most or all plants. also, VPD calculations should remain the same regardless of day or night. only affect day or night might have is if our lights are on which would affect temperature which would call for a specific humidity
 

Loc Dog

Hobbies include "drinkin', smokin' weed, and all k
Veteran
Would a raspberry PI be the same as the Arduino?
 

DelTaco

Member
Great idea, I'm subbed.

Edit - not sure of the ins and outs of an arduino but why stop at controlling just vpd? Could you program it to control other growroom environment variables such as temperature, ventilation, or co2?
 
Last edited:

caljim

I'm on the edge. Of what I'm not sure.
Veteran
There is a member here by the name of Ravenboy that has been running and Audrino set up that controls vpd in relation to his canopy temps using an ultrasonic fogger.

Great thread, I would like to build one myself.
 
Sorry I haven't updated this. A few other projects have been taking priority right now.

I ended up writing the program in a very crude, time consuming way. I failed to get the proper formula for VPD to work in the program. There are some very small numbers, like 10^-11, that were getting rounded to zero. So I wrote it off the chart i.e.
if temp is 20C and humidity is under 60% it's too dry, if it's over 67% it's too humid. If temp is 21C....

I actually wrote it so there was several stages "vpdLow", "vpdOkayLow", "vpdOkay", "vpdOkayHigh", & "vpdHigh". I then gave each a pin to turn on for an indicator LED. My thought was that it would give more options as to when things kick on and turn off.

After fixing about 600 typos, it loaded. It runs, but I'm having a bug where multiple LEDs light at various humidity levels. It might be my sloppy bread board setup, the program, or the cheap arduino clone board I'm using. I haven't gotten around to that step, hopefully tomorrow.
 
i should mention that that chart probably isnt specifically for cannabis but it might apply to most or all plants. also, VPD calculations should remain the same regardless of day or night. only affect day or night might have is if our lights are on which would affect temperature which would call for a specific humidity

Do you have a source for the lights out vpd thing? I was under the impression that the benefit of a proper VPD was primarily keeping stomata open (and they close without light regardless of humidity).
 
the DHT22/11 requires 3 wires, V+, GND, and S. May I suggest that the wires you use for the connections be shielded wires to prevent any signal noises that may be emitted by ballasts.

Good idea. I hadn't though of that. I probably won't do that, but if things act up, that'll be one of the first things I test.
 
Would a raspberry PI be the same as the Arduino?

Nope, but a Pi would probably be better (and use the same program and sensor). A lot better if you want to do logging. I've never played with one, but when I've got an extra $35 I'm definitely buying a Raspberry Pi.
 
Great idea, I'm subbed.

Edit - not sure of the ins and outs of an arduino but why stop at controlling just vpd? Could you program it to control other growroom environment variables such as temperature, ventilation, or co2?

One thing at a time. I don't know what I'm doing, I just pretend to on the internet.
 
One thing at a time. I don't know what I'm doing, I just pretend to on the internet.

One thing at a time is a good idea. Coding gets exponentially more complicated when trying to do many things. The price of an arduino is dirt cheap. I have 2 arduinos working. One controls the relays to power things on/off. The other has the environment sensors connected. They both send or receive data from a mysql database thru PHP scripts running on a linux server. PHP scripts check the environmental data in the database, checks the schedule in the database, and determines is something should be turned on or off. The linux box is also a web server which allows viewing of the data, changing the schedule of things from a web browser and send text messages if a limit is exceeded.

I plan on a couple more arduinos. One for testing new code while keeping the other working. And another dedicated for security functions.
 
Subbed. I'm using a Particle Photon and a soil moisture sensor from Catnip electronics to control my auto-watering system. Looking at adding humidification as it's super dry right now.
 

epicseeds

Member
I have yet to see a VPD controller on the market under like $1k - they are usually for greenhouses. I have a Pi and watching closely.

It's the coding part that is going to take the most skill. So hopefully some smart coder comes along here.

EDIT: I have just put up a bounty on a freelancer website - willing to throw some decent money on just the software. If anyone knows a good coder please PM me.
 
Last edited:

Latest posts

Latest posts

Top