Skip to content

marcodev01/plant-water-system

Repository files navigation

Chilli Plant Water System

The "chilli" plant water system is controlled by an Raspbery PI 3 with the Grove Base Hat and several connected sensors of Grove's ecosystem as well as Xiaomi Mi Flora Plant Sensor. The irrigation is electrically opererated by 5V water pumps which are controlled by 3.3V and 5V relays. Application Architecture:

  • Water System Runner
  • Plant Water System API
  • Plant Water Admin APP (Progressive Web App) TODO

Water System Runner

The water system runner is a simple Python 3.7 application running several jobs scheduled with the Python library Advanced Python Scheduler.

The first job is reading and persisting values from various sensors with a time stamp into a tinyDB table named sensor_history. Note: For certain sensor values it converts and round them to legbible units.

The second job is reading the most recent data entry (by time stamp) from table sensor_history and compares them with the defined threshold values. For plants that fall below this threshold value the water pump is started. The threshold values are defined in a table named plants_configuration among other configurations for sensor channels, relay pins and watering duration/iteration etc.

A third job is cleaning up the sensor_history database from old values. The max age of sensor_history values can be configured in a table named jobs_configuration.

All actions, warnings and errors are logged in water_system.log

API

An interface for the Chilli Plant Water System REST-API is implemented with FastAPI. It provides Endpoints to manage plant configurtions, read logs, start/pause the water system etc. See full API documentation: http://{API_URI}/docs.

The API is operated on a ASGI server by uvicorn

All actions, api accesses and errors are logged in api.log

Dependent Libraries

Dev environment

Setup dev environment

  1. Allow sibling packages in python with virtual environment (venv): stack overflow thread
  2. Install all depenet libraries in venv (except for native python libraries)

Run in dev environment

  1. Activate venv: source ~/Projects/plantWaterSystem/venv/bin/activate
  2. Start API server with water system in dev environment: uvicorn api:app --reload

Run in prod environment

Use bash script start_water_system_main.sh for running water system as standalone or start_water_system_with_api.sh for running water system with api.

About

Automatic plant watering with Raspberry Pi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published