Hello, we are a team of 5 students and for our school project, we decided to create a device that can monitor the environment of a plant and ensure its health with a automatic watering system.
We all know the experience of a dying plant, when we forget to water our plant when we get lazy or are away in the holidays. For that reason we designed the Pflanz-o-mat. With the Pflanz-o-mat you will be able to always check on the plants health via website, wherever you are and it will pour water onto your plant when it is needed. You can be lazy or go into your holidays without a bad conscience because the health of your plant will be ensured by the Pflanz-o-mat.
ConceptAfter evaluating our budget and already existing components in our school, we decided to go with the particle board as control center of all sensors and the external valve. The product will be powered with 12 V. A diagram of the product is shown here:
The electric
You can use normal PET-bottles as watertank. To makke this possible, an specific closure for the watertank has been maded to have a proper connection with the bottle. The concept of the closure is shown below:
The closure of the watertank is designed by multiple pieces andd shown here:
The code is written in the particle web IDE. Here we can see the variables needed for the controlling of the Pflanz-o-mat and the initilisation of the needed pins of the particle board to connect the sensors.
#include <math.h>
#include "Particle.h"
//********Werte*******
double liquid_level; //Wert für die ist-Erdfeuchte
double temperature; //Wert für die ist-Temperatur
double licht; //Wert für die ist-Lichteinstrahlung
double sollFeuchtigkeit; //Wert für die soll-Feuchtigkeit
const int intervalOn=3000; //Ventil öffnet 3 Sekunden lang
const int intervalOff=90000; // Ventil kann erst nach 9 Sekunden erneut öffnen
unsigned long currentMillis, previousMillis;
int state = LOW;
//*******Werte end*******
SYSTEM_THREAD(ENABLED);
//*******PINs*******
const int sensorPin0= A0; //Erdfeuchtesensor pin A0
const int sensorPin1= A1; //Temperatursensor pin A1
const int sensorPin2= A2; //Lichtsensor pin A2
const int WasserPin = D7; //Ansteuerung Relais für das Ventil
//*****PINs end*****
Functions are needed to control the modules of the product. Here is the function to manually water the plant.
int wasser(String command) //Manuelle Steuerung der Bewässerung
{
if(command.equals("on"))
{
digitalWrite(WasserPin, HIGH);
Particle.publish("Ventil", "Eingeschaltet");
return 1;
}
else if(command.equals("off"))
{
digitalWrite(WasserPin, LOW);
Particle.publish("Ventil", "Ausgeschaltet");
return 0;
}
else
{
return -1;
}
}
In the function "setErdfeuchte" the variable Erdfeuchte is being updated after the irrigation.
int setErdfeuchte(String sollWert)
{
sollFeuchtigkeit = atoi(sollWert);
Particle.publish("SollFeuchtigkeit", String(sollFeuchtigkeit));
return sollFeuchtigkeit;
}
Here is the function for the automated irrigation of the plant.
void irrigation ()
{
if(liquid_level < sollFeuchtigkeit)
{
if(state==HIGH && currentMillis - previousMillis > intervalOn)
{
previousMillis = currentMillis;
state = LOW;
digitalWrite(WasserPin, state);
}
if(state==LOW && currentMillis - previousMillis > intervalOff)
{
previousMillis = currentMillis;
state = HIGH;
digitalWrite(WasserPin, state);
}
}
}
In the setup function, modes of the pins and the baud rate are being set.
void setup()
{
Serial.begin(9600); //sets the baud rate for data transfer in bits/second
pinMode(sensorPin0, INPUT); //Erdfeuchtesensor
pinMode(sensorPin1, INPUT); //Temperatursensor
pinMode(sensorPin2, INPUT); //Lichtsensor
pinMode(WasserPin, OUTPUT); //Ansteueung Relais
Particle.function("Wasser", wasser);
Particle.function("setErdfeuchte", setErdfeuchte);
Particle.variable("Erdfeuchte", liquid_level);
Particle.variable("Temperatur", temperature);
Particle.variable("Lichteinstrahlung", licht);
}
In the loop function, the sensor data will be read and calculated into intelligible numbers. These will be shown in the User Interface of the product.
void loop()
{
currentMillis = millis();
irrigation();
//******Erdfeuchtesensor******
double feucht= analogRead(sensorPin0);
liquid_level= (feucht / 4095) * 100; //Umrechnung in eine Prozentzahl
//Particle.publish("Erdfeuchte in %", String(liquid_level));
delay(1000);
//******Erdfeuchtesensor End*****
//*******Temperatursensor*******
double temp = analogRead(sensorPin1);
double fenya=(temp/4095)*5;
double r=fenya/(5-fenya)*10000;
temperature = 1/(log(r/10000) /3950 + 1/(25+273.15))-273.15;
//Particle.publish("Temperatur in °C", String(temperature));
delay(1000);
//********Temperatursensor End*******
//********Lichteinstrahlung*********
double light = analogRead(sensorPin2);
licht= (light/4095) * 100; //Umrechnung in Prozentzahl
//Particle.publish("Lichteinstrahlung in %", String(licht));
delay(1000);
//********Lichteinstrahlung end*******
}
User InterfaceFor the usage and monitoring of the Pflanz-o-mat, a website has been made. On the website, the data of the sensors is shown. These include following:
- ambient temperature
- soil moisture
- light
You can control the recommended moisture of your plant and it irrigate accordingly to that. Furthermore you can manually water your plant if you want to. Also the website shows the weather from the location of your product. The User Interface is shown below:
Comments