你是否有想實現(xiàn)的下列之一的功能:
收到警告(警報聲、短信等)并去給植物澆水?
一段時間后(通常是幾天),計時機器會倒一些水。也許你的工廠當時不這樣做!
完全依賴濕度傳感器。大錯!局部濕度可能會誤導鍋的平均濕度!
您的設備正在監(jiān)控植物,在需要時澆水。您只需不時訪問它,并在需要時重新填充水容器。
這個項目中選擇了最后一個選項。
這是顯示含羞草表情符號的中央單元:快樂 :) 正常 :| 或不滿意 :( ,然后是土壤濕度 (%)、自上次抽水以來的天數(shù)和小時數(shù)。當然,您可以使用任何其他顯示器。這個顯示器是從另一塊板上重復使用的 (Pololu A-Star Prime)。
濕度傳感器
它是一種基于電阻率的傳感器,不會被腐蝕。如果您每次只打開幾毫秒的電源,剛好足以讀取濕度,它就可以正常工作。正好我展示的這個,也工作了多年,沒有任何腐蝕跡象。只需使用附帶的軟件。
但是可能會出現(xiàn)其他問題:濕泥附著在傳感器上,因此表明局部濕度與其余部分不同!同時如果傳感器離水管太遠,讀數(shù)會有很大的延遲:需要水在鍋中擴散所需的時間。把它放在離水管較近的地方停止抽水,以免水分太多。根據(jù)您的工廠要求更改軟件中的濕度閾值。這個抽水低于 95% 的濕度(在用我的含羞草做了一些測試后,我將此閾值更改為 75%),持續(xù)一定的秒數(shù),具體取決于底池大小。然后,在讀取時間(10-15 分鐘)之后,如果指示的濕度沒有超過閾值,則泵送新的水量,但迭代次數(shù)有限。
這種方法可以讓水有時間在鍋中擴散。在給定的時間間隔(8-12 小時)內只允許澆水兩次,以避免在擴散之前灑水,避免一些可能的傳感器臨時錯誤。建議每隔幾個月重新校準濕度傳感器:在軟件中調整閾值:傳感器在空氣中的值(0% 濕度)和傳感器短路的值(100% 濕度)。
作為微控制器,我們建議使用 AtTiny85:它有必要的 IO 引腳,剛好夠用,并且相比其他微控制器便宜。
整個設備(包括泵)由 220V 電??源適配器持續(xù)供電,提供 9V/0.5A。如果發(fā)生電源故障(希望持續(xù)不到幾天,否則植物會變干!),這不是問題。如果需要,系統(tǒng)將重新啟動,讀取濕度和抽水,然后將重置小時和天數(shù)計數(shù)器。
為泵供電由 Mosfet 模塊完成,但也可以通過其他方式(例如繼電器)完成。顯示器可以是任何其他帶有 I2C 接口的顯示器。這個有一個并行接口,所以需要一個I2C適配器。
使用一年后
該項目的運行時間超過 18 個月。不過有一次,突然遇到濕度傳感器停止工作的情況。幸運的是,在此期間并沒有什么和濕度有關的環(huán)境需求,該軟件每 2 天抽一次水。現(xiàn)在它已被替換并且一切正常。
注:必須在代碼中測試和設置新的濕度閾值,從 95% 到 75%!產(chǎn)品和土壤鹽度的可變性!
Arduino code for Attiny-plant-care:
/* Sketch for ATtiny85. Based on the Digispark (Use Digispark Default 16.5 MHz), no port select.
* Compile, Upload and then coonect ATtiny85 to USB.
* {ATtiny85 alone pins: 1=PB5, 2=PB3,ADC3, 3=PB4,ADC2, 4=GND, 5=PB0,MOSI,SDA, 6=PB1,MISO, 7=PB2,SCK,SCL, 8=VCC}
* ATtiny Pin 5 = PB0 (P0 on ATTiny board) = SDA
* ATtiny Pin 7 = PB2 (P2 on ATTiny board) = SCK=SCL
* ATtiny PB1 = to SWITCH power of a POLOLU MOSFET: power the Pump (6-12V)
* ATtiny PB3 = Humidity sensor output= analog read
* ATtiny PB4 = Power for the sensor (pin: 20mA = sufficient)
* Uses 26 mA for CPU, Sensor + Mosfet on + Display
* Uses 20 mA for CPU + Display (between readings)
* Uses 8 mA in deep sleep (Display on only)
* Between reads: deep sleep. Protection against over-watering by humidity sensor.
*/
#define LED_BUILTIN PB5 // Change PB5 to PB1 only for testing delays
//This runs each time the watch dog wakes us up from sleep
void setup() {
void loop() {
// The pump is started if humidity drops below a level determined for each plant!
// Show the results on the screen
// ===================================================================
#include
#include
#define GPIO_ADDR 0x27 // the address i2c for this 8x2 LCD
LiquidCrystal_I2C lcd(GPIO_ADDR, 8, 2); // set the I2C address & 8/16 chars / 2 lines
// Utility sleep macros
#include
#include
#define adc_disable() (ADCSRA &= ~(1<
#define powsen PB4 // PB4 provides 4.1V to power the humidity sensor
#define sensor PB3 // Sensor data pin for analog read
#define pump PB1 // Pin for LED & MOSFET feeding the Pump
// Reading humidity once in 30min...1hour is sufficient:
int D, H, nr=100; // Attiny85 will sleep nr*9 (sec.) (E.g. 200=>30min; 400=>1h))
unsigned long psec, corr=nr*300; // time counter since start or watering
ISR(WDT_vect) {
//Don't do anything. This is just here for wake up.
}
lcd.init(); lcd.backlight(); lcd.clear();
pinMode(powsen,OUTPUT); // Power to the sensor by powsen PIN
pinMode(sensor, INPUT); // Sensor read value from sensor PIN
pinMode(pump, OUTPUT); // Pump control PIN
pinMode(LED_BUILTIN, OUTPUT);
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable(); // enables the sleep bit in the mcucr register, so sleep is possible
psec=0; // Starting moment
}
adc_enable();
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(powsen,HIGH); // Power on the sensor
int humidity=analogRead(sensor); // Read sensor data
delay(200); // A short time, just to read the sensor!
digitalWrite(powsen,LOW); // Power off the humidity sensor
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
// Convert analog values from sensor to humidity. Tested: free and short-circuit.
humidity = constrain(humidity, 85, 660); // accept values between these limits for 4.8V on sensor
humidity = map(humidity, 85, 660, 0, 100); // and map them between 0 and 100%
// Then, the pump cannot restart before 'pause', waiting for water to diffuse in the pot.
// Set below the DRY Limit for Your Plant (E.G.: 95):
if (humidity<=95) { ? ? ? ? ? ? ? ? ??
digitalWrite(pump,HIGH); // Power the pump through a Pololu-LV-MOSFET
delay(15000); // Time [ms] to pump the tested REQUIRED volume of WATER to the plant!!
digitalWrite(pump,LOW); // Power down the pump through the MOSFET
delay(1000);
psec=0; // Reset timer of water pumping.
// Test that after [nr*9] seconds (15min in this case), water was absorbed and sensor is above threshold.
// Otherwise, the pump will start again after. Warning: too much water can be bad for your plant!
}
lcd.setCursor(0, 0); lcd.print("Mimosa:");
if (humidity>95)
if (humidity>97)
lcd.print(")");
else
lcd.print("|");
else
lcd.print("(");
lcd.setCursor(0, 1);
lcd.print(humidity); lcd.print("%"); // Write on LCD the humidity (%) and
D=psec/86400; // days since last watering/reset ...
H=(psec%86400)/3600; // and hours
lcd.print(D); lcd.print("d");
lcd.print(H); lcd.print("h ");
// Most of the time, go to sleep for 'nr' multiples of 8 seconds + opp. time
adc_disable(); // ADC uses ~320uA
for (int i=0; i
sleep_mode(); //Go to sleep! Wake up n sec later and work
}
delay(corr); // Timer correction since sleep is less than nr*9 sec.
psec+=nr*9; // Update timer after deep sleep for Half an hour
}
void setup_watchdog(int timerPrescaler) {
//Sets the watchdog timer to wake up, but not reset
//0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
//6=1sec, 7=2sec, 8=4sec, 9=8sec
//From: http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
if (timerPrescaler > 9 ) timerPrescaler = 9; //Limit incoming amount to legal settings
byte bb = timerPrescaler & 7;
if (timerPrescaler > 7) bb |= (1<<5); //Set the special 5th bit if necessary
//This order of commands is important and cannot be combined
MCUSR &= ~(1<
WDTCR |= _BV(WDIE); //Set the interrupt enable, will keep unit from resetting after each int
}
-
濕度傳感器
+關注
關注
7文章
305瀏覽量
58490 -
澆水裝置
+關注
關注
0文章
3瀏覽量
5264
發(fā)布評論請先 登錄
相關推薦
評論