Arduino Greenhouse
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 13
- Joined: Thu May 03, 2012 8:40 pm
Arduino Greenhouse
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?
-
- Posts: 5
- Joined: Mon Mar 05, 2012 2:36 am
Re: Arduino Greenhouse
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.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino Greenhouse
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.
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.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Arduino Greenhouse
On the software side, you'll probably have the best luck with a fairly slow polling loop that uses the Arduino's millis() function:
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.
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();
}
}
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.
-
- Posts: 13
- Joined: Thu May 03, 2012 8:40 pm
Re: Arduino Greenhouse
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
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
Please be positive and constructive with your questions and comments.