Back to Resources

IoT for Greenhouses: A Practical Guide with ESP32

IoT system with ESP32 in a greenhouse

If you have ever woken up at 3 AM wondering whether the nutrient pump is still running, this article is for you. IoT technology turns that anxiety into real-time data you can check from your phone.

What is IoT and why does it matter in agriculture

Internet of Things (IoT) means connecting physical objects to the internet so they report data automatically. Instead of walking to the greenhouse with a thermometer and a pH meter every four hours, your sensors do it for you every minute.

The difference between manual and automated monitoring is not just convenience. It is the difference between discovering that pH climbed to 7.5 when you arrive in the morning (after your plants have been stressed for 8 hours) versus getting an alert on your phone at 11 PM and correcting it immediately.

Real ROI: A single undetected pump failure can ruin an entire harvest. A basic IoT system costs $100-200 USD. A lettuce crop is worth $1,500-3,000 USD. The math is simple.

Why ESP32

The ESP32 is a coin-sized microcontroller with built-in WiFi. It costs between $5 and $10 USD, consumes less power than an LED bulb, and can read dozens of sensors simultaneously.

Unlike Arduino (which needs external WiFi modules) or Raspberry Pi (which is more expensive and consumes more power), the ESP32 is designed specifically for IoT applications. It has built-in WiFi and Bluetooth, enough memory to handle multiple sensors, and a massive developer community sharing open-source code.

The ESP32-S3 variant offers even more RAM, better processing, and Bluetooth Low Energy (BLE) for mobile applications. It is the recommended choice for new projects in 2026.

Common sensors for hydroponics

A basic IoT system for hydroponics needs these sensors:

Chemical sensors

  • pH: Analog electrode ($15-30) or Atlas Scientific EZO-pH ($50-80). Typical range 4.0-9.0, accuracy ±0.1. Requires monthly calibration with buffer solutions 4.01, 7.00, and 10.01.
  • EC/TDS: Conductivity probe ($20-60). Measures nutrient concentration. Atlas Scientific EZO-EC offers automatic temperature compensation.

Physical sensors

  • DS18B20: Submersible temperature sensor ($3-5). Range -55°C to +125°C, accuracy ±0.5°C. OneWire protocol allows chaining multiple sensors on a single pin.
  • DHT22 or BME280: Ambient temperature and humidity ($5-15). BME280 also measures barometric pressure.
  • YF-S201: Water flow sensor ($5-10). Measures liters per minute. Essential for detecting clogs or pump failures.
  • JSN-SR04T: Waterproof ultrasonic level sensor ($8-12). Measures distance to the water surface in a cistern. Waterproof version of the classic HC-SR04.

Total cost: A complete system with pH, EC, water temperature, ambient temperature, flow, and level costs between $80-120 USD in components. Add $20-30 for a waterproof enclosure, power supply, and wiring.

Basic architecture of an IoT system

A functional IoT system has five components:

  1. Sensors — read physical parameters (pH, temperature, etc.)
  2. Microcontroller (ESP32) — reads sensors, processes data, sends via WiFi
  3. MQTT Broker — server that receives and distributes messages (Mosquitto is the most popular)
  4. Database — stores historical data (PostgreSQL, InfluxDB)
  5. Dashboard — web/mobile interface for visualization and control

Why MQTT

MQTT (Message Queuing Telemetry Transport) is the standard protocol for IoT. Unlike HTTP (designed for web pages), MQTT is optimized for bandwidth-constrained devices.

Devices publish messages to "topics." For example:

  • hydro/sensors/ph{"value": 6.2, "timestamp": "2026-02-15T14:30:00Z"}
  • hydro/sensors/ec{"value": 1.8, "timestamp": "2026-02-15T14:30:00Z"}
  • hydro/sensors/temp_water{"value": 22.5, "timestamp": "2026-02-15T14:30:00Z"}

Other services "subscribe" to those topics and receive data automatically. Think of it as a push notification system for sensors.

Reading frequency

There is no point in reading pH every second. Reservoir water changes slowly. A typical strategy:

  • Internal reading: every 30 seconds (to average out noise)
  • MQTT report: every 1-5 minutes (reduces network traffic)
  • DB storage: every 5 minutes (reduces writes, sufficient for charts)

Critical sensors like flow can report every 30 seconds. Alerts fire immediately when a value crosses a threshold.

From DIY to professional platform

Here is the part nobody tells you when you start with IoT: building the hardware is the easy part. The hard part is the software.

Wiring a DS18B20 sensor to an ESP32 takes 30 minutes. Building a platform that handles:

  • SMS/email alerts when pH goes out of range
  • Historical charts for the last 30 days
  • Trends and predictions (machine learning)
  • Multi-user access with permissions (owner, operator, viewer)
  • Remote control of pumps and valves
  • Integration with billing systems
  • Automated PDF reports for certifications

...that takes hundreds of hours of development. And then you have to maintain it, update it, and provide support.

The smart approach

If your business is growing lettuce, focus on growing lettuce. Not on becoming a full-stack developer.

Invynex connects with your existing ESP32 hardware. You keep full control of your sensors and actuators. We give you the professional platform:

  • Web and mobile dashboard (iOS + Android)
  • Smart alerts with machine learning
  • Unlimited history with interactive charts
  • Remote control with role-based permissions
  • Automated reports for ISO, HACCP, GLOBALG.A.P.
  • Integration with your POS, inventory, and billing

Your focus: optimize pH, improve yield, reduce waste. Our focus: making the technology work 24/7 so you do not have to think about it.

Additional resources

References

  1. Lakhiar, I. A., Jianmin, G., Syed, T. N., Chandio, F. A., Buttar, N. A., & Qureshi, W. A. (2018). Monitoring and control systems in agriculture using intelligent sensor techniques: A review of the aeroponic system. Journal of Sensors, 2018, 1–18. https://doi.org/10.1155/2018/8672769
  2. Espressif Systems. (2023). ESP32 technical reference manual. https://www.espressif.com/en/products/socs/esp32
  3. Light, R. A. (2017). Mosquitto: Server and client implementation of the MQTT protocol. Journal of Open Source Software, 2(13), 265. https://doi.org/10.21105/joss.00265
  4. Resh, H. M. (2022). Hydroponic food production (8th ed.). CRC Press.

Related Articles

Technology What is SCADA and Why Your Greenhouse Needs It Essential Guide The 7 Metrics Every Hydroponic Grower Must Monitor Beginners How to Start Hydroponics: A Beginner's Guide

Already have sensors? Connect them to Invynex

Invynex integrates with ESP32 hardware and gives you the professional platform your greenhouse needs. From smart alerts to automated reports. Free technical consultations — contact us.

Schedule Demo