Commercial smart climate controllers designed for grow tents often run anywhere from $150 to $400, and they frequently rely on closed, proprietary cloud platforms that stop working when your internet drops. Building your own system with an ESP32 microcontroller lets you run local, hardware-level climate logic. It gives you complete control over your grow environment for a fraction of the cost, using parts that are easy to replace.
Quick Answer
An ESP32 microcontroller paired with an I2C environmental sensor (such as the SHT31 or BME280) and an optocoupled relay board creates a dependable, local climate controller for under $30. Using open-source firmware like ESPHome, the device monitors temperature, humidity, and calculated Vapor Pressure Deficit (VPD), switching fans and heaters without relying on cloud services.
What You Need to Know: Why the ESP32?
The ESP32 is a low-power, 32-bit system-on-a-chip with built-in Wi-Fi and Bluetooth. It runs on a low operating draw (typically under 0.5 to 1 watt), features hardware timers, supports analog and digital I/O pins, and has enough processing power to handle local control loops, sensor data filtering, and cryptographic network protocols.
ESP32 CONTROLLER ARCHITECTURE
┌─────────────────────────────────┐
│ ESP32 NodeMCU │
│ (Runs ESPHome Local Logic) │
└───────┬─────────────────┬───────┘
I2C Bus (3.3V) │ │ GPIO Logic (5V/3.3V)
┌────────────────────────┘ └────────────────────────┐
▼ ▼
[Sensirion SHT31-D] [Optocoupled Relay Board]
(Temp, RH, VPD Metrics) (Exhaust, Dehum, Heaters)
Unlike basic smart plugs, which require internet access to send sensor pings to off-site cloud servers, an ESP32 runs its primary programming directly on the chip. Even if your home router fails, your home automation server crashes, or your internet drops, the microcontroller continues reading its sensors and triggering its relays on schedule.
Essential Components and Bill of Materials
You can put together this reliable DIY climate controller using standard components:
| Component | Function | Why It Matters |
|---|---|---|
| ESP32 Development Board | Main processor | Select a 30-pin or 38-pin NodeMCU-style development board with a USB-C port for easy programming. |
| Sensirion SHT31-D or Bosch BME280 | Temperature and RH sensing | Avoid cheap DHT11 or DHT22 sensors; they drift significantly and fail in high humidity. The SHT31 uses I2C communication and offers laboratory-grade reliability ($\pm 2\%$ RH accuracy). |
| Optocoupled 5V Relay Module | High-voltage switching | Mechanically isolates low-voltage microcontroller pins from dangerous 120V/240V mains power running to fans or heaters. |
| 5V 2A USB Power Supply | System power | Supplies clean, regulated power to the board and relay coils. |
Step-by-Step Build: Wiring and Assembly
Assembly requires basic breadboarding or soldering to connect your sensor bus and switching relays.
WIRING DIAGRAM REFERENCE:
ESP32 3V3 ────────────> SHT31 VIN
ESP32 GND ────────────> SHT31 GND
ESP32 D21 (SDA) ───────> SHT31 SDA
ESP32 D22 (SCL) ───────> SHT31 SCL
ESP32 5V (VIN) ────────> Relay VCC
ESP32 GND ────────────> Relay GND
ESP32 D18 ────────────> Relay IN1 (Exhaust Fan)
ESP32 D19 ────────────> Relay IN2 (Dehumidifier)
Step 1: Wire the I2C Sensor
The SHT31 sensor communicates with the ESP32 over the I2C protocol, which uses two signal lines: serial data (SDA) and serial clock (SCL).
- Connect the sensor’s VIN pin to the ESP32’s 3V3 (3.3-volt) output pin.
- Connect the sensor’s GND pin to an ESP32 GND pin.
- Connect the sensor’s SDA pin to the ESP32’s default I2C data pin (GPIO 21).
- Connect the sensor’s SCL pin to the ESP32’s default I2C clock pin (GPIO 22).
Step 2: Wire the Relay Module
The relay acts as an automated, heavy-duty light switch. It takes low-voltage signals from the ESP32 and uses them to mechanically open and close 120V mains circuits.
- Connect the relay board’s VCC pin to the ESP32’s 5V / VIN pin.
- Connect the relay board’s GND pin to a common system GND.
- Connect the control inputs (IN1, IN2) to general-purpose output pins, such as GPIO 18 and GPIO 19.
Firmware Configuration Using ESPHome
The easiest, most stable way to program your ESP32 is with ESPHome. It lets you write your configuration in a simple, human-readable YAML format, compile it, and flash it over USB or over-the-air (OTA) Wi-Fi.
Here is an example configuration that reads your sensor, calculates Vapor Pressure Deficit, and controls an exhaust fan based on humidity:
esphome:
name: tent-climate-node
esp32:
board: esp32dev
framework:
type: arduino
# Network Connections
wifi:
ssid: "Your_Home_WiFi"
password: "Your_Secret_Password"
# I2C Bus Configuration
i2c:
sda: 21
scl: 22
scan: true
# Sensor Inputs
sensor:
- platform: sht3xd
temperature:
name: "Tent Air Temperature"
id: tent_temp
humidity:
name: "Tent Relative Humidity"
id: tent_rh
address: 0x44
update_interval: 10s
# Automated VPD Calculation
- platform: template
name: "Tent Vapor Pressure Deficit"
unit_of_measurement: "kPa"
accuracy_decimals: 2
lambda: |-
float temp = id(tent_temp).state;
float rh = id(tent_rh).state;
float vpsat = 0.61078 * exp((17.27 * temp) / (temp + 237.3));
float vpair = vpsat * (rh / 100.0);
return vpsat - vpair;
# Output Relays
switch:
- platform: gpio
pin: 18
name: "Exhaust Fan Relay"
id: exhaust_fan
inverted: true
# Internal Logic (Runs standalone on the chip)
interval:
- interval: 15s
then:
- if:
condition:
lambda: 'return id(tent_rh).state > 65.0;'
then:
- switch.turn_on: exhaust_fan
else:
- switch.turn_off: exhaust_fan
Electrical Safety and Structural Considerations
When building DIY hardware that controls high-voltage devices, safety is non-negotiable:
- Enclose All Mains Connections: Never leave bare 120V or 240V wire terminals exposed to your grow tent. House your relay board, outlets, and the ESP32 in a proper non-conductive, flame-retardant electrical enclosure (such as an IP65 polycarbonate box).
- Match Equipment Loads to Relay Ratings: Budget mechanical relay boards are typically rated for 10 amps at 120V AC, but cheap inductive components can arc and fail. Avoid running high-load devices (like large portable air conditioners or 1,500W space heaters) directly through small project-board relays. Use the ESP32 relay only to trigger a dedicated, heavy-duty contactor or a UL-listed solid-state relay (SSR).
- Manage Cord Routing: Cut distinct openings for your high-voltage and low-voltage lines on opposite sides of the box. See Cable Management for Grow Tents: Aesthetic and Fire-Safe Power Layouts. Keeping sensor wires physically separated from mains cables protects sensitive data signals from electrical noise and interference.