Resumen
La agricultura inteligente es un tema con un alto interés por su demostrada eficacia en la reducción de costes y el aumento de la producción de plantaciones. Internet de las Cosas (IoT) y, en particular, el tratamiento de los datos recabados por los sensores IoT en “el borde” (edge) mejora la calidad del servicio que estos sistemas pueden ofrecer. A pesar de las ventajas para acelerar la entrega de software que, enfoques y principios como DevOps y GitOps, han reportado en el desarrollo de sistemas distribuidos basados en la nube, su incorporación en el desarrollo y despliegue de sistemas IoT Edge es escasa. Algunas de estas ventas son: despliegues rápidos, confiables y automatizados, mejora de la calidad del software, mayor control de las versiones y detección anticipada ante cualquier desviación, una rápida vuelta a atrás frente a cualquier imprevisto o error en producción, y el registro de auditoría de los despliegues y ejecuciones.
Por lo tanto, en este TFM se propone la creación de un sistema de agricultura inteligente que regule el riego de una plantación tomando las decisiones conforme a los datos recabados y enviados por sensores situados en dicha plantación. Estos datos serán procesados por un computador situado en el borde que tomará la decisión de si es necesario iniciar el riego o detenerlo conforme a los datos que se han recogido en ese momento en la plantación. Esta decisión será transmitida a los actuadores que ejecutarán la instrucción habilitando o denegando el riego de la plantación. Los datos sensorizados se mostrarán mediante un panel web accesible por el agricultor en tiempo cuasi real y sin estar presente en la plantación. El ciclo software estará gestionado por varios flujos de integración continua y despliegue continuo (CI/CD) siguiendo los principios y buenas prácticas promovidas por DevOps y GitOps para, así, automatizar, acelerar y mejorar el despliegue de dicho software. La gestión y orquestación de los nodos edge se realizará haciendo uso de la plataforma Kubernetes, la cual se ha convertido en los últimos años en un estándar de facto para el despliegue de aplicaciones de nube nativas. En particular, al tratarse de un sistema IoT Edge, se contemplará el uso de implementaciones Kubernetes para dispositivos con restricciones computacionales, como KubeEdge, lo que facilitará la replicación y actualización de los nodos cuando sea necesario.
El hardware asociado a los dispositivos de la capa física está basado en el microcontrolador ESP32, en una Raspberry Pi 4B para la capa edge y una Raspberry Pi 3B para la visualización. El resto de los componentes se implementan en la nube con distintas soluciones. La comunicación entre la capa física y la de edge se lleva a cabo utilizando LoRa, y entre la capa edge y la de visualización mediante el protocolo MQTT. El funcionamiento de todos los dispositivos debe ser sencillo y modular para poder ser modificado o sustituido en caso de necesidad.
Los resultados y conclusiones del proyecto han sido positivos pues se han cumplido los principales requisitos impuestos al sistema con pocos fallos. El sistema es completo y funcional y se ha podido comprobar su correcto funcionamiento en campo. El uso de las tecnologías de desarrollo empleadas como parte de los principios DevOps y GitOps (CI/CD, Git, Kubernetes, virtualización, etc.) han permitido crear un sistema más robusto y mejor organizado, resistente a fallos y con un seguimiento mucho más sencillo. En definitiva, han permitido que el desarrollo de este sistema se lleve a cabo con mayor facilidad y rapidez.
Abstract:
Smart agriculture is a topic of high interest due to its proven effectiveness in reducing costs and increasing plantation production. Internet of Things (IoT) and, in particular, the processing of data collected by IoT sensors at the edge improves the quality of service that these systems can provide. The incorporation of DevOps and GitOps culture and principles is still scarce in the development and deployment of IoT Edge systems, despite the advantages for accelerating software delivery that have already been reported in the development of distributed cloud-based systems. Some of these sales are: fast, reliable, and automated deployments, improved software quality, greater version control and early detection of any deviations, fast rollback against any unforeseen events or bugs in production, and audit logging of deployments and executions.
Therefore, in this master’s thesis, we propose the creation of an intelligent agriculture system that regulates the irrigation of a plantation taking decisions according to the data collected and sent by sensors located in the plantation. These data will be processed by a computer located at the edge of the plantation, which will decide whether to start or stop irrigation based on the data collected at that time in the plantation. This decision will be transmitted to the actuators that will follow the instruction by enabling or denying irrigation to the plantation. The data will be displayed on a web panel from which the farmer can consult them in real time and without being present at the plantation. The software cycle will be managed by several flows of continuous integration and deployment (CI/CD), following the principles and best practices promoted by DevOps and GitOps to automate, accelerate, and improve the deployment of the software. The management and orchestration of edge nodes will be performed using the Kubernetes platform, which has become in recent years the de facto standard for the deployment of cloud native applications. In particular, being an IoT Edge system, the use of Kubernetes implementations for computationally constrained devices, such as KubeEdge, will be contemplated, which will facilitate the replication and upgrade of the nodes when needed.
The hardware associated with the physical layer devices is based on the ESP32 microcontroller, the edge layer on a Raspberry Pi 4B, and the visualization on a Raspberry Pi 3. The rest of the components are in the cloud with different solutions. Communications between the physical layer and the edge are carried out using LoRa and between the edge and visualization using the MQTT protocol. The operation of all devices must be simple and modular, so that they can be modified or replaced if necessary.
The conclusions have been positive, as the main requirements imposed on the system have been met with few failures. The system is complete and functional, and it has been possible to verify its correct operation in the field. The use of the employed development technologies as part of the DevOps and GitOps principles (CI/CD, Git, Kubernetes, virtualization, etc.) has allowed us to create a more robust and better organized system, resistant to failures and with much easier monitoring. In short, they have allowed the development of this system to be carried out more easily and quickly.