Skip to content

Commit

Permalink
added all files
Browse files Browse the repository at this point in the history
  • Loading branch information
jankln committed Mar 22, 2024
1 parent 71dcf8b commit f11f1ee
Show file tree
Hide file tree
Showing 15 changed files with 713 additions and 1 deletion.
Binary file added AutoGrowing.db
Binary file not shown.
Binary file added Autorun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Bild.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GPIO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GitHub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 161 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,161 @@
# AutoGrowing
## Übersicht

Willkommen zu unserem Automatisierten Gewächshausprojekt! Das Ziel dieser Zusammenarbeit von Jan Klein und Velimir Kleymenov ist es, eine automatisierte Lösung für das Gewächshausmanagement bereitzustellen. Für dieses Projekt verwenden wir einen Raspberry Pi 3B+. Es wurde eine SQLite-Datenbank erstellt, in der die Pflanzendaten und Sensordaten gespeichert werden. Die Steuerung der Aktoren und Sensoren erfolgt über die GPIO-Pins mit Python und wird anschließend in einer Datenbank gespeichert. Die GUI wurde mit HTML und CSS erstellt. Die Ausgabe der Sensordaten in die GUI wurde mittels PHP umgesetzt und das Darstellen in einem Diagramm mit der Open-Source-Software Plotly.

![Übersicht](Overview.png)

## Inhaltsverzeichnis

