climate-czar
climate-czar
프로젝트가 하는 일
Climate Czar의 본체는 Linux에서 동작하는 서버 시스템입니다. Raspberry Pi, Orange Pi, 일반 Linux 웹 서버처럼 PHP와 MySQL을 실행할 수 있는 환경에서 구동되며, 웹 기반 대시보드와 자동화 로직을 통해 온실 상태를 관리합니다.
서버는 온도, 습도, pH, EC, 조도, 플로트 스위치, 도어 스위치 같은 입력값을 읽고, 설정된 조건에 따라 팬, 히터, 조명, 펌프, 릴레이, 알림 스크립트 같은 출력을 제어합니다. 특정 센서나 스마트 플러그에 고정되지 않고, 명령줄에서 값을 읽거나 출력을 제어할 수 있으면 시스템에 통합할 수 있는 구조입니다.
CZ_Combo_Hub_v2는 온실 내부에 설치되는 ESP32 기반 현장 I/O 허브 펌웨어입니다. 서버가 모든 센서와 릴레이에 직접 배선되는 대신, Combo Hub가 현장에서 센서 값을 읽고 릴레이를 제어한 뒤 그 결과를 HTTP API 형태로 서버에 제공합니다.
이 허브는 DHT22 온습도 센서, BH1750 조도 센서, DS18B20 1-Wire 온도 센서, 디지털 입력, MCP23017 기반 릴레이 출력, OLED 표시 장치, LoRa slave 통신을 처리합니다. 즉, Climate Czar Server는 “언제 팬을 켤지, 어떤 조건에서 조명을 제어할지”를 판단하고, Combo Hub는 “현재 센서 값은 얼마인지, 릴레이를 실제로 켤지 끌지”를 수행합니다.
서버 아키텍처에서 중요한 점은 역할 분리입니다. Linux 서버는 판단, 기록, UI, 자동화 규칙을 담당하고, ESP32 Combo Hub는 온실 현장의 입출력을 담당합니다. 이 분리 구조 덕분에 Climate Czar는 서버 중심의 농업 IoT 시스템이면서도, 실제 온실 내부에는 독립적인 현장 제어 노드를 둘 수 있습니다.
이미지 출처 : AI 생성

