GreenHouse P4
Autonomous controller · ESP32-P4 firmware

GreenHouse P4

Climate, irrigation and grow-light controller for a greenhouse. Up to 8 independent zones, 16 relay channels and 16 sensor profiles are configured from a 1024×600 touch display; automation works locally without cloud or permanent internet.

Work in progress. An experimental engineering project by the NARMOVION lab, not a finished product — expect bugs, changes and incomplete functionality; use at your own risk.
SoC: ESP32-P4 rev 1.3 Board radio: ESP32-C6 · Wi-Fi 6 UI: LVGL v9 IDF: v6.0.2 Firmware: greenhouse p4 0.8
Download full firmware · ZIP 7.8 MB
ESP-IDF v6.0.2 sources · without build and .git folders · build steps in README
Zones
8 climate
Relays
16 2×8 RS-485
Sensors
16 profiles
Inputs
16 discrete
Display
1024×600 touch
What it is

Local greenhouse controller

The device runs climate and irrigation in each zone against target setpoints with hysteresis, driving loads through two RS-485 relay modules (Modbus RTU). All logic runs on-device: settings are stored in NVS, and on each boot the controller writes a safe state to every relay. The loop starts about once a second; individual sensor polls can take longer.

Control loop · nominally 1 Hz

Poll inputs → pulse sensors → DS18B20 → PZEM → SDI-12 → I²C, then apply automation. Enabled actuator channels are assigned a role and zone.

Safety first

Low tank, leak and dry run block the pump and valves; rain, wind and limit switches block the corresponding vent direction. Manual control cannot override these interlocks.

Hardware platform

Board and compute

Compute

ESP32-P4 (rev 1.3) — main processor and UI. ESP32-C6 as an ESP-Hosted slave (SDIO) provides Wi-Fi 6. Board JC1060P470C.

Display

1024×600, MIPI-DSI, JD9165 controller, capacitive GT911 touch. LVGL v9 interface — 10 screens with a bottom navigation bar.

Wiring

Supported I/O interfaces

Sensors and actuators connect to the controller through dedicated interfaces. Below is the peripheral map per bus with ESP32-P4 pins.

I²C SDA 7 · SCL 8

  • SHT45 — air temp & humidity
  • SCD41 — CO₂
  • BH1750 — illuminance, lux

RS-485 / Modbus RTU UART3 · 26/27 · 9600

  • Relay module 1 — address 1, channels 1–8
  • Relay module 2 — address 2, channels 9–16
  • 16 discrete inputs — from the same modules

SDI-12 UART2 · GPIO 1 · 1200

  • Apogee SQ-500 — PAR
  • TEROS 12 — soil moisture and temperature
  • PHYTOS 31 — leaf wetness

1-Wire GPIO 20

  • DS18B20 — digital thermometers

Modbus UART1 · 45/47 · 9600

  • PZEM-004T — power and accumulated energy

Pulse inputs GPIO 46 / 2 / 3

  • Flow meter — GPIO 46
  • Anemometer Davis 6410 — GPIO 2
  • Rain gauge Davis 7852 — GPIO 3

ADC / ADS1115 analog

  • VH400 — soil moisture

4–20 mA current loop analog

  • WIKA A10 — water pressure
Discrete sensors (tank float, leak, door/vent reed switch, limit switches) are read as inputs of the RS-485 relay modules — they use no dedicated GPIO.
Pinout

ESP32-P4 pins

GPIOFunctionInterfaceParameters
7I²C SDAI²Csensors SHT45 / SCD41 / BH1750
8I²C SCLI²Cbus clock
26RS-485 TXUART39600 · isolated connector
27RS-485 RXUART3Modbus RTU · relay modules
1SDI-12UART21200 baud
201-Wire1-WireDS18B20; a 4.7 kΩ external pull-up is required for cable runs
45PZEM TXUART19600 · Modbus
47PZEM RXUART1energy metering
46Water flowPulseflow-meter counter
2WindPulseanemometer
3RainPulserain gauge
Actuators

16 relay channels