- [Features](#features)
- [Hardware-Anforderungen](#hardware-anforderungen)
- [Setup](#setup)
- [Verwendung](#verwendung)
- [Lizenz](#lizenz)

## Features

- **Pflanzenauswahl:** Es stehen verschiedene Pflanzen zur Auswahl.
- **Automatische Steuerung je nach Pflanzenwahl:** Durch die Steuerung der Aktoren und Sensoren werden die benötigten Temperatur-, Wasser- und Bodenfeuchtigkeitsbedürfnisse der ausgewählten Pflanze automatisch angepasst.
- **Speicherung der Sensordaten:** In unserer Datenbank werden alle wichtigen Informationen über die Pflanzen und die Sensorausgabe gespeichert.
- **Ausgabe der aktuellen Sensordaten:** In unserer GUI werden die Sensordaten aus der Datenbank abgefragt und in einem Diagramm dargestellt.
- **Manuelle Steuerung möglich:** In unserer GUI können Sie auch den Raspberry Pi sowie Aktoren und Sensoren bei Bedarf manuell steuern.

## Hardware-Anforderungen

Um mit dem Projekt zu beginnen, stellen Sie sicher, dass Sie über die folgenden Hardwarekomponenten verfügen:

- Raspberry Pi 3B+
- RPI-Netzteil
- Netzwerkkabel
- Leitungen
- Wasserschlauch
- 2 Relais
- 12-Bit-ADC-Umwandler
- Benötigte Aktoren:
- Mini-Wasserpumpe
- 180° Servomotor
- Glühlampe
- Benötigte Sensoren:
- BME280
- Bodenfeuchtigkeitssensor

Bitte beachten Sie, dass die Verwendung anderer Hardwarekomponenten zu unerwarteten Fehlern führen kann und die Funktionalität des Projekts beeinträchtigen könnte.

## Setup

1. **Wir verwenden das Betriebssystem Debian GNU/Linux 11 (bullseye) auf unserem Raspberry Pi 3B+.**

### Benötigte Software

Die unten genannte Software wird benötigt, um unser Programm nutzen zu können. Die Befehle für die Installation für unser verwendetes Betriebssystem sind separat aufgelistet.

- Git

```bash
sudo apt install git
```

- Python

```bash
sudo apt install python3 python3-venv python3-pip
```

- Smbus2

```bash
pip3 install smbus2
```

- RPi.bme280

```bash
pip3 install RPi.bme280
```

- gpiozero

```bash
pip install gpiozero
```

- ADS1015 (siehe [hier](https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115))

```bash
git clone https://github.com/adafruit/Adafruit_Python_ADS1x15.git
cd Adafruit_Python_ADS1x15
sudo python setup.py install
```

- SQLite3

```bash
sudo apt-get install sqlite3
```

- Plotly

```bash
pip install plotly==5.19.0
```

- PHP

```bash
sudo apt-get install php
```

- Node.js

```bash
sudo apt install nodejs
```

- Apache2

```bash
sudo apt install apache2
```

3. **Schließe Aktoren und Sensoren an die Raspberry Pi GPIO-Pins an**
![GPIO](GPIO.png)

4. Klone das Repository auf deinen Raspberry Pi:

```bash
git clone https://github.com/jankln/Automatisiertes_Gewaechshaus.git
```

5. **Füge main.py und index.php zum Autostart hinzu:**

```bash
sudo crontab -e
```

6. **Wähle einen Editor, in unserem Beispiel nano**
![Autorun](Autorun.png)

7. **Gehe nach unten in der Datei und füge folgenden Command ein:**
```bash
@reboot python3 /home/pi/Automatisiertes_Gewaechshaus/main.py
```
8. **Führe die SQL Datei aus:**
```bash
cd Automatisiertes_Gewaechshaus
sqlite3 AutoGrowing.db
.read create.sql
```

## Verwendung
![Verwendung](Verwendung.png)
- **Navigationsbar:** Oben links befindet sich die Navigationsbar um sich schneller vortzubewegen.
- **Auswahl Pflanze:** Es gibt links ein Dropdown Menü, indem man seine aktuelle Pflanze auswählen kann. Beim betätigen des Auswählen Buttons, wird diese Ausgewählt.
- **Ausgewählte Pflanze:** Die ausgewählte Pflanze wird unterhalb des Auswählen Buttons angezeigt.
- **Manuelle Steuerung:** Mit den beschrifteten Buttons kann man, wenn benötigt die Aktoren und den Raspberry Pi manuell steuern.
- **Diagramm Sensorwerte:** Unterhalb des Auswahl Buttons sieht man die aktuell ausgewählte Pflanze mit deren Anforderungen. Durch drücken der linken Maustaste kann man den gewünschten Bereich genauer anschauen und durch Doppelklick gelangt man wieder zur Ausgangsposition. Beim rübergleiten der Maus erscheint ein Menü mit weiteren anzeige Möglichkeiten.


## Lizenz

Dieses Projekt ist unter der [MIT License](LICENSE). Fühlen Sie sich frei, den Code gemäß den Bedingungen der Lizenz zu verwenden, zu ändern und zu verbreiten.
20 changes: 20 additions & 0 deletions Servomotor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PinServoMotor = 26
GPIO.setup(PinServoMotor, GPIO.OUT)
pwm = GPIO.PWM(PinServoMotor, 50)

servoMotor()

def servoMotor():
if (GPIO.input(PinServoMotor)):
duty = 2
pwm.start(duty)
t.sleep(0.5)
pwm.start(0)
pwm.stop
else:
duty = (180 / 18) + 2
pwm.start(duty)
t.sleep(0.5)
pwm.start(0)
pwm.stop
return
Binary file added Verwendung.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Waterpump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import RPi.GPIO as GPIO # Für das ansteuern der GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

PinWaterPump = 20
GPIO.setup(PinWaterPump, GPIO.OUT)

runWaterpump()
GPIO.output(PinWaterPump, GPIO.LOW)

def runWaterpump():
if (GPIO.input(PinWaterPump)):
GPIO.output(PinWaterPump, GPIO.HIGH) #Schalte die Wasserpumpe ein
else:
GPIO.output(PinWaterPump, GPIO.LOW) # Schalte die Wasserpupe aus
return
60 changes: 60 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
drop TABLE if EXISTS SensorReadout;
drop table if exists PlantLog;
drop table if exists Plant;
CREATE TABLE IF NOT EXISTS SensorReadout (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
dateTime DATETIME NOT NULL,
temperature INTEGER NOT NULL,
airHumidity INTEGER NOT NULL,
soilMoisture INTEGER NOT NULL,
doorIsOpen BOOLEAN NOT NULL,
waterIsOn BOOLEAN NOT NULL,
lightIsOn BOOLEAN NOT NULL
);

CREATE TABLE IF NOT EXISTS Plant(
plantID INTEGER PRIMARY KEY AUTOINCREMENT,
commonName VARCHAR(80) NOT NULL,
growingTemperature INTEGER NOT NULL, -- in °C
lightDurationInMinutesPerDay INTEGER NOT NULL, -- in Minuten
growingSoilMoisture INTEGER NOT NULL, -- als Wert zwischen 0 - maximal Sensor wert
growingAirHumidity INTEGER NOT NULL, -- 1-100 %
waterRequirementPerDay INTEGER NOT NULL, -- in Sekunden
actOnSoilMoisture BOOLEAN NOT NULL -- ist Erdfeuchtigkeit ein Faktor zum Gießen?
);

CREATE TABLE IF NOT EXISTS PlantLog(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
plantID INTEGER NOT NULL,
dateTime DATETIME NOT NULL,
FOREIGN KEY(plantID) REFERENCES Plant(ID)
);


INSERT INTO Plant (commonName, growingTemperature, lightDurationInMinutesPerDay, growingSoilMoisture, growingAirHumidity, waterRequirementPerDay, actOnSoilMoisture)
VALUES
('China Rose', 25, 600, 60, 200, 20, 0),
('Tomato', 25, 720, 70, 250, 20, 0),
('Lavender', 22, 480, 50, 220, 20, 0),
('Peppermint', 18, 540, 40, 180, 20, 0),
('Rubber Plant', 28, 660, 65, 280, 20, 0);

INSERT INTO PlantLog (dateTime, plantID)
VALUES
((datetime(CURRENT_TIMESTAMP, '+1 hour')), 2),
((datetime(CURRENT_TIMESTAMP, '+1 hour')), 1);

INSERT INTO SensorReadout (dateTime, temperature, airHumidity, soilMoisture, doorIsOpen,waterIsOn,lightIsOn)
VALUES ('2024-03-13 08:00:00', 25, 60, 40,0,0,0);

INSERT INTO SensorReadout (dateTime, temperature, airHumidity, soilMoisture, doorIsOpen,waterIsOn,lightIsOn)
VALUES ('2024-03-13 09:00:00', 26, 62, 42,1,0,0);

INSERT INTO SensorReadout (dateTime, temperature, airHumidity, soilMoisture,doorIsOpen,waterIsOn,lightIsOn)
VALUES ('2024-03-13 10:00:00', 27, 64, 45,0,0,0);

INSERT INTO SensorReadout (dateTime, temperature, airHumidity, soilMoisture,doorIsOpen,waterIsOn,lightIsOn)
VALUES ('2024-03-13 11:00:00', 28, 65, 46,0,0,0);

INSERT INTO SensorReadout (dateTime, temperature, airHumidity, soilMoisture,doorIsOpen,waterIsOn,lightIsOn)
VALUES ('2024-03-13 12:00:00', 29, 66, 47,1,0,0);
Loading

0 comments on commit f11f1ee

Please sign in to comment.