Seeking guidance for an automated greenhouse misting system

Hello

I am looking to create an automated system or misting my greenhouse. Although I am new to arduino, it appears that this will be the most versatile approach to doing so, as no off the shelf products can offer what I need of them.

My project will be a misting system controlled by a solenoid valve, which will be intermittently activated upon three parameters: daylight, outside temperature and outside humidity. Rain sensing is not required as it is under cover.

I have seen projects similar to this but they function like a thermostat, activating the solenoid continuously until a threshold is reached.

I intend for the misting system to activate only intermittently for a set duration of 5 seconds, but with the rate variable - increased when temperature increases, and decrease when the humidity increases, and stop when a light is not detected (at night), vice versa.

Ideally this would result in the mister being activated very frequently in hot dry conditions, and minimally when the conditions are cold and wet - but still for only 5 second bursts at a time.

Ultimately I am asking if anyone is aware of projects that use multiple inputs to determine the frequency of solenoid/output activation.

I imagine this would require some mathematical equation to combine the effect of temperature and humidity to create the interval for solenoid activation - but I have not seen this before in any projects I have browsed.

I do not have extensive knowledge of arduino so far, but plan to invest time and learn along the way and consider myself capable to do so.

If anybody could point me in the right direction in terms of existing projects that may be of use, please do so.

Hello
Do you have a schematic and a program flow chart?

So the code for activation of the mister is going to be fairly simple. Assuming it's connected to a digital pin, set it High, delay 5 seconds, set it low.

As for often you run that that code think about the parameters. First one is the light sensors, is it day or night? Look at the values the light sensor will give you and decide which of these constitutes day and night. Evaluate that first, because essentially in your case its binary, its either day or its night and if its night there is no point looking at the other values.

Then for the other two evaluate in turn. What causes and activation? Let's say if humidity is less than 40% and temp greater than 10c. So ready the values and if they are both true, activate the solenoid. Whilst it's running you don't want to be evaluating the parameters any more so think how you can pause the main loop whilst it runs, while loop, delay etc.

Last thing you want to think about is how often you want to check the variables, and configure a timer or delay to only check them on that interval.

Last thing I would say is hot and humid environments is not the first choice for a circuit board so look for an IP67 or even 68 rated project box to keep it in

You should be able to find plenty of projects that read temperature and humidity and light level. Plenty of others that trigger a solenoid.

I suggest that you get the appropriate parts for those and write a little program for each component. Once you can control your hardware combine them one by one.

Then make a system that mists every fifteen minutes. After that you can figure out how to vary the fifteen minutes. It'll be a learning experience I suspect, so there's not much need to nail it down at the beginning.

One thing to consider is whether the misting will cause your sensor readings to be off for a while afterwards. You may want to ignore all of them for some time once misting is over.

I think I have attempted to ask for too much at once - i will start by testing myself by coding and creating each part of the system in isolation before being so ambitious.

For now I wish to create a system that turns a LED on for 5 seconds every x amount of time, which is dependant on temperature

as the system will seldom be edited, i think the easiest approach would be to have set parameters for every 1 degree temperature range.

e.g. if temperature = 20-21c the interval will be 10 minutes
if 21-22 interval of 9.5 minutes
etc..

I will for now work on my coding ability and return.

Thank you all for the help in guiding me so far

Good idea. Knowing your ultimate goal is important, but getting there in small chunks is often a very effective strategy.

for what it is worth i have since learned some coding and produced the following to automate a relay that activates a solenoid water valve

the temperature and humidity are read by a DHT22 sensor
an equation that relates temperature and humidity is used to define the delays between misting cycles, that can be adjusted using a potentiometer
the misting duration is set via code by can be adjusted from 1-10seconds with a potentiometer
If the temperature drops below 20c the solenoid is not activated and no misting will occur
I am in the process of adding the day/night sensor to the code and will do so in time

This is yet to be tested as I am waiting for some parts to arrive, i will report back when they do

//Libraries
#include <DHT.h>

//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht = DHT(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino

//Variables for potentiometers
int pot1Pin = A0; // the pin that reads potentiometer 1 (controlling duration of relay activation)
int pot1Input; // variable that stores the output of the potentiometer
int pot1; // pot1 percent value
int pot2Pin = A1; // the pin that reads potentiometer 2 (controlling duration of delay after relay activation)
int pot2Input; // variable that stores the output of the potentiometer
int pot2; // pot2 percent value

//Variables for DHT22 temperature + humidity sensor
int chk; //i dont know what this is for? - left it in as it was found in all DHT22 code online but cannot see it referenced to below
int temp; //Stores humidity value as integer
int humi; //Stores temperature value as integer

// Variables for the calculated delays
int maxtemp; //temperature where maximal relay activation is met
int mintemp; //temperature where relay activation = 0
int relayon;
int relayoff;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //sets the baud rate

//output to relay
pinMode(11,OUTPUT);
}

void loop() {
delay(2000); //Delay to read data and store it to variables - DHT22 can take up to 2 sec to do this - ,this might not be necessary probably delete it

//Potentiometers
pot1Input = analogRead(A0); // sets the variable to equal the input of the specified pin
pot1 = (float)pot1Input / 1023; // convert analog value to fraction
pot1 = pot1 * 100; //convert fraction to percentage
Serial.println("Mist level: ");
Serial.println(pot1 / 10);

pot2Input = analogRead(A1); // sets the variable to equal the input of the specified pin
pot2 = (float)pot2Input / 1023; // convert analog value to fraction
pot2 = pot2 * 100; //convert fraction to percentage
Serial.println("Interval level: ");
Serial.println(pot2 / 10);

//DHT22 temperature + humidity sensor
temp = dht.readTemperature();
humi = dht.readHumidity();
Serial.println("Current temperature: ");
Serial.println(temp);
Serial.println("Current humidity: ");
Serial.println(humi);

//calculate the delays
maxtemp = 50;
mintemp = 20;
if (temp < mintemp) {
relayon = 0;
}
else if (temp >= mintemp) {
relayon = pot1 * 100; //relay on duration = pot1 percent value * 100msec = range from 0-10 seconds duration
}
relayoff = (maxtemp * maxtemp) - (temp * temp); // formula for relayoff = ((maxtempmaxtemp)-(temptemp)/humi)*(pot2/10)
relayoff = relayoff / humi;
relayoff = relayoff * (pot2 / 10); //pot2 value changes duration from 0-10x the value of the above formula, average weather conditions of 21c and 57%RH = 36.12sec duration, range = 0-361 sec depending on pot2 value
Serial.println("Mist duration: ");
Serial.println(relayon);
Serial.println("Interval duration: ");
Serial.println(relayoff);

//activate relay
digitalWrite(11,HIGH);
delay(relayon);
digitalWrite(11,LOW);
delay(relayoff);

}

Please edit your post to add code tags.

The first post of every forum shows how to post code in a format condusive to reading.

pencil your post
Then highlight the code
Then hit </>