Package: pih2o
Thepih2oproject attempts to provide an automatic plant watering applicationout-of-the-boxin pure Python for Raspberry Pi. The watering is triggered for all plants depending on the number
of plants which need water.RequirementsThe requirements listed below are the one used for the development ofpih2o, but other
configuration may work fine.Thepumpcan be replaced by an electro valve if the tank water is upper than the plants
(watering by gravity). The number ofsoil moisture sensorscan be easily adapted from 1 to 4.
Thetransistoris optional, the sensors can be directly connected to the 5V pin in order
to power them continuously (but it accelerate their corrosion).Hardware1 Raspberry Pi 2 Model B (or higher)1 pump and its power supply 12V DC (or electro valve)1 to 4 soil moisture sensors (Arduino TE215)1 Analog-to-Digital Converter (ADS1015 or ADS1115 4 Channel I2C)2 transistors NPN (type BC237B)1 transistor PNP high power switch (type BDX34)1 zener diode (type 1N4007)2 resistors of 1.5k Ohm1 resistor of 10k OhmSoftwarePython3.5.3RPi.GPIO0.6.3adafruit-ads1x151.0.2croniter0.3.23blinker1.4flask1.0.2flask-restful0.3.6flask-sqlalchemy2.3.2InstallA brief description on how to set-up a Raspberry Pi to use this software.Download latest Raspbian image and set-up an SD-card. You can followthese instructions.Insert the SD-card into the Raspberry Pi and fire it up. Use the raspi-config tool that is shown
automatically on the first boot to configure your system (e.g., expand partition, change hostname,
password, enable SSH, configure to boot into GUI, etc.).HintDon’t forget to enable the I2C in raspi-config.Reboot and open a terminal. Install the latest firmware version:$ sudo rpi-updateUpgrade all installed software:$ sudo apt-get update
$ sudo apt-get upgradeInstallpih2ofrom thepypi repository:$ sudo pip3 install pih2oRunStart the automatic plant watering application using the command:$ pih2oThe application acts as a daemon running on the Raspberry Pi. It can be controlled thanks
to anRESTful API.Thepih2ois scheduled to wake up every given interval, power the soil moisture
sensors and take humidity measurement (or threshold if no analog input available).
Finally the sensors are powered off to extend their lifespan.WarningRunning pih2o in that way use the development server offlaskwhich isnot suitable in a production
environmentDefine the record intervalThe record interval (i.e. time between each humidity measurement) is defined
in theConfigurationusing thecrontab syntaxwhich is summarized here:┌───────────── minute (0 - 59)
                  │ ┌───────────── hour (0 - 23)
                  │ │ ┌───────────── day of month (1 - 31)
                  │ │ │ ┌───────────── month (1 - 12)
                  │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday)
                  │ │ │ │ │
                  │ │ │ │ │
record_interval = * * * * *Pump triggering strategyThe watering time is defined in theConfiguration. The rational to dissociate the pump stop
from the humidity level measured is the soil slow absorption and we want to avoid floor flooding.Three strategies are defined to detect if watering is required by your plants depending on your
configuration and the number of sensors connected.[GENERAL][watering_strategy]= majoritymeans the pump is triggered if half of sensors
are triggered.[GENERAL][watering_strategy]= firstmeans the pump is triggered if at least one sensor
is triggered.[GENERAL][watering_strategy]= lastmeans the pump is triggered if all sensors are
triggered.Noteif analog channels are available: the sensor is triggered when the humidity read from the AO
goes below the defined threshold (in %) else if digital channels are available: the sensor
is triggered if the corresponding DO is set to 1.Install developing versionIf you want to use an unofficial version of thepih2oapplication, you need to work from a
clone of thisgitrepository. Replace the step 5. of theInstallprocedure above by the
following actions:clone from github$ git clone https://github.com/anxuae/piH2O.gitgo in the cloned directory$ cd pih2oinstallpih2oin editable mode$ sudo pip3 install -e .start the application exactly in the same way as installed from pypi. All modifications performed
in the cloned repository are taken into account when the application starts.ConfigurationAt the first run, a configuration file is generated in~/.config/pih2o/pih2o.cfgwhich permits to configure the behavior of the application. The configuration can be
easily edited using the command:$ pih2o --configThe default configuration can be restored with the command (strongly recommended when
upgradingpih2o):$ pih2o --resetSee thedefault configuration filefor further details.Circuit diagramSoil moisture sensor specification used for this project (the number is up to you but the following
diagram is for up to 4 max):ParameterValueInput Voltage3.3 – 5VOutput Voltage0 – 4.2VInput Current35mAOutput SignalBoth Analog (A0) and Digital (D0)Digital sensorsHere is the diagram for digital sensors (rise to high on dry soil). Depending on the sensor type,
an signal amplifier may be necessary (not represented on this diagram).Analog sensorsHere is the diagram for analog sensors connected to an ADC1115 to measure humidity level.PumpHere is the diagram for the pump (or electro valve). For better understanding the sensors
are not represented here.