Fantaso / iot-system

Company website & web app to setup, monitor & control farms and crops, IoT API to register sensors and send collecting data from field's weather and soil.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IoT monitoring system

Monitor your plants, keep track of them environment and automate your water pump to irrigate them.

banner

Project consists to allow users to manage irrigation system and monitor the growing plants/crop 24/7 with the help of an IoT system. The IoT system is composed by 3 main components:

  • A Website: Company's website let web visitors see what's the company about and what services/products it offers. Website visitors are able to contact the company, register to newsletters and give feedback on products and services.

  • A Web application: Allows users to register an account, view data collected from the sensors, control water pump, check projected yields and manage life-cycle of the growing plants/crop, manage your sensors and pumps and more...

  • A Rest API: Allows your wireless pump controllers & sensors (Raspberry Pi) to register and communicate with the web application to be able to send collected sensor data and receive instructions to control the water pump.

  • A Raspberry Pi System Repository: Hardware that allow us to collect and control a remote wireless system. Which is composed, by a weather sensor (temperature, humidity & atmospheric pressure), soil sensors (moist, temperature & pH) and a relay system to control the water pump



Index:

  • Installation

    1. Installing Web Application and Rest API
    2. Installing Raspberry Sensors
  • Usage:

    1. Access Website
    2. Access App - Flask
    3. Access Database Client - Adminer
    4. Communicate with your API - Flask
  • Information:

  • Maintainer



Installation:

1.Installing Web Application and Rest API

  • Using docker:
    1. Clone repository and go inside the repository folder "site-app-docker"
    git clone https://github.com/Fantaso/site-app-docker
    1. Build the docker images
    docker-compose build
    1. Initialize database used in the web app
    docker-compose run --rm app python manage.py db init
    1. Create the database mapping to migrate the database
    docker-compose run --rm app python manage.py db migrate
    1. Apply the migration changes detected to the database
    docker-compose run --rm app python manage.py db upgrade
    1. Add a test user to login into web app
    docker-compose run --rm app python manage.py addusers
    1. Add the crops data to the database
    docker-compose run --rm app python manage.py addcrops
    1. Add the licenses data to the database (licenses are string identifiers that allows to control which IoT sensors belongs to which user, and it is used for the IoT sensors to send the sensor data to the web app)
    docker-compose run --rm app python manage.py addlicenses
    1. Run the Docker containers
    docker-compose up

2. Installing Raspberry Sensors

Visit Raspberry Pi Repository



Usage:

Once docker-compose is done downloading all images and none of the services failed after you have run the containers with docker-compose up


1. Access Website

The web application should be running and you can access it in your web browser at http://0.0.0.0:5000 or at http://0.0.0.0:5000/site
which will take you to the website and there in the navigation bar you can find the login link.


2. Access App - Flask

Access the web app at http://0.0.0.0:5000/app
You will be prompt to enter Username and Password, which we have registered in Step # 6 of the installation. Or you could register a new user following the link at the login page.

Login information:


3. Access Database Client - Adminer

Access the database client at http://0.0.0.0:8080
You will be prompt to enter System, Server, Username, Password, Database which has been pre-configured within the web app at config.py and the docker-compose.yml files.

Login information:

  • System = PostgreSQL
  • Server = db
  • Username = postgres
  • Password = password
  • Database = mydb

4. Communicate with your API - Flask

Access the API at http://0.0.0.0:5000/agrimodule_api You can talk to the API if you have an API client like Postman in order to test and check how the process of registering a sensor or a pump controller into your web application.

  1. Check if the API is working at:

    • Method: GET
    • Url: /agrimodule_api/
  2. Check if IoT devices license is valid:

    • Method: GET
    • Url: /agrimodule_api/check/<identifier>
  3. Register IoT devices and get credentials:

    • Method: POST
    • Url: /agrimodule_api/register
    • Payload:
      • identifier = str
      • mac = str
    • Response:
      • username = str
      • password = str
  4. Send IoT devices data to web app database:

    • Method: POST
    • Url: /agrimodule_api/agrimodule/<agrimodule_id>/set-measurement
    • Payload:
      • agrimodule_id = int
      • timestamp = datetime
      • soil_ph = float
      • soil_nutrient = float
      • soil_temp = float
      • soil_humi = float
      • air_temp = float
      • air_humi = float
      • air_pres = float
      • solar_radiation = float
      • batt_status = int
      • lat = float
      • lon = float
  5. Get an IoT specific measurement from the web app:

    • Method: GET
    • Url: /agrimodule_api/agrimodule/<agrimodule_id>/get-measurement/<measurement_id>
  6. Get all data collected by an IoT device:

    • Method: GET
    • Url: /agrimodule_api/agrimodule/<agrimodule_id>/get-measurements
  7. Unregister IoT devices:

    • Method: GET
    • Url: /agrimodule_api/unregister/<identifier>/<mac>



Information:

Technology Stack
Python back-end back-end
Flask web-framework web-framework
SQLAlchemy orm orm
PostgreSQL database database
Docker container container
Docker-Compose container-manager container-manager
Adminer database-client database-client



Maintainer

Get in touch -–> fantaso.de

About

Company website & web app to setup, monitor & control farms and crops, IoT API to register sensors and send collecting data from field's weather and soil.


Languages

Language:Python 44.5%Language:HTML 37.5%Language:CSS 13.7%Language:JavaScript 3.4%Language:Jupyter Notebook 0.9%Language:Dockerfile 0.0%