CONTROL_POWER_MQTT
CONTROL_POWER_MQTT: A 4-Channel Remote Power Control System Built on Arduino Mega and W5100/W5500
요약
CONTROL_POWER_MQTT는 Arduino Mega 2560과 WIZnet Ethernet(W5100/W5500), MQTT를 결합해 4채널 릴레이를 원격 제어하고 PZEM-004T 센서로 실시간 전력을 계측하는 시스템입니다. 코드에 남은 실제 도메인(mqtt.dev.altasoftware.vn)과 계정(altamedia)으로 미루어, 베트남의 이벤트·LED 디스플레이 SI 기업 Alta Media/Alta Software의 운영 인프라에 실제로 연동된 배포용 코드로 보이며, 개인 개발자가 회사 시스템에 맞춰 작성한 것으로 판단됩니다.
개요
이벤트·전시 현장이나 LED 디스플레이 설치 현장에서는 다수의 전원 채널을 원격으로 켜고 끄면서, 동시에 각 채널의 소비 전력을 실시간으로 감시해야 하는 요구가 있습니다. 상용 산업 자동화 장비는 비용이 높고 커스터마이징이 어려운 반면, CONTROL_POWER_MQTT는 Arduino Mega + Ethernet 실드/모듈 + PZEM 전력계라는 익숙한 부품 조합만으로 이 문제를 해결합니다. 4개의 릴레이 채널과 채널별 PZEM-004T 계측을 하나의 보드에 통합하고, MQTT로 원격 제어 명령을 받고 상태를 보고하는 구조입니다.
도입 배경 / 왜 필요한가
저장소 자체 도입 사례: 확인됨 [코드 근거]. MQTT 브로커 도메인이 mqtt.dev.altasoftware.vn, 로그인 계정이 altamedia로 하드코딩되어 있습니다. 검색 결과 Alta Media(호치민 소재 LED 디스플레이 렌탈·이벤트 설치 기업)와 자매사 Alta Software가 실존 기업으로 확인되어, 이 코드는 DIY 샘플이 아니라 실제 클라이언트 인프라에 연동되는 배포용 펌웨어로 판단됩니다.
→ 참고: Alta Software 공식 사이트
게시 주체: 회사의 공식 저장소가 아니라 **개인 개발자 Tuyet Nhung(GitHub: TNhunn25)**의 개인 계정에 올라와 있습니다. 해당 계정의 다른 저장소들(ESP-NOW 통신 테스트, LCD 테스트 등)도 개인 실습성 프로젝트에 가까워, 회사가 직접 만든 것이 아니라 개인이 회사 시스템에 연동하기 위해 작성한 코드를 자신의 계정에 올린 것으로 추정됩니다.
[추정] Alta Software 제품과의 연동 목적: Alta Media의 핵심 사업은 LED 디스플레이 렌탈·이벤트 설치이며, 업계 표준 LED 컨트롤 시스템(Linsn·NovaStar 계열)은 이더넷 케이블로 송신/수신 카드를 연결하는 방식이 일반적입니다. 이런 시스템에서는 컨트롤러의 열·전압 관리 실패가 LED 캐비닛 조기 손상으로 이어지는 것으로 알려져 있습니다. 이 정황을 종합하면, CONTROL_POWER_MQTT는 Alta Media가 운영하는 LED 디스플레이 관제 인프라에 전원 채널 On/Off 및 전력 모니터링 기능을 보조적으로 연동하기 위해 만들어졌을 가능성이 높습니다. 다만 실제 LED 컨트롤 시스템과의 직접 연동을 명시하는 문서나 소스코드 근거는 확인되지 않아, 이는 정황적 추정 수준에 머뭅니다.
산업적·규제적 필요성 근거: 확인 불가 — 전력 원격 감시/차단에 대한 베트남 내 별도 법규나 산업 표준 문서는 발견되지 않았습니다.
두 축을 종합하면, 실사용 배포 자체는 코드 근거로 확인되나, 공식 회사 프로젝트 여부와 특정 제품과의 직접 연동 여부는 확인되지 않고 정황적으로만 추정됩니다.
아키텍처
기술 배경
Arduino Ethernet.h와 WIZnet W5100/W5500 호환성
Arduino의 표준 Ethernet 라이브러리는 W5100, W5200, W5500 등 WIZnet 칩 세대가 달라도 동일한 API(Ethernet.begin(), EthernetClient 등)로 접근할 수 있게 추상화합니다. 칩 세대별 레지스터 차이는 라이브러리 내부에서 흡수되므로, 개발자는 어떤 세대의 칩이 실제 장착되어 있는지 신경 쓰지 않고 코드를 재사용할 수 있습니다. CONTROL_POWER_MQTT의 readme.txt가 "W5100/W5500"을 함께 명시한 것도 이 호환성 덕분입니다.
→ 참고: Arduino Ethernet Library 공식 문서
MQTT LWT(Last Will and Testament)와 상태 관리
MQTT의 LWT는 클라이언트가 비정상 종료(전원 차단, 네트워크 단절)될 경우 브로커가 미리 등록된 메시지를 대신 발행해주는 기능입니다. CONTROL_POWER_MQTT는 CRL_POWER/INFO 토픽에 online/offline 상태를 LWT로 등록해, 원격 현장의 컨트롤러가 꺼졌는지 네트워크가 끊겼는지를 관제 시스템이 즉시 인지할 수 있게 합니다. 전원 채널을 직접 다루는 이 시스템에서는 이 기능이 안전과 직결됩니다.
→ 참고: MQTT.org: Last Will and Testament
PZEM-004T Modbus 전력 계측
PZEM-004T는 Modbus 프로토콜로 전압·전류·전력·전력량을 보고하는 저비용 계측 모듈입니다. CONTROL_POWER_MQTT는 채널 4개 + 총합 1개, 총 5개의 계측 지점을 다뤄야 하지만 PZEM 모듈을 5개 직결하는 대신 HC4052 아날로그 멀티플렉서로 Serial 포트를 채널별로 순차 전환하며 데이터를 수집합니다. 이는 UART 포트 수가 제한된 Arduino Mega에서 다채널 계측을 구현하는 실용적인 해법입니다.
→ 참고: PZEM-004T Modbus 통신 규격
기술 특징
- MD5 서명 기반 텔레메트리 무결성: MQTT로 전송되는 상태 payload에 MD5 해시를 함께 담아, 전송 중 변조나 손상을 수신 측에서 검증
- EEPROM 비휘발성 상태 저장: MAC 주소, 네트워크 설정, 릴레이 On/Off 상태, 누적 전력량을 EEPROM에 저장해 정전 후 재기동 시에도 이전 상태를 복원
- 순차 기동(3초 지연): 릴레이 4채널을 동시에 투입하지 않고 순차적으로 켜서 돌입 전류(inrush current) 집중을 방지
WIZnet 적용 구조
실제 사용: W5100 또는 W5500 — readme.txt에 "Ethernet (W5100/W5500)"로 명시되어 있으며, 코드는 Arduino 표준 Ethernet.h를 통해 두 칩 모두를 지원합니다.
Ethernet.init(53)으로 SPI CS 핀을 Mega의 하드웨어 SPI SS 핀(53번)에 지정Ethernet.begin(mac, ip, dns, gateway, subnet)으로 고정 IP 초기화 (DHCP 미사용)EthernetClient객체를 PubSubClient에 그대로 전달해 TCP 소켓 제공
[추정] 실제 배포 보드에 W5100과 W5500 중 어느 쪽이 탑재되는지는 소스코드만으로 특정할 수 없으며, 리비전에 따라 다를 수 있습니다. 미확인: PoE 지원 여부, 실제 실드/모듈의 정확한 PCB 사양
WIZnet Makers 유사 사례
- Prueba PZEM-004t con Arduino UNO + Shield Ethernet W5100: CONTROL_POWER_MQTT와 동일하게 Arduino + PZEM-004T + WIZnet W5100 Ethernet Shield 조합을 사용합니다. 다만 이 프로젝트는 PZEM 측정값을 확인하는 검증 단계 성격이 강한 반면, CONTROL_POWER_MQTT는 릴레이 제어·MQTT·EEPROM 저장까지 통합한 완성형 배포 시스템입니다.
→ 프로젝트 링크: Prueba PZEM-004t con Arduino UNO + Shield Ethernet W5100
- Arduino Nano-Based W5500 Ethernet MQTT 8-Channel Opto-Isolated I/O Board: CONTROL_POWER_MQTT와 마찬가지로 Arduino + W5500 + MQTT 기반 다채널 릴레이/IO 제어 구조를 갖췄습니다. 다만 옵토아이솔레이션 I/O 제어 자체에 집중해 전력 계측 기능은 포함하지 않는 반면, CONTROL_POWER_MQTT는 PZEM 계측을 결합한 점이 다릅니다.
→ 프로젝트 링크: Arduino Nano-Based, Stable Wired I/O Solution
- ESP32-S3 Ethernet Relay Board — SignalK, MQTT & Victron Venus OS Integration: W5500 Ethernet과 MQTT를 결합한 산업/상업용 릴레이 제어라는 점에서 기능적으로 유사합니다. 다만 이 프로젝트는 해양·Victron 생태계에 특화된 반면, CONTROL_POWER_MQTT는 이벤트/LED 디스플레이 현장의 전원 관리에 특화되어 있습니다.
→ 프로젝트 링크: ESP32-S3 Ethernet Relay Board
세 사례 모두 Arduino/ESP 계열 MCU + WIZnet 이더넷 + MQTT라는 조합을 릴레이·전력 제어의 신뢰성 확보 수단으로 채택했다는 공통점이 있으며, 이는 소규모 산업/이벤트 자동화 영역에서 이 조합이 검증된 패턴임을 보여줍니다.
| 항목 | CONTROL_POWER_MQTT | Prueba PZEM-004t (teddy) | Arduino Nano I/O Board (scott) | ESP32-S3 Relay Board (irina) |
|---|---|---|---|---|
| MCU | Arduino Mega 2560 | Arduino UNO | Arduino Nano | ESP32-S3 |
| 네트워크 칩 | W5100/W5500 | W5100 | W5500 | W5500 |
| 통신 프로토콜 | MQTT | 미상(테스트 단계) | MQTT | MQTT, SignalK |
| 전력 계측 | PZEM-004T ×5(멀티플렉싱) | PZEM-004T ×1 | 없음 | 없음 |
| 제어 채널 | 릴레이 4채널 | 없음(계측 전용) | 옵토아이솔레이트 IO 8채널 | 릴레이(채널 수 미상) |
| 실사용 배포 근거 | 확인됨(코드 내 실제 도메인/계정) | 미상 | 미상 | 미상(마린 전자 생태계 특화) |
표에서 드러나듯, CONTROL_POWER_MQTT는 전력 계측(PZEM)과 릴레이 제어를 하나의 시스템에 결합했다는 점에서 개별 기능에 집중한 다른 사례들과 차별화됩니다. 동시에 실제 고객사 도메인이 코드에 남아있어, 네 프로젝트 중 실사용 배포 근거가 가장 직접적으로 확인되는 사례이기도 합니다.
비즈니스 가치
- 이벤트/전시 현장의 안정적 전원 제어: 무선 간섭이 잦은 다중 장비 밀집 환경에서 유선 Ethernet으로 결정론적인 원격 On/Off 확보
- 전력 사용량 실시간 감시: 채널별 PZEM 계측으로 과부하·이상 전력 소비를 조기 감지 가능
- 저비용 커스텀 SI 솔루션: 상용 산업 자동화 장비 대신 Arduino 기반으로 현장 맞춤형 시스템을 빠르게 구축
- 원격 모니터링/제어 통합: MQTT 기반 구조로 중앙 관제 시스템과 자연스럽게 연동
한계 및 개선 방향
현재 한계
- MQTT 인증정보(
altamedia/Altamedia@%)가 소스코드에 평문으로 하드코딩되어 있어, 퍼블릭 저장소 게시 시 실제 운영 자격증명이 노출되는 보안 리스크가 있음 - 고정 IP만 지원하며 DHCP 옵션이 없어, 네트워크 환경 변경 시 Serial 명령으로 수동 재설정이 필요함
- 단일 작업일에 커밋이 집중되고 이후 이력이 없어, 유지보수 지속 여부를 확인하기 어려움
개선 방향
- MQTT 자격증명을 EEPROM 등 별도 저장 영역으로 분리하고, 소스코드에는 플레이스홀더만 남기는 방식으로 전환하면 저장소 공개 시 위험을 줄일 수 있음
- DHCP 옵션을 추가해 네트워크 재구성 시 수동 개입을 최소화 가능
- HC4052 멀티플렉싱 스캔 주기를 채널 수에 따라 동적으로 조정하면, 채널 확장 시에도 응답성을 유지할 수 있음
- 이 프로젝트가 실제 배포 사례라는 점을 감안하면, 유지보수 체계를 공식화해 재사용 가능한 레퍼런스로 발전시킬 여지가 있음
FAQ
Q1. CONTROL_POWER_MQTT를 도입하려면 난이도가 높은가요? Arduino Mega 2560, Ethernet 모듈(W5100/W5500), PZEM-004T, HC4052 정도의 표준 부품으로 구성되어 하드웨어 진입장벽은 낮은 편입니다. 다만 MQTT 자격증명 등 배포 환경별 설정은 직접 코드를 수정해야 합니다.
Q2. W5100과 W5500 중 어떤 것을 선택해야 하나요? 코드는 Arduino Ethernet.h를 통해 두 칩 모두를 동일하게 지원합니다. 안정성과 처리 속도 면에서는 W5500이 더 최신 세대이므로 신규 구축 시에는 W5500을 권장할 수 있습니다.
Q3. PZEM 채널을 늘리고 싶으면 어떻게 해야 하나요? 현재 HC4052 멀티플렉서 기반 구조를 확장하거나, 추가 UART/멀티플렉서 채널을 도입해야 합니다. 채널이 늘어날수록 스캔 주기가 길어지는 점을 고려해야 합니다.
Q4. MQTT 보안을 강화하려면? 현재 평문 하드코딩된 자격증명을 EEPROM 분리 저장 또는 환경변수화하고, TLS 지원 브로커·클라이언트로 전환하는 것이 권장됩니다.
Q5. 이 프로젝트는 실제로 사용되고 있는 시스템인가요? 코드에 남은 실제 도메인·계정 정보로 볼 때 실사용 배포 정황이 확인되나, 공식 회사 프로젝트로서의 지속적 유지보수 여부는 확인되지 않습니다.
Summary
CONTROL_POWER_MQTT combines an Arduino Mega 2560 with WIZnet Ethernet (W5100/W5500) and MQTT to remotely control a 4-channel relay bank while measuring real-time power consumption through PZEM-004T sensors. Given the real domain (mqtt.dev.altasoftware.vn) and account (altamedia) hardcoded into the source, this appears to be deployment-ready code connected to the operational infrastructure of Alta Media/Alta Software, a Vietnamese event and LED display integration company — most likely written by an individual developer to interface with the company's systems.
Overview
Event and exhibition setups, along with LED display installations, often need to remotely switch multiple power channels on and off while monitoring each channel's power draw in real time. Commercial industrial automation gear tends to be expensive and hard to customize, whereas CONTROL_POWER_MQTT solves this with a familiar combination of parts: an Arduino Mega, an Ethernet shield/module, and PZEM power meters. It integrates four relay channels and per-channel PZEM-004T measurement onto a single board, receiving remote control commands and reporting status over MQTT.
Why This Matters
Real-world adoption of the repository itself: Confirmed [code-level evidence]. The MQTT broker domain is hardcoded as mqtt.dev.altasoftware.vn, with login account altamedia. Search results confirm Alta Media (an LED display rental and event installation company based in Ho Chi Minh City) and its sister company Alta Software as real, verifiable businesses — indicating this is not a DIY sample but deployment firmware tied to a real client's infrastructure.
→ Source: Alta Software official site
Who published it: This isn't the company's official repository — it sits in the personal GitHub account of an individual developer, Tuyet Nhung (GitHub: TNhunn25). The account's other repositories (ESP-NOW communication tests, LCD tests, etc.) read more like personal hobby/practice projects, suggesting this wasn't built and released by the company itself, but rather written by an individual to interface with the company's system and then pushed to their personal account.
[Inferred] Purpose of integrating with Alta Software's product: Alta Media's core business is LED display rental and event installation, and the industry-standard LED control systems (Linsn, NovaStar-type) typically connect sending and receiving cards over Ethernet cable. In that world, a controller failing to manage heat and voltage properly is a known cause of premature LED cabinet damage. Putting these pieces together, CONTROL_POWER_MQTT was likely built to add power-channel on/off control and monitoring as a supporting layer to whatever LED display management infrastructure Alta Media operates. That said, no documentation or source-code evidence directly confirms integration with a specific LED control system — this remains a circumstantial inference.
Industry/regulatory need: Not confirmed — no Vietnamese regulation or industry standard addressing remote power monitoring/cutoff for this use case was found.
Taken together: real-world deployment is confirmed through code-level evidence, but whether this was an official company project, and whether it integrates directly with a specific product, remain unconfirmed and are noted here as circumstantial.
Architecture
Technology Background
Arduino Ethernet.h and W5100/W5500 Compatibility
Arduino's standard Ethernet library abstracts different generations of WIZnet chips — W5100, W5200, W5500 — behind the same API (Ethernet.begin(), EthernetClient, and so on). The register-level differences between chip generations are absorbed inside the library, so developers can reuse the same code without worrying about which generation is actually installed. This is why CONTROL_POWER_MQTT's readme.txt lists "W5100/W5500" together rather than committing to one.
→ Source: Arduino Ethernet Library official docs
MQTT LWT (Last Will and Testament) and Status Management
MQTT's LWT feature lets the broker publish a pre-registered message on the client's behalf if the client disconnects abnormally — power loss, network failure, and so on. CONTROL_POWER_MQTT registers online/offline status as an LWT on the CRL_POWER/INFO topic, letting the central monitoring system immediately recognize whether a remote controller has powered down or lost network connectivity. In a system that directly switches power channels, this capability is tied directly to safety.
→ Source: MQTT.org: Last Will and Testament
PZEM-004T Modbus Power Measurement
PZEM-004T is a low-cost measurement module that reports voltage, current, power, and energy over Modbus. CONTROL_POWER_MQTT needs to cover five measurement points — four channels plus a total — but instead of wiring five separate PZEM modules, it uses an HC4052 analog multiplexer to switch a single serial port sequentially across channels. This is a practical way to implement multi-channel measurement on an Arduino Mega, which has a limited number of UART ports.
→ Source: PZEM-004T Modbus protocol reference
Technical Highlights
- MD5-signed telemetry integrity: Status payloads sent over MQTT include an MD5 hash, letting the receiving side verify the data wasn't tampered with or corrupted in transit
- EEPROM-backed persistent state: MAC address, network configuration, relay on/off states, and cumulative energy are stored in EEPROM, so the system restores its previous state after a power loss and restart
- Sequential startup (3-second delay): The four relay channels are switched on one at a time rather than simultaneously, preventing a concentrated inrush current
Where WIZnet Fits
Confirmed usage: W5100 or W5500 — readme.txt explicitly states "Ethernet (W5100/W5500)," and the code supports both through Arduino's standard Ethernet.h.
Ethernet.init(53)assigns the SPI chip-select pin to the Mega's hardware SPI SS pin (pin 53)Ethernet.begin(mac, ip, dns, gateway, subnet)initializes a static IP (no DHCP)- The
EthernetClientobject is passed directly into PubSubClient to provide the TCP socket
[Inferred] Whether the deployed board actually carries a W5100 or a W5500 can't be determined from source code alone — it may vary by revision. Unconfirmed: PoE support, and the exact PCB specification of the shield/module in use.
Similar Projects on WIZnet Makers
- Prueba PZEM-004t con Arduino UNO + Shield Ethernet W5100: Shares the same combination as CONTROL_POWER_MQTT — Arduino + PZEM-004T + WIZnet W5100 Ethernet Shield. However, this project reads more like a validation step for confirming PZEM readings, while CONTROL_POWER_MQTT is a complete deployed system integrating relay control, MQTT, and EEPROM persistence.
→ Project link: Prueba PZEM-004t con Arduino UNO + Shield Ethernet W5100
- Arduino Nano-Based W5500 Ethernet MQTT 8-Channel Opto-Isolated I/O Board: Like CONTROL_POWER_MQTT, this uses an Arduino + W5500 + MQTT-based multi-channel relay/IO control structure. It focuses purely on opto-isolated IO control without power measurement, whereas CONTROL_POWER_MQTT adds PZEM-based metering on top.
→ Project link: Arduino Nano-Based, Stable Wired I/O Solution
- ESP32-S3 Ethernet Relay Board — SignalK, MQTT & Victron Venus OS Integration: Functionally similar in combining W5500 Ethernet with MQTT for industrial/commercial relay control. It specializes in the marine electronics ecosystem (SignalK, Victron), while CONTROL_POWER_MQTT specializes in power management for event and LED display sites.
→ Project link: ESP32-S3 Ethernet Relay Board
All three projects adopt the combination of Arduino/ESP-family MCU + WIZnet Ethernet + MQTT as a reliability backbone for relay and power control, showing that this pattern is proven within small-scale industrial and event automation.
| Item | CONTROL_POWER_MQTT | Prueba PZEM-004t (teddy) | Arduino Nano I/O Board (scott) | ESP32-S3 Relay Board (irina) |
|---|---|---|---|---|
| MCU | Arduino Mega 2560 | Arduino UNO | Arduino Nano | ESP32-S3 |
| Network chip | W5100/W5500 | W5100 | W5500 | W5500 |
| Communication protocol | MQTT | Unconfirmed (test-stage) | MQTT | MQTT, SignalK |
| Power measurement | PZEM-004T x5 (multiplexed) | PZEM-004T x1 | None | None |
| Control channels | 4 relay channels | None (measurement only) | 8 opto-isolated IO channels | Relay (channel count unconfirmed) |
| Real-world deployment evidence | Confirmed (real domain/account in code) | Unconfirmed | Unconfirmed | Unconfirmed (specialized for marine ecosystem) |
As the table shows, CONTROL_POWER_MQTT distinguishes itself by combining power measurement (PZEM) with relay control in a single system, whereas the other cases each focus on a narrower function. It's also the one of the four with the most direct evidence of real-world deployment, given the actual client domain left in the code.
Business Value / Use Cases
- Reliable power control at event/exhibition sites: Wired Ethernet provides deterministic remote on/off switching in environments dense with equipment and prone to RF interference
- Real-time power consumption monitoring: Per-channel PZEM measurement enables early detection of overload or abnormal power draw
- Low-cost custom SI solution: Arduino-based construction lets integrators build site-specific systems quickly instead of relying on commercial industrial automation gear
- Integrated remote monitoring/control: The MQTT-based structure connects naturally to a central monitoring system
Limitations and Future Improvements
Current limitations
- MQTT credentials (
altamedia/Altamedia@%) are hardcoded in plaintext in the source, creating a security risk of exposing real operational credentials when the repository is made public - Only static IP is supported, with no DHCP option, requiring manual reconfiguration via serial commands whenever the network environment changes
- Commits are concentrated on a single day with no subsequent history, making it hard to confirm whether maintenance is ongoing
Improvement directions
- Separating MQTT credentials into EEPROM or another storage area, leaving only placeholders in source code, would reduce risk when the repository is public
- Adding a DHCP option would minimize manual intervention when reconfiguring the network
- Dynamically adjusting the HC4052 multiplexing scan interval based on channel count would preserve responsiveness as channels are added
- Given that this appears to be a real deployment, formalizing a maintenance process could turn it into a reusable reference implementation
FAQ
Q1. Is CONTROL_POWER_MQTT difficult to adopt? It's built from standard parts — an Arduino Mega 2560, an Ethernet module (W5100/W5500), PZEM-004T, and an HC4052 — keeping the hardware barrier low. That said, deployment-specific settings like MQTT credentials need to be edited directly in the code.
Q2. Should I choose W5100 or W5500? The code supports both equally through Arduino's Ethernet.h. W5500 is the newer generation with better stability and throughput, so it's a reasonable default for new builds.
Q3. How do I add more PZEM channels? You'd need to extend the current HC4052 multiplexer setup or add more UART/multiplexer channels. Keep in mind that scan cycle time grows as channel count increases.
Q4. How can MQTT security be improved? Moving the currently plaintext-hardcoded credentials into EEPROM or environment-based configuration, and switching to a TLS-capable broker and client, are recommended next steps.
Q5. Is this system actually in production use? The real domain and account left in the code point to actual deployment, but whether it's officially maintained as a company project remains unconfirmed.

