Smart Agriculture System: Remote Mini‑Program Control and Real‑Time Dashboard

Programmer Xiao Meng details the design and implementation of a smart agriculture platform that uses a WeChat mini‑program for remote hardware control, a web‑based dashboard for real‑time monitoring, and a full stack of Spring Boot, Vue, UniApp, MQTT and TDengine technologies.

SpringMeng
SpringMeng
SpringMeng
Smart Agriculture System: Remote Mini‑Program Control and Real‑Time Dashboard

Project Overview

The author, a programmer known as Xiao Meng, built a smart agriculture system for a large farm. The solution includes a WeChat mini‑program that remotely manages various hardware devices and a large‑screen dashboard that visualizes greenhouse data in real time.

Backend Technology Stack

Spring Boot 2.7.x (stable) serves as the core framework, with Spring MVC providing RESTful APIs. Authentication and authorization are handled by Spring Security 5.7+ using JWT. Data access uses MyBatis‑Plus 3.5+ for simplified CRUD operations and Spring Validation for parameter checks.

Primary storage is MySQL 8.0+ (supports JSON fields for device metadata). Redis 6/7 caches device status, tokens and implements rate limiting. For massive sensor data, a time‑series database such as TDengine (recommended) or InfluxDB is used because MySQL performs poorly with high‑volume time‑series data. HikariCP is the default connection pool. Supporting libraries include Lombok, Hutool (recommended Chinese utility library), Jackson for JSON processing, EasyExcel for Excel export, and XXL‑Job (preferred over Quartz for its management UI) for scheduled tasks.

IoT and Communication

Device commands are sent via an MQTT client (Eclipse Paho or Aliyun IoT). Real‑time alerts and data are pushed to the mini‑program using Spring WebSocket. Third‑party APIs such as weather services are accessed with OkHttp or RestTemplate.

Frontend Admin Panel (Web)

The admin UI is built with Vue 3.4+ using the Composition API, Vite for fast hot‑module replacement, Vue Router for navigation, and Pinia for state management (replacing Vuex). Element Plus (2.5+) provides the component library. Data visualisation relies on ECharts 5.5+ for line charts, gauges and trend graphs, with optional DataV for animated numbers and decorative borders. HTTP requests use Axios 1.6+, date handling with dayjs, and utility functions from lodash‑es.

Mobile Frontend (WeChat Mini‑Program)

The user‑side app is developed with UniApp (latest stable) which packages the code for both WeChat mini‑programs and H5. UniApp leverages Vue 3, Vite (default build tool), and the uView‑Plus UI library (most mature UniApp component set). Lightweight charts are rendered with uCharts. Network requests are wrapped by uni‑ajax / luch‑request, and real‑time push uses uni.connectSocket (WebSocket). Pinia manages state on the mini‑program side.

Middleware, Deployment and Tooling

MQTT broker: EMQX (recommended) or Mosquitto, supporting >50,000 concurrent connections.

Reverse proxy and load balancing: Nginx 1.24+.

Containerisation: Docker Compose provides one‑click deployment of MySQL, Redis, EMQX and Nginx.

Object storage for farm images: Alibaba Cloud OSS or MinIO.

Version control: Git with GitEE/GitHub.

API testing: Postman or Apifox (Apifox syncs documentation).

API documentation: Knife4j (enhanced Swagger).

Build tool: Maven 3.8+.

Code style: Alibaba Java Coding Guidelines (IDEA plugin).

Functional Requirements – User Side (Mini‑Program)

Dashboard showing greenhouse count, device totals, online/offline status and today’s alerts.

Quick controls for common devices (e.g., fan on/off, curtain).

Weather integration for farming decisions.

Greenhouse monitoring screen with real‑time temperature, humidity, light, CO₂, soil moisture and EC values.

Device status visualisation and historical trend curves.

Manual and mode‑based device control, with permission checks.

Alarm pop‑ups, message centre, and acknowledgment with remarks.

Farm and crop management (switch farms, view crop variety, planting time, growth stage, record farming activities with text and images).

Personal centre (password change, account binding, work orders, logout).

Functional Requirements – Admin Side (Web)

Farm management (info, greenhouse list, map with device locations).

Device management (inventory, status, configuration, optional firmware upgrade).

Data collection and storage (historical tables/curves, export, retention policies).

Automation strategies (IF‑THEN rule engine, timed tasks, enable/disable, priority, execution logs).

Crop management (catalog, farm‑crop binding, growth‑stage reminders).

Personnel management (roles, permissions, operation logs).

Alarm management (rules, recipients, history, statistics).

Greenhouse big screen (2D/3D layout, KPI overview, optional video streams).

Statistical reports (device online/failure rates, environmental averages, farming operation stats, energy consumption).

IoT and Automation Integration

Sensors include air temperature/humidity, soil moisture, light intensity, CO₂, rain, wind speed. Controllers manage fans, pumps, curtains, valves and supplemental lighting. Smart gateways support MQTT, CoAP and Modbus TCP for data upload and command delivery. Device shadows store the latest state, while a time‑series DB stores historical sensor data. The system implements reconnection, data retransmission and ensures manual control overrides automatic policies, includes timeout confirmations and double‑confirmation for critical devices.

Technical Selection Rationale

TDengine is chosen for sensor data because of its high compression ratio and fast query performance compared with MySQL.

Redis hash stores device state per ID, enabling millisecond‑level reads.

WebSocket provides push capability for alerts and data to the mini‑program.

MQTT QoS 1 guarantees command delivery, preventing packet loss.

XXL‑Job offers a management UI, simplifying operations over Quartz.

Conclusion

The article presents a complete end‑to‑end architecture and detailed component choices for building a smart agriculture platform, covering backend services, frontend and mobile interfaces, IoT communication, data storage, deployment and functional modules. The author invites collaborators for similar development projects.

Spring BootVueTDengineSmart AgricultureMQTTuniapp
SpringMeng
Written by

SpringMeng

Focused on software development, sharing source code and tutorials for various systems.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.