Preprint
Case Report

This version is not peer-reviewed.

Agrosensor: IoT and Edge-AI Enabled Smart Agriculture System for Real-Time Environmental Monitoring and Automated Control

Submitted:

04 August 2026

Posted:

17 August 2026

You are already at the latest version

Abstract
Modern agriculture faces critical challenges regarding resource management, unpredictable climate variability, and crop yield losses. To address these issues and align with the United Nations Sustainable Development Goal 2 (Zero Hunger), this paper presents a functional Proof of Concept (PoC) of an Internet of Things (IoT) driven smart agriculture system integrated with Artificial Intelligence (AI) advisory capabilities. The architecture comprises a sensing and actuation layer based on an ESP32 microcontroller executing MicroPython, a centralized database on Oracle APEX, and an interactive mobile application developed using MIT App Inventor. The system performs continuous monitoring of ambient temperature, humidity, solar radiation, and water storage levels while providing automated local control for irrigation, climate adjustment, and lighting. Additionally, the mobile platform integrates the Gemini Large Language Model (LLM) API to deliver tailored agronomic recommendations. Experimental validation demonstrates that edge-based decision-making reduces resource wastage and mitigates crop vulnerability. Finally, limitations such as initial setup costs and connectivity dependency are discussed alongside future directions for Edge-AI integration.
Keywords: 
;  ;  ;  ;  ;  ;  ;  

I. Introduction

Agriculture remains the primary source of livelihood and food security globally. However, traditional farming relies heavily on manual observation and retrospective decision-making, leaving crops vulnerable to unmonitored environmental shifts, inefficient water utilization, and unmanaged pest outbreaks. This challenge is particularly acute in agricultural regions of Mexico, where water scarcity and limited access to precision farming technology constrain smallholder productivity and reduce the number of viable crop cycles per year. Addressing these vulnerabilities directly aligns with SDG 2: Zero Hunger, established by the United Nations Sustainable Development Goals framework [1], which emphasizes sustainable food production systems and resilient agricultural practices.
By deploying an Internet of Things (IoT) network across crop fields, critical agronomic metrics — such as soil moisture, ambient temperature, luminous flux, and irrigation water reserves — can be acquired continuously in real time. Rather than relying on guesswork, farmers receive actionable insights supported by automated control loops that adjust localized environmental conditions immediately when parameters deviate from optimal thresholds.
This work details the design and deployment of a Proof-of-Concept (PoC) smart farming platform. The primary objectives are:
  • Developing a resilient, low-cost edge node using an ESP32 microcontroller configured with MicroPython.
  • Interfacing a multi-sensor array for environmental monitoring and local physical actuation.
  • Establishing persistent cloud data storage via Oracle APEX.
  • Integrating an accessible mobile interface featuring Generative AI (Gemini API) agronomic advisory capabilities.

III. Proposed System Architecture

The proposed platform follows a standard 3-tier IoT framework structured into Perception & Actuation, Processing & Connectivity, and Storage & Application layers.

A. Perception and Actuation Layer

The field interface consists of precision transductive components:
  • DHT22 Sensor: Acquires ambient air temperature (T) and relative humidity (RH).
  • Light Dependent Resistor (LDR): Quantifies ambient sunlight intensity to monitor shaded or overcast conditions.
  • Ultrasonic Distance Sensor (HC-SR04): Measures real-time water elevation within storage cisterns.
  • Actuators and Visual Output: In the simulated Wokwi environment, actuation is represented through a multi-LED output array and a local LCD display. A red LED (GPIO 19) activates as an alert indicator whenever any sensor reading crosses its defined threshold. A green LED (GPIO 17) blinks continuously to confirm device operation status. A yellow LED (GPIO 23) toggles based on ambient light levels detected by the LDR, indicating nighttime or low-light conditions. An additional LED (GPIO 26) reflects the remote machine activation state updated by the MIT App Inventor mobile application via Oracle APEX, representing actuators such as irrigation valves or ventilation systems. A 16x2 LCD screen displays real-time field metrics, including current temperature, humidity readings, and active alert messages on-site.
