Skip to content

Tapuz97/smartplant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒฑ SmartPlant - AI-Powered Cloud Plant Monitoring System

Note: This project is designed to run on Google Colab for optimal performance and cloud integration.

๐Ÿ“‹ Overview

SmartPlant is a comprehensive cloud-based plant monitoring system that combines IoT sensors, AI-powered plant disease detection, and gamification to help users maintain healthy plants. The system integrates real-time sensor data from AdaFruit IO with Google's Gemini AI for intelligent plant care recommendations.

โœจ Features

  • Real-time Monitoring: Track temperature, humidity, soil moisture, and light levels
  • AI Plant Assistant: RAG-powered chatbot using Google Gemini for plant care advice
  • Disease Detection: Computer vision model for plant disease identification from photos
  • Gamification: Points, badges, challenges, and leaderboards to encourage plant care
  • Historical Analytics: View trends and patterns in sensor data over time
  • Social Features: Connect with friends, compete on leaderboards
  • Multi-plant Management: Monitor multiple plants simultaneously

๐Ÿš€ Running on Google Colab

Prerequisites

  1. Google Account with Colab access
  2. API Keys (see Configuration section)
  3. AdaFruit IO Account (for sensor data)
  4. Firebase Project (for database)

Setup Instructions

  1. Upload Project to Google Drive

    - Upload the entire `smartplant` folder to your Google Drive
    - Note the path to your project folder
    
  2. Open in Google Colab

    # Mount Google Drive
    from google.colab import drive
    drive.mount('/content/drive')
    
    # Navigate to project directory
    %cd /content/drive/MyDrive/smartplant
  3. Install Dependencies

    !pip install -r requirements.txt
  4. Configure API Keys

    • Edit SmartPlant_backend/keys.json with your credentials:
    {
      "ADAFRUIT": {
        "username": "your_username",
        "aio_key": "your_aio_key"
      },
      "NGROK": "your_ngrok_token",
      "TREFLET": "your_trefle_api_key",
      "GEMINI": "your_gemini_api_key",
      "FIREBASE": "firebase-credentials"
    }
  5. Run the Application

    # Run main.py in Colab
    %run main.py
  6. Access the Web Interface

    • The ngrok tunnel URL will be displayed in the output
    • Copy the URL and open it in your browser
    • Example: https://your-tunnel.ngrok-free.app

๐Ÿ”ง Configuration

Required API Keys

Service Purpose Get Key From
AdaFruit IO IoT sensor data io.adafruit.com
Ngrok Public tunnel for web access ngrok.com
Trefle.io Plant species database trefle.io
Google Gemini AI chatbot (RAG) ai.google.dev
Firebase Database & authentication console.firebase.google.com

Firebase Setup

  1. Create a new Firebase project
  2. Enable Firestore Database
  3. Download service account credentials JSON
  4. Place in SmartPlant_backend/ directory
  5. Update path in keys.json

AdaFruit IO Setup

  1. Create feeds for: temperature, humidity, soil-moisture, light
  2. Configure MQTT or HTTP integration
  3. Add credentials to keys.json

๐Ÿ“ Project Structure

smartplant/
โ”œโ”€โ”€ main.py                          # Main entry point (run in Colab)
โ”œโ”€โ”€ requirements.txt                 # Python dependencies
โ”œโ”€โ”€ DATABASE_SCHEMA.md               # Database design documentation
โ”œโ”€โ”€ SmartPlant_backend/
โ”‚   โ”œโ”€โ”€ BackendManager.py           # Central service coordinator
โ”‚   โ”œโ”€โ”€ NgrokManager.py             # Flask server + ngrok tunnel
โ”‚   โ”œโ”€โ”€ FirebaseManager.py          # Database operations
โ”‚   โ”œโ”€โ”€ AdaFruitManager.py          # IoT sensor integration
โ”‚   โ”œโ”€โ”€ RAG.py                      # Retrieval-Augmented Generation
โ”‚   โ”œโ”€โ”€ GEM.py                      # Google Gemini AI wrapper
โ”‚   โ”œโ”€โ”€ DetectionManager.py         # Plant disease detection
โ”‚   โ”œโ”€โ”€ TrefletManager.py           # Plant species API
โ”‚   โ”œโ”€โ”€ SearchEngine.py             # Knowledge base search
โ”‚   โ”œโ”€โ”€ Helpers.py                  # Utility functions
โ”‚   โ”œโ”€โ”€ fakes.py                    # Mock data generators
โ”‚   โ”œโ”€โ”€ ngrokConfig.json            # Route configuration
โ”‚   โ”œโ”€โ”€ ApiConfig.json              # API endpoint mapping
โ”‚   โ”œโ”€โ”€ backendConfig.json          # Backend settings
โ”‚   โ””โ”€โ”€ keys.json                   # API credentials (NOT in git)
โ””โ”€โ”€ SmartPlant_frontend/
    โ”œโ”€โ”€ index.html                  # Landing page
    โ”œโ”€โ”€ dashboard.html              # Main plant dashboard
    โ”œโ”€โ”€ chat.html                   # AI assistant chat
    โ”œโ”€โ”€ status.html                 # Historical data & charts
    โ”œโ”€โ”€ my_garden.html              # Gamification & social
    โ”œโ”€โ”€ app.js                      # Frontend application logic
    โ”œโ”€โ”€ api.js                      # API client
    โ”œโ”€โ”€ style.css                   # Styling
    โ””โ”€โ”€ smartplanticon.svg          # Logo/favicon