Two RS-485 relay modules (addresses 1 and 2, 8 channels each). Below is the default assignment; the role, zone, safe state and max on-time of each channel are configured on-screen. Channels 11–16 are free for expansion.

ChannelRoleTypeZoneModuleMax on-time
01PumpIrrigationZone 11 · addr 110 min
02ValveIrrigationZone 11 · addr 110 min
03Exhaust fanClimateZone 11 · addr 1—
04Intake fanClimateZone 11 · addr 1—
05HeaterClimateZone 11 · addr 1—
06HumidifierClimateZone 11 · addr 1—
07LightGrow lightZone 11 · addr 1—
08Vent openVentingZone 11 · addr 11 min
09Vent closeVentingZone 12 · addr 21 min
10Emergency cutoffSafetyZone 12 · addr 2—
11–16Not set——2 · addr 2—
Measurements

16 sensor profiles

Each profile sets the sensor type, bus, zone, address/channel and scale. All profiles are disabled by default and enabled as hardware is connected.

#SensorMeasuresDefault bus
1SHT45Air temperature + humidityI²C
2SCD41CO₂I²C
3Apogee SQ-500PARSDI-12
4BH1750Illuminance, luxI²C
5TEROS 12Soil moisture and temperatureSDI-12
6VH400Soil moistureADC
7DS18B20Temperature1-Wire
8Float switchTank water levelDiscrete
9Flow meterWater flowPulse
10Leak sensorLeakDiscrete
11Reed switchDoor / ventDiscrete
12PHYTOS 31Leaf wetnessSDI-12
13WIKA A10Water pressure4–20 mA
14PZEM-004TPower and accumulated energyModbus
15Davis 6410Wind speedPulse
16Davis 7852RainfallPulse
Discrete inputs have roles: low tank level, flow present, leak, rain, wind, door, vent open limit and vent close limit. Each input's polarity (direct/inverted) is configurable.
How it works

Automation logic by role

Climate, irrigation and light roles compare their zone measurement against setpoints; the pump follows open valves, while vent actuators are operated manually with protective interlocks. Rules start about once a second.

Heater
Turns on at T° < target − hysteresis, off at T° ≥ target + hysteresis.
Exhaust / Intake
Turn on at T° > target + hysteresis, off at T° ≤ target − hysteresis.
Humidifier
Turns on at humidity < target − hysteresis, off at humidity ≥ target + hysteresis.
Valve
Irrigation: opens when soil moisture < target threshold.
Pump
Turns on if at least one valve is open — and only when the tank isn't empty and there's no leak.
Light
With valid system time, turns on in hour ∈ [start, end) when illuminance < threshold; without time it remains off.
Manual control: tapping a configured relay turns it on/off for the selected manual timeout (15 minutes by default), after which the channel returns to automation. The max on-time (max on) forces the channel off on timeout.
Interlocks

Safety overrides everything

Fault conditions block their associated loads regardless of automation and manual mode. On boot the controller force-writes the configured safe state to all 16 channels, never trusting the cache.

Pump and valves

Switch off on low tank level, detected leak or a flow fault (dry run).

Vent opening

Blocked on rain or strong wind — limit switches and weather inputs prevent opening.

Dry-run protection

If the pump runs longer than 20 s with no flow detected, irrigation shuts off until the fault is cleared.

Interface

Ten screens on the touch display

Navigation is the bottom tab bar. Tap the tabs at the bottom of the display to switch screens — the mockup reproduces the firmware's real colours and layout.

GREENHOUSE P4  •  AUTONOMOUS GREENHOUSE
Active tab: Home · 10 screens total

Screen reference

01
Home
Zone cards: T°, humidity, CO₂, soil
02
Climate
T° / humidity setpoints, hysteresis
03
Water
Soil threshold, irrigation limit
04
Light
Grow-light schedule, lux threshold
05
Relays
Manual control of configured channels
06
Rules
Global automation toggle
07
Alarms
Safety statuses, input setup
08
Charts
Minute history of real zone readings
09
Sensors
Sensor profiles: type, bus, address
10
Settings
Relay config: role, zone, limit