🌿 PlantCare — Smart Plant Health Monitoring System

A full-stack IoT-inspired smart plant health dashboard with real-time sensor monitoring, AI-based health analysis, automation controls, and trend visualization.

✨ Features

FeatureDetails
šŸ“Š Live DashboardSoil moisture, temperature, humidity with progress bars
🚨 Smart AlertsColor-coded warnings (🟢 Healthy / 🟔 Moderate / šŸ”“ Critical)
🧠 AI DecisionsStress level analysis with actionable suggestions
āš™ļø AutomationAuto watering & cooling fan toggle controls
šŸ“ˆ Trend ChartLine graph of last 20 readings (Chart.js)
šŸ—ļø ArchitectureSystem diagram showing full IoT data flow
šŸ“” REST APIPOST sensor data from real Arduino/ESP32

šŸ—ļø System Architecture

Rendering mermaid diagram...

šŸ“ Project Structure

plant-health-monitor/
ā”œā”€ā”€ main.ts              # HTTP entrypoint
ā”œā”€ā”€ backend/
│   ā”œā”€ā”€ index.ts         # Hono routes
│   └── database.ts      # SQLite queries
ā”œā”€ā”€ shared/
│   └── types.ts         # Types + AI health analysis
└── frontend/
    ā”œā”€ā”€ index.html       # HTML shell
    ā”œā”€ā”€ style.css        # Green eco theme
    └── app.tsx          # React dashboard

šŸ”Œ API Endpoints

GET /api/status

Returns latest sensor reading + AI health analysis + automation state.

GET /api/history?limit=20

Returns last N readings for chart rendering.

POST /api/reading

Ingest real sensor data from Arduino/ESP32:

{ "soilMoisture": 45, "temperature": 28, "humidity": 60 }

POST /api/simulate

Generate a simulated sensor reading (for demo/testing).

GET|POST /api/automation

Read or update watering/fan automation state.

šŸ¤– AI Health Logic

ConditionScoreAlert
Moisture < 20%+3🚨 Critical dry
Moisture < 40%+1āš ļø Low moisture
Temp > 38°C+3šŸ”„ Critical heat
Temp > 32°C+1šŸŒ”ļø Too warm
Temp < 10°C+2🄶 Too cold
Humidity < 30%+1šŸ’Ø Dry air
Humidity > 85%+1šŸŒ§ļø Fungal risk
  • Score 0 → Healthy 🟢
  • Score 1–2 → Moderate 🟔
  • Score 3+ → Critical šŸ”“

🌱 Connecting a Real Sensor (Arduino/ESP32)

// Arduino / ESP32 snippet #include <WiFi.h> #include <HTTPClient.h> HTTPClient http; http.begin("https://your-val-endpoint.web.val.run/api/reading"); http.addHeader("Content-Type", "application/json"); String body = "{\"soilMoisture\":" + String(moistureVal) + ",\"temperature\":" + String(tempVal) + ",\"humidity\":" + String(humidityVal) + "}"; int code = http.POST(body);