๐ŸŒ API Endpoints

Authentication

  • POST /api/login - User login validation

Sensor Data

  • GET /api/sensor/data - Get current/historical sensor readings
  • GET /api/sensor/thresholds - Get alert thresholds
  • POST /api/sensor/thresholds - Update alert thresholds

Plants

  • GET /api/plants?user_id=<id> - Get user's plants
  • POST /api/plants - Add new plant

AI Assistant

  • POST /api/rag/query - Chat with AI (text + optional image)

Gamification

  • GET /api/tasks - Get daily/weekly tasks
  • POST /api/tasks/toggle - Complete a task
  • GET /api/badges?user_id=<id> - Get user badges
  • GET /api/challenges - Get available challenges
  • GET /api/garden/summary - Get user stats summary

Social

  • GET /api/friends - Get friends list
  • GET /api/leaderboard - Get ranked users

๐Ÿ› ๏ธ Technology Stack

Backend

  • Python 3.8+ - Core language
  • Flask - Web framework
  • Firebase Firestore - NoSQL database
  • Google Gemini - AI language model
  • Transformers - Plant disease detection
  • NLTK - Natural language processing
  • Paho MQTT - IoT communication
  • BeautifulSoup - Web scraping for knowledge base

Frontend

  • Vanilla JavaScript - No frameworks
  • Chart.js - Data visualization
  • Lucide Icons - UI icons
  • CSS Variables - Dark/light theme

Infrastructure

  • Google Colab - Cloud compute environment
  • Ngrok - Public tunneling
  • AdaFruit IO - IoT platform
  • Firebase - Cloud database

๐Ÿ“Š Database Schema

See DATABASE_SCHEMA.md for detailed collection structures.

Main Collections:

  • users - User accounts & stats
  • plants - Plant metadata & current readings
  • sensorreadings - Time-series sensor history
  • tasks / usertasks - Daily/weekly challenges
  • badges / userbadges - Achievements
  • queries - Chat history
  • friends - Social connections
  • leaderboard - Ranked user stats

๐ŸŽฎ Usage Guide

First Time Setup

  1. Create an account on the landing page
  2. Add your first plant from the dashboard
  3. Configure sensor thresholds in the Status page
  4. Connect IoT sensors to AdaFruit IO feeds
  5. Start monitoring and complete challenges!

Daily Workflow

  1. Check dashboard for plant health status
  2. Review sensor readings and charts
  3. Use AI chat for plant care questions
  4. Upload plant photos for disease detection
  5. Complete daily challenges for points

Gamification

  • Earn points by completing tasks
  • Unlock badges for achievements
  • Compete with friends on leaderboards
  • Maintain streaks for daily logins

๐Ÿ” Troubleshooting

Ngrok Tunnel Issues

# Kill existing tunnels
!pkill ngrok

# Restart the application
%run main.py

Firebase Connection Errors

  • Verify credentials JSON path
  • Check Firebase project permissions
  • Ensure Firestore is enabled

Sensor Data Not Updating

  • Check AdaFruit IO feed status
  • Verify MQTT credentials
  • Test sensor hardware connections

AI Chat Not Responding

  • Verify Gemini API key
  • Check API quota limits
  • Review error messages in console

๐Ÿค Contributing

This is an academic project. For questions or suggestions, contact the development team.

๐Ÿ“ License

Academic project - Braude College of Engineering Cloud Computing Course - Semester 7

๐Ÿ‘ฅ Authors

Braude College Software Engineering Students Cloud Computing Course - 2025

๐Ÿ™ Acknowledgments

  • AdaFruit - IoT platform and sensors
  • Google Gemini - AI language model
  • Trefle.io - Plant database API
  • Firebase - Cloud infrastructure
  • Ngrok - Tunneling service

๐Ÿšจ Important Notes for Google Colab

Session Management

  • Colab sessions timeout after 12 hours of inactivity
  • Save your work frequently to Google Drive
  • Ngrok tunnel URL changes on each restart

Performance Tips

  • Use GPU runtime for faster ML model inference
  • Cache frequently accessed data in memory
  • Minimize file I/O operations

Security Warnings

  • Never commit keys.json to version control
  • Use environment variables for production
  • Rotate API keys regularly
  • Keep Firebase credentials secure

Resource Limits

  • Colab has memory and compute limits
  • Optimize large dataset processing
  • Consider upgrading to Colab Pro for extended sessions

Ready to grow? ๐ŸŒฟ Start monitoring your plants with SmartPlant!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors