Introduction
Hello there,
We are a team of 3 students from Germany and want to enhance your gardener experience.
As a result of the climate change we had a hot and thirsty summer this year. Thus the nonexistent water for our garden and plants there was a huge need for watering those. During the hours needed for this process nothing else could be done.
Therefore we invented the Giess-Beast. It's an amazing product which will provide an easy and modular solution for your desires.
It's a smart solution to address the inconvenience with watering the garden. Once set up correctly, you will understand the advantages of a self working watering system that you can easily control everything form a comfortable standpoint.
Feel free to contact us or share your experiences with our product.
Stay hungry, stay foolish
Structure
The basis of our product is the raspberry pi. This serves as the control center for the external pump control. This means that our product is compatible with your existing pump. The raspberry pi is also necessary to analyze the current weather data and to take the necessary measures to ensure an optimal supply of the plants.
The most optimal amount of water can be preconfigured using the configurable and individually adjustable values for certain plant species.
Since we want to continue to use an open system for the end user, our source code can be modified as you like.
Advantages
- save water and time: Adjustable droppers and nozzles allow water savings compared to conventional irrigation methods. You will also save time as no conventional irrigation is required - use your free time elsewhere.
- for healthy plants: Due to the precise and uniform irrigation, the water arrives where the plant needs it: at the root.
- flexibel system to customize and use: The Giess-Biest-System offers you the flexibility required to develop an individual system that meets your needs. The wide range of extensions for your optimal gardener experience.
- relaxing vacation days: With the Giess-Beast you are absolutely independent at vacation time and when you are away and your plants are still optimally cared for. You also no longer have to ask your neighbors to take care of your plants.
Software for the Microcontroller
The software for the Microcontroller is divided in multiple parts:
- Wifi connectivity
- MQTT and Functions
- Reading the Sensor Data
- Displaying Data on the OLED Display
- Activating and deactivation the Pump
Programming with Arduino IDE
Many of you probably know about the Arduino IDE, since the Platform is very popular among the DIY community.
For those new to the topic:
The ESP32, used in this Project is a Microcontroller. It requires Compiled Code to run as intended. The used ESP Board comes with a handy Micro-USB Port which allows it to be written to with just a PC and a Micro USB cable.
Arduino IDE takes care of the the compiling and programming of your code and features some code highlighting as well. You can get Arduino IDE here.
Since the ESP32 isn't a normal Arduino we need to set up Arduino IDE for the ESP32. I learned the setup process from this Site, its pretty simple.
Afterwards connect your controller to the PC with a micro USB cable. Also make sure that it's turned on, since we use a battery board, it has an on/off switch.
Once connected check your Com Ports in the Arduino IDE. Test them and use the Serial Monitor to see if you got the right one. Press the Enable button to restart the ESP32, this will always print some Data to the Serial Interface, if you see nothing - its the wrong port.
TIPP: I had some Problems getting a connection:
- The driver for the USB to Serial interface on the Controller Board was not installed
- My Bluetooth USB Stick interfered in some way, unplugging it solved that Problem
Code Organised in Tabs in Arduino IDE
You will find that my Code is Separated in different Files. For this to work the File with the setup() and main() function needs to be the same as the dictionary folder.
The files are Compiled by the IDE as one long continuous File, thus no including is necessary.
Used Librarys for this Project
#include <WiFi.h> //WIFI
#include <PubSubClient.h> //MQTT
#include <Adafruit_Sensor.h> //Sensor commands
#include <Adafruit_BME280.h> //specific for BME280
#include "SSD1306.h" //OLED Screen DriverConnecting to Wifi
Declare your Variables (global):
const char* ssid = "Your SSID (network Name)";
const char* password = "Your Networks Password";just fill in the fields with your Network settings, example:
SSID: "MyWifi"
PW: "ThisIsMyPassword"
The used function:
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED, HIGH);
delay(500);
Serial.print(".");
digitalWrite(LED, LOW);
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}this function uses the values given to connect to the wifi Network.
MQTT and functionsdeclare your server Data. If you are not sure what your Pi's IP is use
hostname -Ito get it on your IP on the Pi.
Set the Variables like this:
const char* mqttserver = "192.168.178.58";
const int mqttport = 1883;
const char* mqttUser = "";
const char* mqttPassword = "";In the setup() function you need to pass a few arguments:
client.setServer(mqttserver, mqttport); //Setzten der Servervariablen
client.setCallback(callback); //Callback setzten
reconnect();the reconnect function is implemented in:
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.println("\nConnecting to MQTT...");
if (client.connect("ESP32Client", mqttUser, mqttPassword )) {
Serial.println("connected");
} else {
Serial.print("failed with state ");
Serial.print(client.state());
delay(2000);
}
}
}it makes sure you are connected with the MQTT broker.
Callback
The Callback function is just as important. It defines what the controller will do if a command is recieved. The used callback funtion can be found in in the attachments.
Notable details:
- MQTT Messages only use a String Data Type - Bytes are transmitted. Becouse of that for the callibration of the Sensor a conversion Method is needed. This is implemented in the functions file. It looks complicated, but its purpose is rather simple: it convertes Bytes of Data (Numbers) into a float value.
- Every Message comes with its topic, this can be used to organize your code and hand over a message to the right function.
the Send values Function is called in the loop() function and is defined in the "functions" file. The Data is gathered through functions of the two Adafruit librarys. This Data is then passed to the OLED and the MQTT Network.
Since MQTT only takes in bytes, the values get converted into the char Datatype using the function sprintf() and handing it over to the global Variable char C. C is used for all outgoing transmission - it works like a simplified Buffer.
Pump controlIs done by the Raspberry Pi which sends commands to the microcontroller. These commands are then interpreted and used to switch a Relais to activate the Pump.
void activatePump(float time){
if (time + millis() < 4294967295) {
pumpTimer = millis()+(int)time*1000000;
}else{
pumpTimer = (int) time*1000000-(4294967295-millis());
}
digitalWrite(LED,HIGH);
Serial.println("pump on");
}The Microcontroller creates his own timer to deactivate the pump again. In Order for this to work another function is called every main loop() that controlles wether the pump should be turned off again:
void checkPump(){
if (pumpTimer >= millis() && pumpTimer <= millis()+1000000 &&
digitalRead(LED) == HIGH){
digitalWrite(LED,LOW);
Serial.println("pump off");
}
}It trys to deactivate the pump only if:
- timer is reached
- Pump is actually on
since the System Time (millis()) is used as a reference and this does restart at 0 after about 50 Days. So it will calculate the remaining time after reset accordingly.
Raspberry Pi configurationMost of you probably have worked with a Pi before so I want to skip the beginner Parts since it has been coverd enough by this point. If you dont have a bootable SD Card yet, you can flash one.
Get the Resbian Jessi OS here. To create the Bootable Device I recomend Etcher, but if you like other tools like rufus more, no Problem, it will work as well.
Once you are done with creating the Image and have booted into your Pi, try to get a Network Connection. Once set up run these two commands in the Terminal to get your Pi up to date:
sudo apt-get update
sudo apt-get upgradeInstalling Mosquitto on your Raspberryevery MQTT Network needs a Broker that controlls and handels the Data of the Network. As broker I recomend Mosquitto, since it works reliable with the Raspberry Pi and is easy to set up.
I managed to set mine up mainly with help from this Article. So check it for further reference.
Comands you need to run:
this will install Mosquitto:
sudo apt install -y mosquitto mosquitto-clientsthis does enable Mosquitto at startup:
sudo systemctl enable mosquitto.serviceafterwards check if it is installed with:
mosquitto -v-v is the Version flag so you should get back something like this:
1580295764: mosquitto version 1.5.7 starting
1580295764: Using default config.
1580295764: Opening ipv4 listen socket on port 1883.
1580295764: Error: Address already in useInstall Node-Red to manage the Data flow and generate a UIfor Documentation look here. I will only discuss the neccesary commands for the Raspberry
sudo apt-get install build-essential
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)The bash skript will try to install node-red or update it to the latest version.
We also want to autostart Node-Red:
sudo systemctl enable nodered.serviceAfterwards we go to the editor by entering <"your local IP":1880> in our browser.
for example: 192.168.178.58:1880 if you dont know the IP of your raspberry you can get it with:
hostname -Ithe :1880 is the port for Node red. If you haven't changed it manually it will be 1880.
Importing Flows to Node Redto get the used flows into Node Red, just copy the Text in the Attachments and insert it under Menu -> Import -> Clipboard
afterwards hit deploy to implement changes. You will probably be asked to Install further Librarys, this can be done through the either the terminal or the web interface. I recommend you use the Web Interface.
A list of all my installed Nodes (some come with Node-Red install):
node-red 0.20.7
node-red-contrib-bool-gate 1.0.2
node-red-contrib-boolean-logic 0.0.3
node-red-contrib-ibm-watson-iot 0.2.8
node-red-contrib-moment 3.0.3
node-red-contrib-play-audio 2.3.2
node-red-contrib-simple-message-queue 0.2.5
node-red-contrib-string 0.2.2
node-red-dashboard 2.16.2
node-red-node-email 1.6.2
node-red-node-feedparser 0.1.14
node-red-node-openweathermap 0.2.1
node-red-node-ping 0.0.16
node-red-node-random 0.1.3
node-red-node-rbe 0.2.4
node-red-node-sentiment 0.1.3
node-red-node-serialport 0.8.3
node-red-node-smooth 0.1.0
node-red-node-sqlite 0.4.1
node-red-node-tail 0.0.2
node-red-node-twitter 1.1.5Setting up MQTT in Node Reddouble click one of the MQTT Nodes, for example:
and set the local IP of your Raspberry Pi, if it is not set automatically. The Standard port of the Broker is 1883 - example:
Set up Open weathermap:for the Weather Data we use openweathermap. So you will need to sign up to get a free API Key.
you will than have to insert that Key into as well as your location.
Visualization

























Comments