이미지 출처 : https://github.com/larry-athey/climate-czar
WIZnet이 들어가는 위치
이 프로젝트에서 확인되는 WIZnet 제품은 W5500입니다. W5500은 ESP32 Combo Hub의 유선 Ethernet 경로를 담당합니다.
Combo Hub는 서버와 HTTP API로 통신해야 하므로 네트워크 연결이 안정적이어야 합니다. Wi-Fi는 설치가 쉽지만 온실처럼 습기, 금속 구조물, 긴 거리, 전원 노이즈가 있는 환경에서는 신호 품질이 흔들릴 수 있습니다. W5500 기반 Ethernet은 배선이 필요하지만, 서버가 주기적으로 센서 값을 읽고 릴레이를 제어하는 구조에서는 더 예측 가능한 통신 경로를 제공합니다.
W5500은 하드웨어 TCP/IP 스택을 내장한 Ethernet 컨트롤러이며, ESP32와 SPI로 연결됩니다. 네트워크 처리를 별도 칩에 맡길 수 있기 때문에 ESP32는 센서 수집, 릴레이 제어, LoRa 메시지 처리, OLED 표시 같은 현장 로직에 집중할 수 있습니다.
농업 IoT 시스템에서는 네트워크 안정성이 곧 제어 안정성으로 이어집니다. 팬, 히터, 조명, 펌프 같은 장치는 상태 판단이 늦거나 연결이 끊기면 작물 환경에 직접 영향을 줄 수 있습니다. W5500은 Climate Czar Server와 Combo Hub 사이에 안정적인 유선 제어 지점을 만드는 역할을 합니다.
구현 참고 사항
CZ_Combo_Hub_v2/CZ_Combo_Hub_v2.ino에는 W5500과 호환되는 Ethernet 라이브러리와 SPI 핀 설정이 포함되어 있습니다.
#include "UIPEthernet.h" // Ethernet interface library compatible with W5500 modules
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define ETH_CS 5이 코드는 ESP32가 W5500 모듈을 SPI 장치로 제어하기 위한 기본 연결 정보를 정의합니다. ETH_CS는 W5500의 chip select 핀이고, MOSI, MISO, SCK는 SPI 데이터 통신에 사용됩니다.
네트워크 초기화 흐름은 다음과 같이 구성됩니다.
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, ETH_CS);
Ethernet.init(ETH_CS);
if (Ethernet.linkStatus() == LinkON) {
cableConnected = true;
}
if (Ethernet.begin(ethMAC) > 0) {
ethConnected = true;
ethServer.begin();
}이 코드는 SPI 초기화, W5500 chip select 설정, Ethernet link 확인, DHCP 기반 IP 할당, Ethernet server 시작을 담당합니다. Climate Czar Server가 Combo Hub의 센서 값이나 릴레이 상태를 읽으려면, 먼저 이 Ethernet server가 정상적으로 실행되어야 합니다.
CZ_Combo_Hub_v2/web_api.h는 서버가 호출하는 HTTP API 요청을 처리합니다. 습도, 온도, 조도, 스위치, 릴레이, uptime 같은 요청을 각 센서 또는 출력 제어 함수로 분기합니다. 서버는 이 API를 통해 온실 현장의 상태를 읽고, 필요한 경우 릴레이 출력을 변경합니다.
실무 팁 / 주의점
- W5500은 ESP32와 SPI로 연결되므로 MOSI, MISO, SCK, CS 배선을 짧고 안정적으로 유지하시는 것이 좋습니다.
- 온실은 습기와 긴 케이블이 많은 환경이므로 RJ45 커넥터, 전원, 릴레이 배선에는 방수와 고정 처리가 필요합니다.
- DHCP는 설치가 쉽지만, 서버가 Combo Hub를 반복 호출해야 하므로 실제 배포에서는 static IP 또는 DHCP reservation이 관리하기 쉽습니다.
- 부팅 시 Ethernet link가 올라오지 않으면 IP 할당과 server 시작 단계까지 진행되지 않을 수 있습니다.
- 릴레이 부하와 W5500 모듈을 같은 enclosure에 넣는 경우, EMI 영향을 줄이기 위해 전원 분리와 배선 간격을 확보하시는 것이 좋습니다.
- watchdog과 자동 재부팅 로직은 현장 복구에 유용하지만, 네트워크 장비 장애를 허브 장애로 오인하지 않도록 기준 주소를 신중히 정해야 합니다.
FAQ
Q: Climate Czar는 Linux 시스템인데, CZ_Combo_Hub_v2는 왜 필요한가요?
A: Linux 서버는 판단 로직, 대시보드, 데이터 관리, 자동화 규칙을 담당합니다. CZ_Combo_Hub_v2는 온실 현장에 설치되어 센서 값을 읽고 릴레이를 제어하는 ESP32 기반 I/O 허브입니다. 서버가 직접 모든 장치에 배선되지 않아도 현장 장치를 네트워크로 다룰 수 있게 해줍니다.
Q: 왜 이 프로젝트에서 W5500을 사용하나요?
A: Combo Hub는 서버가 HTTP로 호출하는 현장 제어 노드입니다. W5500은 ESP32에 유선 Ethernet을 추가해 Wi-Fi보다 예측 가능한 통신 경로를 제공하고, 네트워크 처리를 별도 Ethernet 컨트롤러에 맡길 수 있게 합니다.
Q: ESP32에는 어떻게 연결하나요?
A: 코드 기준으로 W5500은 SPI로 연결됩니다. MOSI는 GPIO 23, MISO는 GPIO 19, SCK는 GPIO 18, CS는 GPIO 5로 정의되어 있으며, 초기화 시 SPI.begin()과 Ethernet.init()이 호출됩니다.
Q: W5500은 이 프로젝트에서 정확히 어떤 역할을 하나요?
A: W5500은 ESP32 Combo Hub가 Climate Czar Server와 통신하는 유선 TCP/IP 인터페이스입니다. 서버는 이 경로를 통해 센서 값을 읽고, 스위치 상태를 확인하고, 릴레이 출력을 제어합니다.
Q: Wi-Fi만 사용하는 구성과 비교하면 어떤 차이가 있나요?
A: Wi-Fi는 배선이 적고 설치가 간단하지만, 온실 환경에서는 신호 품질이 변할 수 있습니다. W5500 기반 Ethernet은 배선이 필요하지만, 서버가 주기적으로 현장 노드를 호출하는 제어 구조에서는 더 안정적인 선택입니다.
What the Project Does
Climate Czar is a server system that runs on Linux. It operates in environments that can run PHP and MySQL, such as Raspberry Pi, Orange Pi, or a general Linux web server. It manages greenhouse conditions through a web-based dashboard and automation logic.
The server reads input values such as temperature, humidity, pH, EC, light level, float switches, and door switches. Based on configured conditions, it controls outputs such as fans, heaters, lights, pumps, relays, and notification scripts. The architecture is not tied to a specific sensor or smart plug. Any device that can be read or controlled from the command line can be integrated into the system.
CZ_Combo_Hub_v2 is ESP32-based field I/O hub firmware installed inside the greenhouse. Instead of wiring every sensor and relay directly to the server, the Combo Hub reads sensor values and controls relays at the field level, then provides the results to the server through an HTTP API.
This hub handles DHT22 temperature and humidity sensors, BH1750 light sensors, DS18B20 1-Wire temperature sensors, digital inputs, MCP23017-based relay outputs, an OLED display, and LoRa slave communication. In other words, the Climate Czar Server decides “when to turn on the fan” or “under which conditions to control the light,” while the Combo Hub performs field-level tasks such as “what the current sensor value is” and “whether to actually turn a relay on or off.”
The key architectural point is role separation. The Linux server handles decision-making, logging, the UI, and automation rules, while the ESP32 Combo Hub handles field I/O inside the greenhouse. This separation allows Climate Czar to remain a server-centered agricultural IoT system while still placing independent field control nodes inside the actual greenhouse.
Image source: AI-generated

