Если вы забываете поливать свой любимый цветок, то сделайте сигнализатор полива растений, как это сделал мастер-самодельщик.
Инструменты и материалы:
-Ардуино нано;
-Соединительные кабели;
-Макетная плата;
-Светодиод;
-Батарея 9 В;
-Аккумуляторный разъем;
-ЖК-экран Nokia 5110;
-Сервопривод;
-Датчик влажности;
-Мини USB кабель;
-Фанера 3мм;
-Петля мебельная 25x22 мм;
-Липучка;
-Резистор 1000 Ом - 4 шт;
-Крепеж;
-Столярный клей;
-Термоусадочные трубки;
-Лазерный резак;
-3D-принтер;
-Паяльное оборудование;
-Компьютер;
Шаг первый: схема
Собирается все по схеме ниже. Места соединения изолирует термотрубкой.
Для датчика влажности собирает разъем. Здесь нужны только три провода красный +, черный -, желтый к AnalogPin A1.
Подключается к Ардуино следующим образом:
Серводвигатель - Pin 5
Кнопка Pin - 2
Светодиод RGB - красный - Pin 10, зеленый - Pin 11, синий - Pin 12
Датчик влажности - Pin 1
ЖК-экран Nokia (справа налево) - Pin 9, 8, 7, 6, 4, питание, 3, земля



Шаг второй: код
Дальше нужно загрузить код.
#include
#include
#include"rgb_lcd.h"
rgb_lcd lcd;
constint numberOfPlants = 4;
constint noPlant = -1; // index meaning no plant is being monitored
constint plant1R = 0;
constint plant1G = 0;
constint plant1B = 255;
constint zeroR = 0;
constint zeroG = 0;
constint zeroB = 0;
constint plant2R = 0;
constint plant2G = 255;
constint plant2B = 0;
constint plant3R = 255;
constint plant3G = 0;
constint plant3B = 0;
constint plant4R = 255;
constint plant4G = 0;
constint plant4B = 255;
// Pinout.
constint waterSensorPin = A1;
constint buttonPin = 2;
constint servoPin = 5;
constint ledPins[numberOfPlants] = {12, 11, 10, 9};
// Moisture ranges for the different plants.
constint moistureMinima[numberOfPlants] = { 0, 0, 0, 0};
constint moistureMaxima[numberOfPlants] = {195, 682, 750, 950};
// Servo holding the indicator needle.
Servo indicator;
int sensorValue = 0; // value read from the Soil Moisture
voidsetup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(waterSensorPin, INPUT);
pinMode(buttonPin, INPUT);
for (int ledNo = 0; ledNo < numberOfPlants; ledNo++) {
pinMode(ledPins[ledNo], OUTPUT);
}
indicator.attach(servoPin);
}
voidloop() {
// Which plant are we currently monitoring?
staticint whichPlant = noPlant;
sensorValue = analogRead(waterSensorPin);// read the analog in value:
// Switch to next plant on button press.
if (digitalRead(buttonPin) == HIGH) {
if (whichPlant != noPlant) {
digitalWrite(ledPins[whichPlant], LOW); // turn off previous LED
}
++whichPlant;
if (whichPlant == numberOfPlants) {
whichPlant = noPlant;
} else {
digitalWrite(ledPins[whichPlant], HIGH); // turn on current LED
}
}
if (whichPlant == noPlant) {
digitalWrite(10, LOW); // turn off previous LED
digitalWrite(12, LOW); // turn off previous LED
lcd.clear();
lcd.noDisplay();
lcd.setRGB(zeroR, zeroG, zeroB);
}
if (whichPlant == 3) {
digitalWrite(10, HIGH); // turn off previous LED
digitalWrite(12, HIGH); // turn off previous LED
lcd.setRGB(plant4R, plant4G, plant4B);
lcd.clear();
lcd.display();
lcd.print("Swamp Plant");// print the results to the LCD Display:
sensorValue = map(sensorValue, 0, 950, 0, 100);
lcd.setCursor(0, 1);
lcd.print(sensorValue);
lcd.print("% Enough water");
Serial.println(sensorValue);
delay(500); // crude debouncing
}
if (whichPlant == 2) {
lcd.setRGB(plant3R, plant3G, plant3B);
lcd.clear();
lcd.display();
lcd.print("Orchid");// print the results to the LCD Display:
sensorValue = map(sensorValue, 0, 750, 0, 100);
lcd.setCursor(0, 1);
lcd.print(sensorValue);
lcd.print("% Enough water");
Serial.println(sensorValue);
}
if (whichPlant == 1) {
lcd.setRGB(plant2R, plant2G, plant2B);
lcd.clear();
lcd.display();
lcd.print("Sunflower");// print the results to the LCD Display:
sensorValue = map(sensorValue, 0, 682, 0, 100);
lcd.setCursor(0, 1);
lcd.print(sensorValue);
lcd.print("% Enough water");
Serial.println(sensorValue);
}
if (whichPlant == 0) {
lcd.setRGB(plant1R, plant1G, plant1B);
lcd.clear();
lcd.display();
lcd.print("Cactus");// print the results to the LCD Display:
sensorValue = map(sensorValue, 0, 195, 0, 100);
lcd.setCursor(0, 1);
lcd.print(sensorValue);
lcd.print("% Enough water");
Serial.println(sensorValue);
}
// Report the moisture level of this plant.
if (whichPlant != noPlant) {
int sensorValue = analogRead(waterSensorPin);
int position = map(sensorValue,
moistureMinima[whichPlant], moistureMaxima[whichPlant], 180, 0);
indicator.write(constrain(position, 0, 180));
Serial.println(sensorValue);
delay(500);
}
// added 14-02 to make sure servo pointer goes back to start after reading last reading from waterSensor
if (whichPlant == noPlant) {
int sensorValue = analogRead(waterSensorPin);
int position = map(sensorValue,
moistureMinima[whichPlant], moistureMaxima[whichPlant], 180, 0);
indicator.write(constrain(position, 180, 180));
delay(500);
}
//gemaakt door Sinan van Noppen
}

Шаг третий: печать деталей, резка
На принтере печатает детали.
button extender.SLDPRT
Battery holder.SLDPRT
Arduino-Nano-Mount.SLDPRT
Servo_Mount3.SLDPRT
partclip.SLDPRT
cop_fin.stl
Вырезает часть деталей на резаке.
Arduino nano box.dxf
Шаг четвертый: сборка
Дальше мастер приступает к сборке устройства.
Склеивает корпус.


На держатели приклеивает липучку. Приклеивает липучку на стенку корпуса.





Устанавливает серводвигатель, стрелку и батарею.


Устанавливает светодиод, ЖК-экран, устанавливает на петлях переднюю крышку. Датчик влажности заливает внутри эпоксидной смолой, для защиты от влаги.


Теперь нужно установить щупы датчика в грунт, и подключить его к Ардуино. Само устройство нужно разместить рядом с цветочным горшком.
Источник (Source)
Становитесь автором сайта, публикуйте собственные статьи, описания самоделок с оплатой за текст. Подробнее здесь.