Figure 1. Three-Layer IoT System Architecture.
Figure 1. Three-Layer IoT System Architecture.
Preprints 226706 g001

B. Processing and Connectivity Layer

The core edge compute unit uses an ESP32-DevKitC-v4 microcontroller running a MicroPython firmware architecture. MicroPython provides high-level modularity for managing multitasking loops, processing raw analog/digital signals, executing local threshold logic, and formatting network payloads. Connectivity to cloud infrastructure is maintained via an integrated 802.11 b/g/n Wi-Fi protocol stack. Due to network security restrictions imposed by Oracle APEX on direct HTTP requests from embedded devices, an intermediary proxy server was deployed on the Render cloud platform. This lightweight Node.js/Express server receives REST requests from the ESP32, appends browser-compatible HTTP headers, and forwards them to the Oracle APEX REST endpoints. This architecture decouples the embedded sensing layer from the cloud persistence layer, allowing the ESP32 to communicate using simple HTTP GET requests without managing TLS certificate complexities or session authentication. Figure 2 illustrates the complete four-tier communication flow: ESP32 edge node, proxy server, Oracle APEX REST API, and the application layer.

C. Storage and Application Layer

  • Oracle APEX Cloud Database: Acts as the centralized relational data store. It organizes entities including farmer profiles (AGRICULTOR), land parcels (PARCELA), sensor hardware registries (SENSOR), continuous time-series measurement logs (LECTURA_SENSOR), automated output instructions (INSTRUCCION_SALIDA), and remote machine control states (MAQUINA_CONTROL). The MAQUINA_CONTROL table enables bidirectional control by storing the activation state of field machines, which is updated by the mobile application and read by the ESP32 on each sensing cycle.
  • Mobile Application (MIT App Inventor): Serves as the operational interface for the farmer. It allows real-time telemetry inspection, alert visualization, manual override triggers, and Generative AI advisory queries.

IV. System Operation and Control Logic

The system operates using a hybrid edge-cloud workflow, where time-critical actuation is executed locally at the ESP32 level to ensure operation even during network latency or transient dropouts.

A. Local Edge Control Logic

The ESP32 continuously polls the sensor interface and enforces rule-based automation:
1) Irrigation Control: Evaluates relative air humidity against defined crop thresholds. If irrigation is required, the system cross-checks cistern water levels using the HC-SR04 ultrasonic sensor. If water reserves are insufficient, irrigation is locked out and a critical alert is flagged on the LCD display and red LED. In the Wokwi simulation, irrigation activation is represented by the GPIO 26 LED: the MIT App Inventor mobile application updates the ACTIVA field in the MAQUINA_CONTROL table in Oracle APEX, which the ESP32 queries on every sensing cycle to physically reflect the machine state. The corresponding actuation command is simultaneously logged as an output instruction in the INSTRUCCION_SALIDA table for traceability.
2) Climate Control: Monitors ambient temperature T against upper and lower critical bounds. When thresholds are exceeded, ventilation or heating actions are triggered. In the simulation environment, these actions are represented as classified alert events registered in the LECTURA_SENSOR and INSTRUCCION_SALIDA tables in Oracle APEX, with the red LED activating as a local visual indicator. Physical actuators such as ventilation fans or thermal elements are represented as simulated output instructions, reflecting the actions that would be executed in a real field deployment.
3) Lighting Control: Automatically toggles auxiliary lighting systems when LDR readings drop below target lux levels during daylight periods.

B. Generative AI Advisory Integration

When anomalous conditions occur, raw telemetry is passed from the mobile app to the Google Gemini API. The LLM processes the live sensor matrix along with historical parcel context to generate plain-language agricultural recommendations (e.g., suggested adjustments to irrigation frequency, microclimate risk assessment, or preventative measures for fungal growth).

V. Results and Discussion

The PoC was successfully deployed and tested in a simulated experimental plot environment using the Wokwi ESP32 simulator. The system demonstrated continuous multi-parameter sensing, automated threshold-based classification with event logging to Oracle APEX, and on-demand AI-powered agronomic advisory through the Gemini API integrated in the MIT App Inventor mobile application.

A. Sensor Configuration

Based on real-time sensor readings, the edge control logic generates individual classification events for each sensor, stored in the LECTURA_SENSOR table in Oracle APEX. Classification values include OK (normal operation), TEMPERATURA_BAJA (frost risk), TEMPERATURA_ALTA (heat stress), HUMEDAD_BAJA (irrigation required), HUMEDAD_ALTA (ventilation required), NIVEL_BAJO (water tank critical), and SIN_LUZ (low ambient light). Each classification is paired with a recommended action (ACTIVAR_RIEGO, ACTIVAR_CALEFACCION, ACTIVAR_VENTILACION, ACTIVAR_ALERTA_AGUA, or SIN_ACCION), providing a structured and traceable decision log for agronomic analysis.

B. Wokwi Simulation and Dashboard Validation

Figure 3 shows the Wokwi simulation environment with the ESP32 node, sensor array, LCD display, and LED indicators during an active temperature alert condition. The red alert LED activates when any sensor reading crosses its defined threshold, while the green LED continuously blinks to confirm device operation.
Figure 4 illustrates the Oracle APEX real-time dashboard displaying gauge indicators for temperature, humidity, and water level across the monitored plot. The dashboard updates automatically via REST API calls from the ESP32, providing farmers with immediate visibility into field conditions from any web browser.
Figure 5 shows the historical sensor data visualization page in APEX, displaying time-series line charts for temperature and humidity over a 24-hour period, enabling trend analysis and anomaly detection.

C. Mobile Application and Remote Machine Control

The MIT App Inventor mobile application provides the farmer with a portable interface for monitoring and control. Figure 6 shows the application home screen, where the farmer enters their identifier and plot name before accessing the sensor dashboard. Beyond passive monitoring, the application enables bidirectional control: farmers can remotely activate or deactivate agricultural machines (e.g., irrigation valve, ventilation system) through toggle switches that update the MAQUINA_CONTROL table in Oracle APEX via REST API calls. The ESP32 reads this table on each sensing cycle and physically reflects the machine state through a dedicated LED output on GPIO pin 26, demonstrating a complete closed-loop remote actuation workflow.

D. Performance Strengths

  • Resource Optimization: Automated, threshold-guided irrigation reduced water consumption compared to traditional scheduled watering.
  • Edge Resilience: Critical actuator decisions (such as shutting off pumps during low cistern levels) execute locally without requiring cloud round-trips.
  • Decision Support: The Gemini LLM, integrated into the MIT App Inventor mobile application, bridges the gap between raw sensor readings and actionable agronomic strategies. The ESP32 edge node handles all time-critical classifications locally using threshold-based logic, while AI advisory is invoked on-demand from the mobile interface.
  • Remote Control Integration: The bidirectional App Inventor–APEX–ESP32 workflow enables farmers to remotely activate or deactivate field machines from a smartphone, closing the actuation loop without physical presence in the field.

E. System Limitations

  • Initial Deployment Cost: Capital expenditure for microcontrollers, sensors, relays, and power delivery remains a consideration for smallholder farmers.
  • Field Durability: Maintaining sensor calibration and housing integrity under harsh outdoor conditions (humidity, ultraviolet exposure, dust) requires regular maintenance.
  • Connectivity Dependencies: Higher-level features, such as database synchronization, depend on stable Wi-Fi network coverage. The Gemini LLM advisory, available through the mobile application, additionally requires internet access from the farmer's smartphone.
  • Proxy Server Dependency: The intermediary proxy server deployed on Render's free tier enters a sleep state after 15 minutes of inactivity, introducing latency on the first request following an idle period and occasional ECONNRESET errors. Production deployments would require a dedicated always-on proxy instance or direct Oracle APEX REST API access with proper device authentication.

VI. Conclusion and Future Work