Image source: https://github.com/larry-athey/climate-czar
Where WIZnet Fits
The WIZnet product identified in this project is the W5500. The W5500 provides the wired Ethernet path for the ESP32 Combo Hub.
Because the Combo Hub communicates with the server through an HTTP API, the network connection must be stable. Wi-Fi is easy to install, but in greenhouse environments with humidity, metal structures, long distances, and power noise, signal quality can fluctuate. W5500-based Ethernet requires cabling, but it provides a more predictable communication path for a system where the server periodically reads sensor values and controls relays.
The W5500 is an Ethernet controller with an embedded hardware TCP/IP stack, and it connects to the ESP32 over SPI. Since network processing can be handled by a separate chip, the ESP32 can focus on field logic such as sensor acquisition, relay control, LoRa message handling, and OLED display updates.
In agricultural IoT systems, network stability directly affects control stability. Devices such as fans, heaters, lights, and pumps can directly affect crop conditions if state decisions are delayed or the connection is interrupted. The W5500 provides a stable wired control point between the Climate Czar Server and the Combo Hub.
Implementation Notes
CZ_Combo_Hub_v2/CZ_Combo_Hub_v2.ino includes an Ethernet library compatible with the W5500 and the SPI pin configuration.
#include "UIPEthernet.h" // Ethernet interface library compatible with W5500 modules
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define ETH_CS 5This code defines the basic connection information required for the ESP32 to control the W5500 module as an SPI device. ETH_CS is the chip select pin for the W5500, while MOSI, MISO, and SCK are used for SPI data communication.
The network initialization flow is structured as follows.
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, ETH_CS);
Ethernet.init(ETH_CS);
if (Ethernet.linkStatus() == LinkON) {
cableConnected = true;
}
if (Ethernet.begin(ethMAC) > 0) {
ethConnected = true;
ethServer.begin();
}This code handles SPI initialization, W5500 chip select configuration, Ethernet link detection, DHCP-based IP assignment, and Ethernet server startup. Before the Climate Czar Server can read sensor values or relay states from the Combo Hub, this Ethernet server must be running properly.
CZ_Combo_Hub_v2/web_api.h handles HTTP API requests called by the server. Requests such as humidity, temperature, light, switch, relay, and uptime are routed to the corresponding sensor or output control functions. Through this API, the server reads the greenhouse field status and changes relay outputs when needed.
Practical Tips / Pitfalls
- The W5500 connects to the ESP32 over SPI, so MOSI, MISO, SCK, and CS wiring should be kept short and stable.
- Greenhouses often have humidity and long cable runs, so RJ45 connectors, power wiring, and relay wiring require waterproofing and secure fixation.
- DHCP is easy to set up, but in deployment, a static IP or DHCP reservation is easier to manage because the server repeatedly calls the Combo Hub.
- If the Ethernet link does not come up during boot, IP assignment and server startup may not proceed.
- When relay loads and the W5500 module are placed in the same enclosure, power separation and wiring distance should be considered to reduce EMI effects.
- Watchdog and automatic reboot logic are useful for field recovery, but the reference address should be chosen carefully so that network equipment failures are not mistaken for hub failures.
FAQ
Q: Climate Czar is a Linux system, so why is CZ_Combo_Hub_v2 needed?
A: The Linux server handles decision logic, the dashboard, data management, and automation rules. CZ_Combo_Hub_v2 is an ESP32-based I/O hub installed in the greenhouse to read sensor values and control relays. It allows the server to manage field devices over the network without wiring every device directly to the server.
Q: Why is the W5500 used in this project?
A: The Combo Hub is a field control node called by the server over HTTP. The W5500 adds wired Ethernet to the ESP32, providing a more predictable communication path than Wi-Fi and allowing network processing to be handled by a separate Ethernet controller.
Q: How is it connected to the ESP32?
A: Based on the code, the W5500 is connected over SPI. MOSI is defined as GPIO 23, MISO as GPIO 19, SCK as GPIO 18, and CS as GPIO 5. During initialization, SPI.begin() and Ethernet.init() are called.
Q: What exactly does the W5500 do in this project?
A: The W5500 acts as the wired TCP/IP interface between the ESP32 Combo Hub and the Climate Czar Server. Through this path, the server reads sensor values, checks switch states, and controls relay outputs.
Q: How is this different from using only Wi-Fi?
A: Wi-Fi requires less wiring and is easier to install, but signal quality can vary in greenhouse environments. W5500-based Ethernet requires cabling, but it is a more stable choice for a control architecture where the server periodically calls field nodes.


