Skip to content
pedrovilaca.dev
Read this page in Portuguese

pedro/projects/horta-inteligente

Horta Inteligente

ESP8266 with a soil moisture sensor publishing over MQTT, and a React Native app that shows soil moisture in real time and opens or closes the irrigation valve.

IoTAcademic

Context

Horta Inteligente ("Smart Garden") was a Computer Engineering interdisciplinary project at PUC Minas. At first, the project was called HortaControlApp.

Problem

The goal: monitor soil moisture remotely and trigger the irrigation from a phone, without having to walk over to the pot.

Solution

On the hardware side, an ESP8266 NodeMCU reads an analog soil moisture sensor on pin A0 and converts the reading to a 0 to 100% scale. Irrigation is triggered through pin D0, which would drive a relay or a valve; in the prototype, an LED plays that role.

For communication, I went back to MQTT (with the PubSubClient library), using HiveMQ's public broker:

  • the ESP8266 publishes the moisture every second to the …/umidade topic;
  • the ESP8266 subscribes to the …/status topic and reacts to the abrir (open) and fechar (close) messages.

In the app, built with React Native 0.62, the screen shows the moisture in real time, the irrigation state, and two buttons to open or close the valve.

App screen: soil moisture at 37.78%, irrigation closed, and the “Abrir irrigação” (Open irrigation) and “Fechar irrigação” (Close irrigation) buttons.
The React Native app, with the moisture read from the MQTT topic.

Outcome and lessons learned

The prototype worked with manual control from the app: the ESP8266 publishes the moisture, the app subscribes and sends the command to open or close the irrigation valve.

The app screen displays the message "Irrigação ligará ao atingir 10% de umidade" ("Irrigation will turn on at 10% moisture"), but that rule was not implemented in the firmware. Automatic irrigation remained a planned next step: the ESP8266 already has the reading and the actuation; what's missing is the logic that connects one to the other.

The project confirmed what I had seen in my student research at CEFET-MG: with a broker in the middle, the device and the app don't need to know about each other; they just need to agree on the topics.