budulinek / arduino-altherma-controller

Arduino-based controller for Daikin Altherma heat pumps. The controller connect to the Altherma heat pump via P1/P2 bus, has a built-in webserver for configuration (of the controller itself). Integration to Loxone home automation system via UDP protocol, allows you to monitor and control your Altherma heat pump.
GNU General Public License v2.0
51 stars 11 forks source link
arduino arduino-eeprom arduino-webserver daikin daikin-altherma loxone p1p2

Arduino Altherma UDP Controller

What is it good for?

Allows you to connect your Daikin Altherma heat pump (P1/P2 bus) to a home automation system (such as Loxone). This controller reads data from the P1/P2 bus on your Daikin Altherma and forwards them via ethernet UDP. You can also control your Daikin Altherma by sending commands via ethernet UDP.

The controller has a built-in web interface. You can use this web interface to configure the controller itself, monitor the status of the controller's connection to the P1/P2 bus and check error counters. All settings and P1/P2 statistics are stored in EEPROM. This program implements P1P2Serial library (https://github.com/Arnold-n/P1P2Serial).

Technical specifications

Hardware

Get the hardware and connect together:

Here is my HW setup (cheap Arduino Uno clone + W5500 Ethernet shield from Keyestudio + custom P1P2 Uno adapter):

HW

Firmware

You can either:

Connect your Arduino to ethernet and use your web browser to access the web interface on default IP: http://192.168.1.254

Settings

This controller has a built-in webserver which allows you to configure the controller itself, check basic system info of the controller and the status of its connection to the P1/P2 bus.

System Info

daikin1

EEPROM Health. Keeps track of EEPROM write cycles (this counter is persistent, never cleared during factory resets). Replace your Arduino once you reach 100 000 write cycles (with 6 hours EEPROM_INTERVAL you have more than 50 years lifespan).

Ethernet Chip. Wiznet chip on the ethernet shield.

MAC Address. First 3 bytes are fixed 90:A2:DA, remaining 3 bytes are random. You can also set manual MAC in IP Settings.

P1P2 Status

daikin2

Daikin Indoor Unit. Shows the name of your Altherma indoor unit.

Daikin Outdoor Unit.** Shows the name of your Altherma outdoor unit.

External Controllers. Shows all external controller connected to the P1/P2 bus (incl. their addresses) and provides info whether additional controller is supported by your heat pump. These messages can show up:

Date. Displays internal date and time of the heat pump.

Daikin EEPROM Writes. Every time you send Write Command through the web interface or a command via UDP, settings of the main Daikin controller (= controller on your heat pump) change and new values are written to its internal EEPROM. Your main Daikin controller's EEPROM has a limited number of writes, so keep an eye on this counter in order to prevent EEPROM wear! It is adviced to do max 7000 writes per year (19 writes/day on average).

Write Command. You can send a P1/P2 write command directly from web interface, for testing or reverse-engineering P1/P2 write commands. The format of the write command send via web interface is identical to the command sent via UDP:

P1P2 Packets. Counters for packets read from the P1/P2 bus or written to the P1/P2 bus, counters for various read and write errors. If any of the counters rolls over the unsigned long maximum (4,294,967,295), all counters will reset to 0.

UDP Messages.**

IP Settings

daikin3

MAC Address.** Change MAC address. "Randomize" button will generate new random MAC (first 3 bytes fixed 90:A2:DA, last 3 bytes will be random).

Auto IP.* Once enabled, Arduino will receive IP, gateway, subnet and DNS from the DHCP server.

Static IP. Set new static IP address. Automatically redirect the web interface to the new IP.

Submask.

Gateway.

DNS.*

TCP/UDP Settings

daikin4

Remote IP. IP address of your home automation system which listens for UDP messages and sends UDP commands.

Send and Receive UDP.

UDP Port. Local UDP port and remote UDP port.

WebUI Port. Change web UI port, automatically redirects the web interface to the new Web UI port.

P1P2 Settings

daikin5

Enable Write to P1P2.

EEPROM Write Quota. Daily quota for writes to the EEPROM of the main Daikin controller. Every command sent via web interface (Write Command on P1P2 Status page) or via UDP = write cycle to the Daikin EEPROM. If the daily quota is reached, new commands are dropped. The quota resets at midnight.

Connection Timeout. Timeout for reading data packets and for enabling writing to the P1/P2 bus.

Target Temperature Hysteresis. Hysteresis for writing target temperature or target setpoint commands (packet type 0x36) in 1/10 °C. Applies for write commands received via UDP. The purpose is to minimize Daikin controller EEPROM wear.

Packet Filter

daikin6