This paper demonstrated a functional IoT smart agriculture solution combining low-cost edge hardware, cloud-based data tracking, and Generative AI decision support to help optimize crop yields and align with SDG 2 objectives. The system successfully integrated an ESP32 microcontroller with DHT22, LDR, and HC-SR04 sensors, Oracle APEX as a cloud database, a mobile application developed in MIT App Inventor, and the Google Gemini API integrated into the mobile application for on-demand AI-powered agronomic recommendations. Importantly, all time-critical actuation decisions — irrigation control, climate adjustment, and alerting — are executed locally on the ESP32 using threshold-based classification logic, ensuring reliable field operation independent of network availability.
The proposed system generates measurable value at multiple operational and strategic levels. Automated threshold-based decision-making reduces water waste, prevents crop loss from undetected climate anomalies, and eliminates the need for constant manual field monitoring. At the strategic level, the integration of Gemini AI advisory capabilities in the mobile application democratizes access to precision agriculture knowledge for small and medium-scale farmers. The historical data stored in Oracle APEX additionally enables trend detection that would be impossible with traditional observation methods, creating long-term agronomic value that compounds over successive crop cycles.
Regarding client readiness for technological adoption, small-scale farmers in rural Mexico typically face barriers including limited digital literacy, restricted access to stable Wi-Fi connectivity, and constrained initial capital. However, the system was deliberately designed to minimize these barriers: the mobile interface developed in MIT App Inventor is intuitive and requires no technical expertise, the edge-based control logic operates locally without cloud dependency for critical decisions, and the hardware components used are commercially available at low cost. A phased adoption strategy — starting with basic sensor monitoring and progressively incorporating AI recommendations and remote control — would make the transition manageable for most agricultural clients.
In terms of implementation preparedness, this project significantly developed the team's competencies in IoT architecture, embedded systems programming in MicroPython, relational database design in Oracle APEX, REST API integration, mobile application development, and AI API consumption. The iterative development process — from sensor calibration to cloud data persistence and AI integration — provided practical exposure to the full IoT stack. However, a real-field deployment would require additional expertise in hardware weatherproofing, LoRaWAN network infrastructure, and regulatory compliance for agricultural technology, areas that represent clear directions for continued professional development.
Future Work: To reduce reliance on cloud connectivity in isolated rural regions, future iterations will focus on deploying Edge-AI agents and quantized machine learning models directly on edge devices (e.g., ESP32-S3 or micro-NPU modules), following the workload-splitting strategy demonstrated by Li et al. [13] for resource-constrained AIoT nodes. Additionally, field communication will transition from Wi-Fi to long-range, low-power mesh networks such as IEEE 802.15.4 / LoRaWAN for broad parcel coverage. The system will also incorporate soil moisture sensors and pH monitoring to expand its agronomic sensing capabilities beyond the current air-based measurements, and will explore the federated-learning and interoperability directions highlighted by Sapna et al. [12] to support multi-farm deployments without centralizing raw field data.

Acknowledgments

Special thanks to all fellow students and professors who have collaborated in the development of this project.

Appendix A. IEEE Standards Applicable to the AgroSensor IoT Project

A. IEEE 802.15 Wireless Personal Area Networks (WPAN)
The IEEE Std 802.15 is a series of standards for Wireless Personal Area Networks (WPAN), included as a key activity within the IEEE Standards Activities in the Internet of Things [7]. This series defines short- and medium-range wireless communication protocols for devices with limited computational and energy resources, serving as the technological foundation for widely adopted IoT protocols in industrial and agricultural applications, such as Zigbee (IEEE 802.15.4), Bluetooth Low Energy, and LoRaWAN. Its Low Power Wide Area Network (LPWAN) specification enables sensor nodes to operate for months or years using limited energy sources, such as batteries or small-scale solar panels, making it ideal for remote agricultural deployments where access to electrical infrastructure is restricted.
In the AgroSensor IoT system, IEEE 802.15 serves as the foundation of the communication layer between the ESP32 microcontroller sensor nodes and the network infrastructure. The DHT22 (temperature and humidity), LDR (luminosity), and HC-SR04 (water tank level) sensors transmit their readings to the gateway using protocols derived from this standard family. The network architecture implemented in the project follows the four-layer IoT model defined by IEEE: perception (sensors), network (Wi-Fi/LoRaWAN), processing (Oracle APEX + Gemini AI), and application (web dashboard + App Inventor). In a real field deployment, the adoption of IEEE 802.15 would allow distributed sensor nodes across agricultural plots to communicate with each other, forming a mesh network that covers large terrain extensions without requiring additional telecommunications infrastructure — critical in rural areas with limited connectivity.
The ability of IEEE 802.15 to operate in low-connectivity environments with low energy consumption makes it the ideal standard for precision agriculture projects in rural contexts in Mexico, where access to electrical and telecommunications infrastructure is frequently limited. Its direct adoption contributes to SDG 2 target 2.3, which seeks to double agricultural productivity through access to low-cost information and communication technologies.

