Hardware

The project uses the Ai-M61-32S-Kit (thanks to Ai-Thinker for providing the board). It’s a mighty development board — the processing speed is impressive, and it runs a web server smoothly without any issues.


DIY Concept

Based on suggestions from previous projects, I decided not to replace the original main MCU of the water heater this time. Reference: https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=47239

Instead, I chose to control the heater via infrared (IR) by using the Ai-M61-32S to transmit IR codes.

All connections were made with flying wires and manually soldered.

System Design

The Ai-M61 runs a web server and connects to Wi-Fi. The system includes:

  • DS18B20 temperature sensor to measure water temperature
  • IR transmitter to control the water heater
  • Optocoupler input to detect whether the heater is currently heating
  • DS1302 RTC chip to maintain timekeeping when Wi-Fi is unavailable
  • Leader code: 12 ms + 4.5 ms
  • 42-bit data:
    • “0”: 560 μs + 560 μs
    • “1”: 560 μs + 1680 μs
  • End code: 560 μs + 23000 μs + 18 μs + 4500 μs + 820 μs

 

IR remote control signals were captured using a logic analyzer with an IR receiver module.

IR Protocol Analysis

Analysis showed that the IR protocol is custom, not standard NEC. Therefore, the Ai-M61 simply transmits the captured IR codes directly.

Protocol details:

IR Codes:

  • Power ON/OFF: 0x58853B D0AF 1A A1 DC 0B F5 80
  • Temperature +: 0x58853B F08F 1A A1 DC 0F F1 80
  • Temperature −: 0x58853B F48B 1A A1 DC 2F D1 80
  • Medium level: 0x58853B C8B7 1A A1 DC 13 ED 80
  • Timer: 0x58853B D8A7 1A A1 DC 1B E5 80


Power Supply & Installation

The system is powered directly from the water heater’s internal 5V supply, confirmed using a multimeter.

After opening the heater control board:

  • The optocoupler input is connected to the heating indicator LED
  • The IR transmitter is fixed next to the original IR receiver using hot glue

The module is then installed inside the water heater.

Notes

This is a low-cost DIY solution with no additional hardware cost, though long-term reliability may be lower than a commercial design.

After flashing the firmware with initial OTA support, the system was fully assembled. There is plenty of remaining flash space.

Firmware Development

The software was developed module by module, referencing excellent examples shared by community members: