
External
mohamed1920said/Greenhouse_edge_AI
This repository is an experimental greenhouse monitoring and control project built around an ESP32-class controller.

This repository is an experimental greenhouse monitoring and control project built around an ESP32-class controller.
Central is an open-source printed circuit board by mohamed1920said, from the mohamed1920said/Greenhouse_edge_AI repository on GitHub. It is a 2-layer board with 13 parts on 93 nets.
It is built around the HLK-5M05, HLK-5M12 and AM2302, with the SEN-13322 and RT314A05 among its other parts. It belongs with the ESP32 boards of this library.
This repository is an experimental greenhouse monitoring and control project built around an ESP32-class controller. It combines environmental sensors, relay-driven actuators, MQTT/Node-RED connectivity, over-the-air updates, persistent setpoints, and an Edge Impulse anomaly model. It also contains the project's firmware history and KiCad hardware designs.
The project is a prototype, not a finished safety controller. The firmware and PCB directories contain several generations with different assumptions. Start with code section/final/final.ino for the most integrated implementation, then verify it against the exact PCB and board you intend to use before compiling or wiring anything.
DHT22 + BH1750 + soil + flow + AC-voltage + DS1302
|
v
ESP32 tasks
sensors / control / AI / MQTT
| |
v v
heater, fan, pump, MQTT broker
humidifier, light and Node-REDThe current final.ino uses FreeRTOS tasks to:
Setpoints are stored in ESP32 Preferences/NVS and survive a restart.
| Path | Contents |
|---|---|
code section/final/final.ino | Integrated firmware and the recommended starting point for review. |
code section/V0 through V6, and V8 through V11 | Historical firmware iterations. V7 is not present; these are alternatives, not modules to compile together. |
code section/TEST PCB/CODE/CODE.ino | PCB-oriented test firmware. |
code section/logger/ | Python serial logger and an example CSV log. |
code section/LIBRARY/GreenhouseDashboard .zip | Archived dashboard-related project files. |
ia library/ei-mohamed_said-project-1-arduino-1.0.11.zip | Exported Edge Impulse Arduino inference library used by final.ino. |
LIBRARY/ | Archived SimpleTimer and DHT library packages used during earlier iterations. |
NODE RED/flows.json | Node-RED flow export. Review broker and topic settings before importing. |
PCB/central/ | KiCad central-board design and backups. |
PCB/central/external/ | KiCad external-board design, a nested pfe design, and backups. |
iot-dashboard, PCB/central/.history, PCB/central/external/.history | Gitlink entries whose referenced repositories are not configured in this repository. |
Do not assume that a pin map or sensor type from an older V* directory matches final.ino; variants in this repository use different hardware and dependencies.
The three Gitlink entries above are stored like submodules, but there is no .gitmodules file with their source URLs. A normal clone therefore cannot retrieve their contents with git submodule update; the original repository locations would need to be identified and configured first.
The following table describes only code section/final/final.ino:
| Function | GPIO | Notes |
|---|---|---|
| BH1750 SDA / SCL | 8 / 9 | I2C address 0x23. |
| DHT22 data | 4 | DHTTYPE is DHT22. |
| Soil-moisture analog input | 14 | Mapped from raw dry 3200 and wet 1100 to 0-100%; recalibrate for the actual probe. |
| Water-flow pulse input | 10 | Interrupt input with pull-up; conversion assumes 7.5 pulses per flow-rate unit. |
| Heater relay | 5 | Active low in the helper functions. |
| Fan relay | 6 | Active low. |
| Irrigation-pump relay | 7 | Active low. |
| Humidifier output | 15 | Active high, unlike the other actuator relays. |
| Light relay | 16 | Active low. |
| Red alarm LED | 42 | Driven high during configured lockout conditions. |
| AC-voltage analog input | 3 | Uses a firmware calibration factor of 237.0; requires a safe isolated sensing circuit. |
| DS1302 CLK / DAT / RST | 11 / 12 / 13 | Three-wire RTC connection. |
These GPIO numbers are board-specific. Select an ESP32 variant that exposes them, check boot/strapping and ADC restrictions, and compare this table with the selected KiCad revision before connecting hardware.
Use an Arduino-compatible ESP32 development environment and install the libraries required by final.ino:
ThreeWire.h and RtcDS1302.h;ia library/ei-mohamed_said-project-1-arduino-1.0.11.zip; andLibrary and ESP32-core versions are not pinned. Record known-good versions after the first successful build.
final.ino, replace WIFI_SSID, WIFI_PASS, MQTT_SERVER, and MQTT_PORT with values for the deployment network. Do not publish real credentials in source control.192.168.4.1:1883 without authentication or TLS.NODE RED/flows.json, then inspect all nodes and broker settings before deploying the flow. The exported flow targets HiveMQ Cloud over TLS on port 8883, while final.ino targets 192.168.4.1:1883 without TLS or authentication; the two configurations will not interoperate unchanged.code section/final/final.ino, open a serial monitor at 115200, and validate sensor readings.connectWiFi() blocks until the configured network becomes available. A wrong SSID/password therefore prevents the remaining setup from completing.
The device uses these topics:
| Direction | Topic | Purpose |
|---|---|---|
| Device to broker | greenhouse/data | Sensor values, actuator state, anomaly result, mode, setpoints, and manual commands. |
| Broker to device | greenhouse/commands | Mode, setpoint, and actuator-command changes. |
Example automatic-mode configuration:
{
"mode": "AUTO",
"temp_low": 18,
"temp_high": 26,
"hum_low": 50,
"lux_low": 50,
"moist_low": 30
}Example manual command:
{
"mode": "MANUAL",
"heater": false,
"fan": true,
"pump": false,
"humid": false,
"light": true
}Telemetry includes temp, humid, lux, moist, water_flow, mains_voltage, the five *_state fields, anomaly_score, diagnosis, mode, hour, the current setpoints, and the five cmd_* fields. Invalid DHT readings are published as JSON null.
The checked-in defaults are 18-26 deg C, 50% minimum humidity, 50 lux minimum light, and 30% minimum soil moisture. In automatic mode:
The AI input repeats temperature, humidity, soil moisture, light, and water-flow values across the model frame. Rule-based diagnoses take priority for invalid DHT data, pump-without-flow, flow-without-pump, low temperature while heating, and low humidity while humidifying. An anomaly score above 3.0 otherwise produces a warning.
The controller switches off selected loads and lights the red LED when measured AC voltage is between 10 V and 190 V, or when the diagnosis contains CRITICAL. This logic is an application safeguard, not certified electrical protection.
isDaytime = true; automatic lighting is therefore not actually limited to the stated day period.CRITICAL path explicitly switches off only the heater and pump; it does not force every actuator off..gitmodules configuration, so the dashboard and history content they reference is not reproducible from this repository alone.Heaters, pumps, humidifiers, grow lights, relays, water, and mains sensing create fire, shock, flooding, and equipment hazards. Use isolated and correctly rated power supplies, relay/driver modules, fuses, grounding, enclosures, strain relief, emergency shutoff, and independent temperature/water-level protection. Keep low-voltage electronics separated from mains and wet areas. Test with safe dummy loads first, and do not operate this prototype unattended or use it as the only protection for plants, property, or people.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | RT314A05 | Relay_THT:Relay_SPDT_Schrack-RT1-16A-FormC_RM5mm | FAN1, HEATER1, HUMIDIFIRE1, PUMP1 |
| 2 | ESP32-S3-DEVKITC-1U-N8R8 | ESP32-S3-DEVKITC-1U-N8R8(1):MODULE_ESP32-S3-DEVKITC-1U-N8R8 | ESP32#1, ESP32#2 |
| 1 | AM2302 | Sensor:ASAIR_AM2302_P2.54mm_Vertical | DHT22 |
| 1 | GROW_LIGHT | Relay_THT:Relay_SPDT_Schrack-RT1-16A-FormC_RM5mm | K5 |
| 1 | HLK-5M05 | Converter_ACDC:Converter_ACDC_HiLink_HLK-5Mxx | PS1 |
| 1 | HLK-5M12 | Converter_ACDC:Converter_ACDC_HiLink_HLK-5Mxx | PS2 |
| 1 | SEN-13322 | soil moist:SEN-13322 | SOIL_MOIST1 |
| 1 | Screw_Terminal_01x02 | TerminalBlock_Philmore:TerminalBlock_Philmore_TB132_1x02_P5.00mm_Horizontal | POWER1 |
| 1 | ZC362800_ | bh1750:ZC362800_ | BH1750 |

mohamed1920said/Greenhouse_edge_AI
This repository is an experimental greenhouse monitoring and control project built around an ESP32-class controller.








13 parts, built around the HLK-5M05, HLK-5M12, AM2302 and SEN-13322. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the mohamed1920said/Greenhouse_edge_AI repository on GitHub, at the commit this page was made from: the board is PCB/central/central.kicad_pcb and its schematic PCB/central/central.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask mohamed1920said before reusing the design.