Arduino Greenhouse

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
BK1981
 
Posts: 13
Joined: Thu May 03, 2012 8:40 pm

Arduino Greenhouse

Post by BK1981 »

Hi, everyone. I'm a student at Fab Academy building my final project, which is a press-fit acrylic greenhouse with an Arduino-controlled irrigation and vent system. I am looking at using the AM2302 temperature and humidity sensor, but am worried about running it along with a servo (for the convection vent) and solenoid water valve off the Arduino; I've been advised that the temp/humidity reading loop might conflict with the servo control script. Thoughts?

tfunk10258
 
Posts: 5
Joined: Mon Mar 05, 2012 2:36 am

Re: Arduino Greenhouse

Post by tfunk10258 »

I suppose that depends on what you mean by conflicts. That sensor is very slow for reading from, roughly 250ms per read (temp and humidity) which means if you call a read of both, it will take roughly 500ms, time during which your arduino can't be doing other things. Depending on what else you're trying to accomplish, this may or may not be workable.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Greenhouse

Post by adafruit_support_bill »

I would not expect that your control loop timing constraints would need to be all that tight for a greenhouse application. Temperature and humidity don't change all that fast. And even if they did, you would not want to be opening and closing vents and valves every few seconds.

The only way I could see that it would interfere with servo timing would be if you were trying to do the servo PWM in software. If you use the Servo library, there is not need for critical servo timing in your code.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Arduino Greenhouse

Post by adafruit_support_mike »

On the software side, you'll probably have the best luck with a fairly slow polling loop that uses the Arduino's millis() function:

Code: Select all

void loop () {
    unsigned long startTime = millis();
    unsigned int temperature = readTheTemperature();

    if ( thisTempNeedsChanging( temperature ) ) {
        adjustTheVentsFor( temperature );
    }

    unisgned int humidity = readTheHumidity();

    if ( thisHumidityNeedsChanging( humidity ) ) {
        adjustTheIrrigationFor( humidity );
    }

    unsigned long currentTime = millis();

/* make each pass through the loop about 5 min long */
    while ( 300000 > (currentTime - startTime) ) {  
        delay (1000);
        currentTime = millis();
    }
}
As long as your total loop time is longer than your longest possible sensor/servo times, you won't have to worry about collisions.

You will need to protect against overflow conditions from millis() if you intend to run the controller for a long time though. The clock counter rolls over about every 50 days.

BK1981
 
Posts: 13
Joined: Thu May 03, 2012 8:40 pm

Re: Arduino Greenhouse

Post by BK1981 »

Thanks, guys.

I've received the 2302 and am attempting to connect to it through my fabbed Arduino. I was previously successful in burning the bootloader through a FAB ISP and loading example sketches, but it's now giving me an ""avr-gcc: CreateProcess: No such file or directory" error.

I've tried the steps listed here (http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1238257341) with no joy. Thoughts?

B

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”