The Packet Filter page lists all packet types observed on the P1/P2 bus. Some of them are exchanged between the heat pump and the main Daikin controller, others are exchanged between our controller (or other external controllers) and the main Daikin controller. If you do not see any packet types, wait few seconds. If a new packet type is detected, it will be automatically added to the list. Packet types enabled on this page are forwarded via UDP. By default, only Counter Packet (0xB8) and Data Packets (usually 0x10 - 0x16) are sent via UDP. Enable additional packet types if you want to test or reverse-engineer the P1/P2 protocol.

Send All Packet Types. All packets read from the P1/P2 bus are sent via UDP (including packet types which were not yet observed). There is a lot of communication going on on the P1/P2 bus, so use with caution!

Counters Packet. Counter packet is periodically requested by the controller (only works if the controller is connected to the P1/P2 bus). Set the period for the counter packet requests.

Data Packets.

Tools

daikin7

Load Default Settings. Loads default settings (see DEFAULT_CONFIG in advanced settings). MAC address is retained.

Reboot.

Integration

This controller is mainly intended for the integration with Loxone home automation system.

Loxone

https://user-images.githubusercontent.com/6001151/232344216-52fd6a9e-4cc3-4d51-8f66-87266d960757.mp4

1. Wiring

It is advised to connect/disconnect devices to the P1/P2 bus only if the power of all connected devices is switched off.

2. Controller Settings

The controller can passively read (monitor) most data from the P1/P2 bus while being in a Disconnected state. If you also want to write to the bus and control your heat pump, you can (at your own risk!) connect the controller to the P1/P2 bus (to the main Daikin controller). Connect the controller manually, if no errors show up on the P1P2 Status page, enable Auto Connect.

Optionally, set the Remote IP (= Loxone Miniserver IP) and enable Only to/from Remote IP. See Remote IP Settings on the W5500 Chip.

3. Virtual UDP Input

Download the Loxone template VIU_Daikin Altherma.xml. Open Loxone Config and in the periphery tree mark Virtual Inputs, then go to UDP Device Templates > Import Template ... in the menu bar:

Find the template you have downloaded and import the template. You should see Daikin Altherma with a number of Virtual UDP Input Commands. Change the Sender IP address (= IP of your Arduino controller) or UDP port if needed.

Just drag and drop individual inputs into your Loxone plan and you are ready to go. There are only two challenges:

4. Virtual Output

Virtual Output will only work if the Arduino controller is fully connected to the P1/P2 bus (can write to the bus). Moreover, writeable command are device-specific. The Virtual Output Commands provided in the template may (with no guarantee) work only with Daikin Altherma LT (EHVH(H/X/Z)) heat pumps. Use at your own risk!!!

Download the Loxone template VO_Daikin Altherma LT.xml. Open Loxone Config and in the periphery tree mark Virtual Outputs, then go to Device Templates > Import Template ... in the menu bar. Find the template you have downloaded and import the template. You should see Daikin Altherma LT with a number of Virtual Output Commands. Change the IP address or UDP port if needed:

There are 3 types of outputs available:

If you want to control your heat pump through Loxone App (just like I did in the short video above) or Loxone Web Interface, use the EIB push-button block. It has the same functionality as a normal push-button but in addition has the State (S) input which can forward the status of a heat pump settings without triggering an action on the output. As a result, you can have a smooth two-directional communication between the main Daikin controller and the Loxone App. Here you have a solution for the DHW On/Off push-button and the DHW Boost push button. Please note that the DHW_OnOff_B input is a compound input which needs to be decoded with Binary Decoder:

5. Digital Outputs (Relays)

By default, the main Daikin controller (the user interface mounted at the indoor unit) acts as a thermostat. It has a temperature sensor and can control the heat pump by comparing the actual room temperature with target room temperature. This is not very practical solution if the main Daikin controller is located at the unit which sits somewhere in a separate boiler room.

Fortunately, 1) Daikin Altherma allows you to connect an external thermostat and 2) Loxone Miniserver can act as an external thermostat.

Wiring. External thermostat is an external 230V relay operated by a temperature sensor (+ some scheduling logic). It controls the heat pump by opening and closing a 230V circuit! Danger of death! Always unplug your heat pump from the mains before connecting wires and consult your heat pump's Installation manual in order to locate the correct wiring terminal. Proceed at your own risk! If you know what you are doing, connect the correct wiring terminal of your heat pump (on my Altherma I have used the X2M wiring terminal) to Loxone Miniserver relays. You can use separate relays for heating and cooling and separate relays for main LWT zone and additional LWT zone. Therefore, up to 4 external relays can be used depending on the complexity of your heating/cooling system.

Heat Pump Configuration. Enable external thermostat on your heat pump. Consult your installation manual. In my case I have the settings here: Installer settings > System layout > Standard > [A.2.1.7] Unit control method > Ext RT control. If you want to use separate relays for heating and cooling, check also Installer settings > System layout > Options > [A.2.2.4] Contact type main > H/C request.

Loxone Config. You can now connect your Digital Outputs (relays) directly to the HVAC Controller block:

