IoT Plant and Environment Monitor

A complete IoT system for monitoring home environment and plant moisture levels, hosted at crabdance.milescb.com. The project combines embedded systems, web development, and backend services to create a real-time monitoring solution running on a Raspberry Pi Zero 2W with ESP8266-based sensor nodes.

Motivation

Home plant care and environmental monitoring require consistent attention and manual measurement. This project automates the monitoring process, providing real-time data visualization and historical tracking accessible from anywhere via the web. The system demonstrates practical applications of IoT architecture, including sensor networks, message queuing protocols, database management, and web service deployment.

System Architecture

Hardware Components

Raspberry Pi Zero 2W Server:

ESP8266 Sensor Nodes:

Software Stack

Frontend:

Backend:

Networking:

Technical Implementation

Sensor Network

The ESP8266 nodes use the custom PlantMonitor library to interface with multiple sensors:

Data Pipeline

  1. Data Collection: ESP8266 sensors publish readings to MQTT topics
  2. Data Ingestion: Python subscriber service listens to MQTT broker and writes to SQLite
  3. Data Storage: Time-series data stored with timestamps and sensor identifiers
  4. Data Retrieval: REST API queries database and serves JSON responses
  5. Data Visualization: Frontend JavaScript fetches API data and renders charts/displays

Deployment Configuration

The system supports two deployment options:

Free Domain with Port Forwarding:

Cloudflare Tunnel (Recommended):

Key Features

Security Considerations

The project implements multiple security layers:

Warning: Port forwarding exposes devices to potential attacks. The Cloudflare Tunnel approach is recommended for enhanced security without exposing home network ports.

Technical Challenges Solved

  1. Analog Multiplexing: Overcame ESP8266’s single analog input limitation to read multiple moisture sensors
  2. Service Reliability: Implemented systemd services for automatic restart and system integration
  3. Database Performance: Optimized SQLite queries for efficient time-series data retrieval
  4. Web Concurrency: Used Gunicorn with gevent workers to handle multiple simultaneous API requests
  5. Network Security: Balanced external accessibility with home network security through Cloudflare Tunnel

Resources

Future Enhancements