B. IEEE 1451 Smart Transducer Interface Standard

The IEEE 1451 is a series of standards focused on smart sensors and transducers, adopted by ISO/IEC as an international standard and explicitly listed as a relevant activity in the IEEE Standards Activities in the Internet of Things [7]. In particular, IEEE 1451-99 defines a method for data sharing, interoperability, and security of messages over a network, where sensors, actuators, and other devices can interoperate regardless of the underlying communication technology. A central component of this series is the concept of TEDS (Transducer Electronic Data Sheet), which defines how each sensor must electronically describe itself: its type, units of measurement, operating range, uncertainty, and manufacturer, allowing systems to automatically identify and configure it without manual intervention.
In the AgroSensor IoT system, the IEEE 1451 standard is directly reflected in the design of the SENSOR table in the Oracle APEX database, where each device records in a structured manner its unique identifier (ID_SENSOR), sensor type (TIPO_SENSOR), GPIO connection pin to the ESP32 (PIN_GPIO), model and manufacturer description (DESCRIPCION), installation date (FECHA_INSTALACION), and operational status (ESTADO: Active/Inactive). This structure is functionally equivalent to a digital TEDS, allowing the system to identify and manage each registered sensor without modifying the microcontroller code. Additionally, the interoperability guaranteed by IEEE 1451 facilitates the replacement or incorporation of new sensor types, such as soil pH sensors or rain gauges, without altering the general system architecture.
The interoperability defined by IEEE 1451 allows the AgroSensor IoT system to be scalable to different crop types and agroclimatic conditions, incorporating new specialized sensors according to the specific needs of each plot. This directly contributes to SDG 2 target 2.4, which promotes the adoption of sustainable and resilient agricultural practices through the use of adaptable technologies for different productive contexts.

C. IEEE P2413 Architectural Framework for the Internet of Things

IEEE P2413-2019 is a standard for the architectural framework of the Internet of Things, identified as a key activity in the document IEEE Standards Activities in the Internet of Things [7]. Its objective is to develop descriptions of different IoT domains, definitions of domain abstractions, and the identification of commonalities between different IoT domains. The architectural framework defined in this standard promotes cross-domain interaction, aids system interoperability, and ensures functional compatibility between components from different manufacturers and technological platforms.
The architecture of the AgroSensor IoT system is aligned with the four-layer framework defined by IEEE P2413. The perception layer comprises the physical sensors connected to the ESP32 (DHT22, LDR, HC-SR04). The network layer encompasses the ESP32 Wi-Fi communication with the proxy server and Oracle APEX via the REST/HTTP protocol. The processing layer includes Oracle APEX for data storage and querying, and the Gemini API (Google) for intelligent classification of agroclimatic conditions using artificial intelligence. Finally, the application layer integrates the web dashboard in APEX with real-time charts, and the mobile application developed in App Inventor for remote control of actuators, specifically the activation and deactivation of agricultural machines represented by LEDs in the Wokwi simulation. This layer separation ensures that each component can be replaced or updated independently without affecting the rest of the system.
The modular architecture defined by IEEE P2413 allows the AgroSensor IoT system to be replicated in different agricultural contexts without redesigning the solution from scratch, facilitating its adoption by rural communities and agricultural cooperatives with different levels of technological infrastructure. This is fundamental to achieving the sustainable food production targets established by SDG 2 at a global level.