It is quite simple. I have a HVAC Controller block which serves as a heating and cooling source for 7 Intelligent Room Controllers (see the "7 Objects Assigned" note at the bottom of the HVAC block). The HVAC block needs to know the outdoor temperature, so I have connected the Temperature_Outside_Stabilized measured by the heat pump. Relay Ext_Therm_Main_Heating triggers heating on the main LWT zone (underfloor heating), relay Ext_Therm_Add_Cooling triggers cooling on the additional LWT zone (ceiling cooling panels). Ext_Therm_Main_Cooling is not connected because I do not use floor for cooling.

6. Application Recommendations

Use relays for heating/cooling requests. Your Loxone automation system can now control the Altherma heat pump through 2 sets of outputs: Virtual Output Commands (UDP) and Digital Outputs (Relays). Each of them is doing a different thing, the two do not replace but complement each other:

Adjust the heating curve. Daikin Altherma heat pumps have a built-in heating curve (weather-dependent curve, equithermic curve). Heating curve means that the leaving water temperature (LWT) depends on weather (outdoor temperature). Interestingly, Loxone also has a heating curve, integrated in the Intelligent Temperature Controller block. Here are your choices:

Other systems

Home Assistant

Arduino Altherma UDP controller is not suitable for Home Assistant. As far as I know, it is difficult to parse hex UDP messages in HA. Check the table bellow and use another solution (or Node-RED as an intermediary).

Node-RED

Import and configure the node-red-contrib-buffer-parser package. See Payload-data-read.md how to parse UDP messages (read data from the heat pump). See Payload-data-write.md how to make UDP commands (write to the heat pump).

You can use Node RED as:

Limitations and known issues

Portability

The code was tested on Arduino Uno, ethernet chips W5100 and W5500. It may work on other platforms, but:

Remote IP settings on the W5500 Chip

The Ethernet.setRetransmissionCount() and Ethernet.setRetransmissionTimeout() commands do not work on W5500 chips because of a bug in the Ethernet.h library (see this issue). As a result, Arduino fails to read data from the P1/P2 bus (read errors, CRC errors) if certain conditions are met:

In this situation (UDP unicast) the W5500 chip checks whether the remote IP exists via ARP request. While the Ethernet.h waits for the ARP response, new P1/P2 packet arrives and is not properly processed which leads to P1/P2 read errors. The solution is simple. If you have a shield with the W5500 chip, set the Send and Receive UDP setting to To/From Any IP (Broadcast).

Ethernet sockets

The number of used sockets is determined (by the Ethernet.h library) based on microcontroller RAM. Therefore, even if you use W5500 (which has 8 sockets available) on Arduino Nano, only 4 sockets will be used due to limited RAM on Nano.

Memory

Not everything could fit into the limited flash memory of Arduino Nano / Uno. If you have a microcontroller with more memory (such as Mega), you can enable extra settings in the main sketch by defining ENABLE_DHCP and/or ENABLE_EXTRA_DIAG in advanced settings.

Comparison with other solutions

As of April 2023:

Project budulinek/
arduino-altherma-controller
Arnold-n/
P1P2Serial
raomin/
ESPAltherma
tadasdanielius/
daikin_altherma
speleolontra/
daikin_residential_altherma
Hardware • Arduino Uno
• Ethernet Shield
• Custom P1P2 Uno adapter
• Custom all-in-one board • M5StickC (or any ESP32/ESP8266 board)
• external relay (optional)
• Daikin LAN adapter
(BRP069A62/ BRP069A61
with OLD firmware)
• Daikin LAN adapter
(BRP069A62/ BRP069A61
with NEW firmware)
• Daikin WLAN adapter
(BRP069A78)
Programable MCUs 1
ATmega328P
2
ATmega328P + ESP8266
1
ESP32/8266
--- ---
Connection to Daikin Altherma P1/P2 bus P1/P2 bus X10A serial port P1/P2 bus P1/P2 bus dedicated slot
Interface • Ethernet • WiFi
• Ethernet (optional)
• WiFi • Ethernet • Ethernet • WiFi
Local LAN or Cloud Local Local Local Local Cloud
Controller configuration • web interface
• sketch
• console
• sketch
• sketch • web interface • web interface
OTA upgrades No Yes Yes Yes Yes
Read data from Daikin Altherma Yes Yes Yes Limited Limited
Control Daikin Altherma Yes Yes Limited Yes Yes
Communication protocol UDP MQTT MQTT Websockets Websockets
Data format HEX JSON JSON JSON JSON
Integration with • Loxone
• other systems (via UDP-HEX)
• Home Assistant
• other systems (via MQTT-JSON)
• Home Assistant
• other systems (via MQTT-JSON)
• Home Assistant • Home Assistant

Version history

For version history see:

https://github.com/budulinek/arduino-altherma-controller/blob/main/arduino-altherma-controller/arduino-altherma-controller.ino#L3