Introduction
This document got written for an English. This project is for monitoring my plantsā moisture. Optionally there can be a pump connected to regulate the moisture of the plantās soil.
The documentation here is written like an Instructables, to it is easy for anyone to reproduce it. Showing the moisture level the span of almost a month in a nice graph. Instead of going for an automated watering plant with valves/pumps you can opt for getting notifications if a plant doesnāt report moisture or is below some level.
Materials and tools š
What do you need to get started?
ESP32 š¶
Pumps or Valves ā
Iāve opted for valves.
Sensors šæ
Waterpipes š§
Cables and transistors š
For multiple plants ā
Multiplexer / Demultiplexer
This is very cheap and you can read 8 analog values from one analog pin if you switch correctly.
Multiplexer for the Valves/Pumps
In case you want to have a lot of plants dependent on the same esp32 (which I donāt recommend) you can use a multiplexer. You can read a lot of more analog inputs with this connected before the real analog input. You can control what external plant to connect to and read the moisture. If you donāt use this you have to use transistors. In the picture of Cables and transistors you can see a few transistors that are good to use.
Preparation/Prerequisites
Programming knowledge
In the beginning of the class it as mandatory to learn the basic of Arduino C++. We developed a traffic lightš¦. We gathered a understanding of how the Arduino Framework works and meddled around with with timers (not really hardware timers but writing the milliseconds since boot into variables and using that as timers). We used inputs (buttons) to control the traffic light. Problems encountered
Server
Another prerequisite is to own a domain that your plants can pipe the information to no matter where they are. On this domain there should be a database. It is inherently useful to get a timeseries database for our project.
InfluxDB
We went for InfluxDB but you can choose a another. Check out other time series databases on Wikipedia :Time series database - Wikipedia. The nice thing about time series databases is that you just send something there like a moisture value and a name and you can already make nice plots because all the timestamps when the DB received the messages are recorded down to the microsecond.
Hints and Tips
If you are in the same network as the server you donāt have to send the data to your public domain but to the local address. You donāt even have to use https. I just use http and I donāt care if it can be read in this instance. Usually Iām more picky about network security but not when it is about something like this.
Problems encountered
I had lots of problems with the adc (Analog digital converter) while using WiFi.
With some ESP there are lots of booting issues with Wifi enabled.
Problems with measuring the moisture
Here you can See that the system was sending the moisture to the server every 10s. This is a lot and will be reduced in the future. The problem here is that the value is not even correct. Another board was used with other analog values.
Code š»
SendToInfluxDB
This is rather straight forward. You donāt really have to understand it all.
Get the moisture from the plant
In order to get the moisture form the soil of a plant you have to know the sensor before. The sensor consists of three wires: Aout, GND (Ground), Vcc (our Voltage here 3V3). Basically the voltage on Aout changes depending on the mostisture.
In order to get the maxima of the voltage of Aout we have to measure it dry and submerged in water. Here you can see in the comments of the code the voltages for the edges of our scale.
Object Orientated Programming
Now we need some way to use it. We need a class or a struct to organize the code and make it more readable and less prone to human errors.
Now with the struct we can simply call the function to send the moisture to the DB.
The Code as a whole
Conclusion
This project has been a blast with my mates. Phillip and Oliver were helpful and were happy to lean. We not only enjoyed our own project but all the projects in the class. Please have a look at them here.
Future Ideas š
On the backend side there is a lot to be done. Letās say we have 20 plants and each sends every 10min. Every entry in our DB is 200 Bytes. This would accumulate to 210 Mega Byte in one Year. . It would be nice to downsample our data after one year or so. But honestly there is not really much storage to recapture and it might not be worth the hassle to pursue this idea. Carlo will use this as a base on constructing his automated farm.
Links to Classmatesā Projects
Other Watering plant group with nice PCB and lots of features we didnāt have. RC Motionsensor in action