Skip to content

bawfng04/DADN-SmartGreenhouseSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

216 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌿 Smart Greenhouse IoT System

Smart Greenhouse Node.js React Native PostgreSQL Python

An intelligent IoT greenhouse monitoring and control system with AI-powered automation

Table of Contents

✨ Features

🔍 Real-time Monitoring

  • Environmental Sensors: Temperature, Humidity, Soil Moisture, Light intensity
  • Live Dashboard: Real-time data visualization with charts and graphs
  • Historical Analytics: Track trends and patterns over time
  • WebSocket Integration: Instant updates without page refresh

🤖 Smart Automation

  • AI-Powered Control: Machine learning models for optimal device control
  • Automatic Mode: Intelligent responses based on sensor readings
  • Scheduled Control: Time-based automation with custom schedules
  • Manual Override: Complete manual control when needed

🎛️ Device Management

  • LED Control: Smart lighting with intensity adjustment (0-100%)
  • Fan Control: Ventilation management with variable speed (0-100%)
  • Water Pump: Automated irrigation system with flow control (0-100%)

🔔 Smart Alerts

  • Threshold Monitoring: Custom alerts for sensor values
  • Reminder System: Scheduled notifications and maintenance reminders
  • Alert History: Track all notifications and system events

🛠️ Tech Stack

Backend

  • Runtime: Node.js with Express.js
  • Database: PostgreSQL with connection pooling
  • Real-time: WebSocket (ws library)
  • IoT Platform: Adafruit IO with MQTT
  • Authentication: JWT tokens
  • Environment: dotenv configuration

Frontend

  • Framework: React Native with Expo
  • Language: TypeScript
  • UI Library: React Native Paper
  • Navigation: Expo Router
  • State Management: React Query
  • Charts: React Native Chart Kit & Gifted Charts

Machine Learning

  • Language: Python 3.x
  • Framework: Scikit-learn
  • Algorithm: Random Forest Classifier
  • Features: Environmental sensor data processing
  • Devices: LED, Fan, Water Pump control prediction

DevOps & Deployment

  • Deployment: Render.com (Backend), Expo (Frontend)
  • Version Control: Git
  • Package Management: npm (Node.js), pip (Python)

Project Setup

1. Clone the Repository

git clone https://github.com/bawfng04/DADN-SmartGreenhouseSystem.git
cd DADN-SmartGreenhouseSystem

2. Database Setup

  1. Install PostgreSQL and create a database.

  2. Import database schema:

    • Navigate to backend/src/database/create.sql
    • Copy the SQL content and execute it in your PostgreSQL database
    • Or run: psql -U postgres -d <database name> -f backend/src/database/create.sql

3. Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Install the dependencies:

    pip install -r requirements.txt && npm install
  3. Configure the environment variables:

    • Create a .env file in the backend directory with the following content:
    # Port to run the server on
    PORT = <yours>
    
    # Postgres connection - For local database
    POSTGRES_HOST=localhost
    POSTGRES_PORT=5432
    POSTGRES_DB=<yours>
    POSTGRES_USER=<yours>
    POSTGRES_PASSWORD=<yours>
    
    # Postgres connection - For hosted database (comment out when running locally)
    # POSTGRES_HOST=<yours>
    # POSTGRES_PORT=<yours>
    # POSTGRES_DB=<yours>
    # POSTGRES_USER=<yours>
    # POSTGRES_PASSWORD=<yours>
    # DB_SSLMODE=require
    # POSTGRES_EXTERNAL_URL=<yours>?ssl=tr
    
    # Secret key for encrypting password
    SECRET_KEY=<yours>
    
    # Secret key for token
    JWT_SECRET_KEY=<yours>
    
    # Adafruit IO configuration
    ADAFRUIT_IO_USERNAME=<yours>
    ADAFRUIT_IO_KEY=<yours>
    
    # Frontend URL
    FRONTEND_URL=<yours>
    
    
  4. Start the backend server:

    npm run dev

For complete API documentation, see backend/README.md.

4. Frontend Setup

  1. Navigate to the frontend directory:
    cd frontend
  2. Install the dependencies:
    npm install
  3. Configure the environment variables:
    • Create a .env file in the frontend directory with the following content:
      API_URL = <yours>
      WEBSOCKET_URL = <yours>
      
  4. Start the frontend application:
    npx expo start

📁 Project Structure

DADN-SmartGreenhouseSystem/
├── backend/                    # Node.js Backend
│   ├── src/
│   │   ├── controllers/        # API route handlers
│   │   ├── models/            # Database models
│   │   ├── services/          # Business logic
│   │   ├── repository/        # Data access layer
│   │   ├── routes/            # Route definitions
│   │   ├── utils/             # Utilities (MQTT, etc.)
│   │   ├── database/          # Database configuration
│   │   └── GreenhouseModel/   # AI prediction models
│   ├── .env                   # Environment variables
│   ├── server.js              # Entry point
│   └── package.json
│
├── frontend/                   # React Native Frontend
│   ├── app/                   # App screens (Expo Router)
│   ├── components/            # Reusable components
│   ├── constants/             # App constants
│   ├── contexts/              # React contexts
│   ├── hooks/                 # Custom React hooks
│   ├── utils/                 # Utility functions
│   ├── assets/                # Static assets
│   ├── .env                   # Environment variables
│   └── package.json
│
├── Machine learning model/     # Python ML Models
│   ├── fan_control/           # Fan control model
│   ├── led_control/           # LED control model
│   ├── pump_control/          # Pump control model
│   └── README.md
│
└── README.md                  # This file

About

A mobile-first platform leveraging Adafruit IO for IoT connectivity, enabling real-time smart greenhouse monitoring & control, built with React Native and Node.js.

Topics

Resources

Stars

Watchers

Forks

Contributors