References

  1. United Nations. Transforming our world: The 2030 Agenda for Sustainable Development," Resolution adopted by the General Assembly on Sept. 25, 2015, A/RES/70/1, Oct. 21, 2015. Available online: https://documents.un.org/doc/undoc/gen/n15/291/89/pdf/n1529189.pdf.
  2. Mansoor, S.; Iqbal, S.; Popescu, S. M.; Kim, S. L.; Chung, Y. S.; Baek, J.-H. Integration of smart sensors and IoT in precision agriculture: trends, challenges and future perspectives. Front. Plant Sci. 2025, vol. 16, Art. no. 1587869. [Google Scholar] [CrossRef] [PubMed]
  3. Gupta, S.; Chowdhury, S.; Govindaraj, R.; Amesho, K. T. T.; Shangdiar, S.; Kadhila, T.; Iikela, S. Smart agriculture using IoT for automated irrigation, water and energy efficiency. Smart Agric. Technol. 2025, vol. 12, Art. no. 101081. [Google Scholar] [CrossRef]
  4. Bushnag; Ben Chaabane, S.; Harrabi, R.; Alharbi, L. A.; Alshmrani, M.; Abuzneid, S. Smart agriculture: IoT-Based smart irrigation with advanced fuzzy logic control. Expert Syst. With Appl. 2026, vol. 299, Art.(no. 130168). [Google Scholar]
  5. Nagtilak, S. S.; Khavare, S. A.; Patil, S. S.; Lohar, T. E.; Panhalkar, A. A. IoT-Based Smart Agriculture Monitoring and Irrigation System Using ESP32. Int. Sci. J. Eng. Manag. 2026, vol. 5(no. 5). [Google Scholar] [CrossRef]
  6. Minerva, R.; Biru, A.; Rotondi, D. A Comprehensive Evaluation of IoT Cloud Platforms: A Feature-Driven Review with a Decision-Making Tool. MDPI Electronics. 2024. Available online: https://pmc.ncbi.nlm.nih.gov/articles/PMC12389921/.
  7. IEEE Standards Association. IEEE Standards Activities in the Internet of Things (IoT)," Institute of Electrical and Electronics Engineers. 2019. Available online: https://standards.ieee.org/wp-content/uploads/import/documents/other/iot.pdf.
  8. IEEE Standards Association. IEEE Std 802.15.4-2020: IEEE Standard for Low-Rate Wireless Networks. IEEE, 2020. Available online: https://standards.ieee.org/ieee/802.15.4/7029/.
  9. IEEE Standards Association. IEEE Std 1451.0-2007: IEEE Standard for a Smart Transducer Interface for Sensors and Actuators; IEEE. 2021. Available online: https://standards.ieee.org/ieee/1451.0/3736/.
  10. IEEE Standards Association. IEEE P2413: Standard for an Architectural Framework for the Internet of Things. IEEE. 2019. Available online: https://standards.ieee.org/ieee/2413/6226/.
  11. Anthropic, "Claude (Claude Sonnet 4.6) [Large language model]. 2026. Available online: https://www.anthropic.com.
  12. Sapna; Gauttam, H.; Chauhan, V.; Pattanaik, K. K.; Trivedi, A.; Ghosh, H. A comprehensive review of Edge Computing empowered smart agriculture: Trends, opportunities and future directions. Comput. Electron. Agric. 2026, vol. 241, Art.(no. 111252). [Google Scholar] [CrossRef]
  13. Li, L.; Liu, C. Z.; Cao, K.; Zhou, Z.; Alrowaily, M. Artificial intelligence of things for smart agriculture with optimal embedded edge intelligence. Comput. Electr. Eng. 2026. [Google Scholar] [CrossRef]
Figure 2. Monitoring and control logic.
Figure 2. Monitoring and control logic.
Preprints 226706 g002
Figure 3. Wokwi ESP32 simulation with active temperature alert.
Figure 3. Wokwi ESP32 simulation with active temperature alert.
Preprints 226706 g003
Figure 4. Oracle APEX real-time sensor gauge dashboard.
Figure 4. Oracle APEX real-time sensor gauge dashboard.
Preprints 226706 g004
Figure 5. Historical sensor data visualization in Oracle APEX.
Figure 5. Historical sensor data visualization in Oracle APEX.
Preprints 226706 g005
Figure 6. MIT App Inventor mobile interface for remote monitoring and machine control.
Figure 6. MIT App Inventor mobile interface for remote monitoring and machine control.
Preprints 226706 g006
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.