This document describes how MQTT and telnet are used by P1P2MQTT (which will replace P1P2-bridge-esp8266) on the ESP8266 of the P1P2-ESP-interface (or on the Arduino/ESP combi-board) to communicate data from/to P1P2Monitor running on the ATmega with the P1/P2 interface.
Only for first time usage: Wifi parameters and MQTT settings can be configured after first boot using wifimanager's AP (connect to 192.168.4.1 on SSID P1P2MQTT and fill in details). WiFi and MQTT server details will be stored afterwards. Note: if MQTT details are not correct, the only way to connect to the ESP is by telnet. Over telnet any command can be given (just like via P1P2/W), including the 'b' command to verify or change MQTT settings.
In addition to MQTT, it is possible to telnet to P1P2MQTT on the ESP8266.
This provides an additional possibility to monitor the system's output and to enter commands directly. To obtain the IPv4 address, check your router or firewall, use a tool like Fing, or check the MQTT output (which includes the 4th byte of the IPv4 address in all topics).
Example (command given below: "J803"):
$ telnet 192.168.4.122
Trying 192.168.4.122...
Connected to 192.168.4.122.
Escape character is '^]'.
Welcome 192.168.4.240 to P1P2-bridge-esp8266 v0.9.14 compiled Aug 2 2022 12:29:12
(Use ^] + q to disconnect.)
P1P2/S/122 * [ESP] Uptime 740
J803
P1P2/S/122 * [ESP] Outputmode set to 0x803
P1P2/S/122 * [ESP] Uptime 750
A tutorial to MQTT is outside scope of this file; but MQTT topics can be monitored using
- "mosquitto_sub -h <host> [-p <portnr>] -t P1P2/#"
and commands to P1P2MQTT (and via P1P2MQTT to P1P2Monitor) can be given by
- "mosquitto_pub -h <host> [-p <portnr>] -t P1P2/W/<xxx> -m <command_or_message>.
where xxx is the 4th byte of the device's IPv4 address. If the 4th byte is (unknown and) left out, all P1P2MQTT instances execute the command:
- "mosquitto_pub -h <host> [-p <portnr>] -t P1P2/W -m <command_or_message>.
- P1P2/R/<xxx> : raw hex packet data as read from the P1/P2 bus (and additional pseudo-packets generated by P1P2Monitor and P1P2MQTT)
- P1P2/S/<xxx> : status messages, errors, and verbose information
- P1P2/J/<xxx> : json formatted decoded parameter values from the P1/P2 bus
- P1P2/P/<xxx>/<X>/<SRC>/<KEY> topic for parameter value <KEY>. Each parameter is published as a separate topic.
Each topic includes <xxx>, which is the 4th byte of the IPv4 address, shown as a 3-character code (with leading zeroes if needed). This enables to easily derive its IPv4 address for telnet usage and to have multiple P1P2MQTT programs running. In the examples below <xxx> is 122.
In topic P1P2/P/<xxx>/<X>/<SRC> X is a single character:
- P for parameter settings
- T for temperature and flow measurements
- M for other measurements
- F for auxiliary controller related settings
- A for data generated by software on ATmega or ESP8266 (pseudo-packets)
- E for schedule information
- U for unknown reports
while <SRC> identifies the parameter source:
- 0 main controller (communicating to main system)
- 1 main heat pump system (communicating to main controller)
- 2 main controller (communicating to auxiliary controller)
- 3 auxiliary controller (communicating to main controller)
- 8 P1P2Monitor running on ATmega328P
- 9 P1P2MQTT running on ESP8266
For example, P1P2/P/122/T/1/TempLWT reports the actual leaving water temperature as reported by the main system.
P1P2/P/122/C/1/Starts_Compressor 20713
P1P2/P/122/C/1/Hours_Gasboiler_DHW 501
P1P2/P/122/A/8/ATmega_Uptime 5881
P1P2/P/122/A/9/ESP_Uptime 302
P1P2/P/122/T/1/Temperature_HP2Gas_Water 22.750
P1P2/P/122/C/1/Hours_Compressor_Heating 27843
...
Communicates raw hex packet data as it is read from the P1/P2 bus, in recommended verbose=3 mode prefixed by relative time stamp. Useful to verify operation of hardware and analyse data patterns if your model is not (fully) supported. In addition may contain timing information.
Example output:
P1P2/R/122 R T 0.160: 0000100001010000000014000000000800000F00003D0029
P1P2/R/122 R T 0.024: 400010000081013D000F0014001A000000000000000000E0
P1P2/R/122 R P 00000D0000000000000000000000000000000000000000C4
P1P2/R/122 R P 40000D0000000000000000000000000000000000000000B2
P1P2/R/122 R T 0.041: 00001115660000000000000B
...
Packets with timestamps (‘T’) originate from the P1/P2 bus. Packets without time stamp (‘P’) are pseudo-packets generated by P1P2Monitor or P1P2MQTT with internal state information.
Example output in verbose=1 mode after ATmega328 reboot ("P1P2/W/122 a"):
P1P2/S122 P1P2-bridge-esp8266 v0.9.14 compiled Aug 2 2022 15:25:42
P1P2/S122 * [ESP] Connected to MQTT server
P1P2/S122 * [ESP] AVRISP: ATmega programming: avrdude -c avrisp -p atmega328p -P net:192.168.4.122:328 -t # or -U ...
P1P2/S122 * [ESP] Two dummy lines to ATmega.
P1P2/S122 * [ESP] Setup ready
P1P2/S122 * [ESP] TELNET: telnet 192.168.4.122
P1P2/S122 * [MON] First ATmega input line ignored 0010300000000002100370060
P1P2/S122 * [ESP] Uptime 1
P1P2/S122 * [ESP] Uptime 2
...
Example output:
P1P2/X/122 @�
P1P2/X/122 @#��
...
Json data channel. Example output:
P1P2/J/122 {"HeatingOn":0,"RoomTarget":20,"DHWactive":0,"DHWcomfort":55,"TempLWT":20.59, .. }
...
Topics providing information or commands to P1P2MQTT:
- P1P2/W or P1P2/W/<xxx> : Channel to give commands to the P1P2MQTT and indirectly to P1P2Monitor
- (planned:) P1P2/E/<xxx> : (reserved for, not supported yet) Electricity consumption information, provided by an external electricity meter or another program (perhaps: ESPAltherma), enabling P1P2MQTT to calculate CoP values
(Planned:) Topics to set parameters on the Daikin system:
- (planned:) P1P2/C/<xxx>/<XX>/<YYYY> : (reserved for, not supported yet) write parameter number 0xYYYY (hex) in packet type 0xXX (hex) to the value (usually decimal, depends on function) in the message of this topic. For example, message "1" on topic "P1P2/C/122/35/2F" will switch heating on.
(Planned:) Topics to switch often-used parameters by regular names, for example:
- (planned:) P1P2/C/122/heating 1 : (reserved for, not supported yet) will switch heating on
- (planned:) P1P2/C/122/heating 0 : (reserved for, not supported yet) will switch heating off
Commands to be executed by P1P2MQTT can be given over P1P2/W/<xxx> or via telnet:
- "A" Execute hard reset of ATmega328P
- "B [MQTT_server_IPv4 [MQTT_portnr [MQTT_user [MQTT_password [MQTT_INPUT_IPv4-byte4 [hwId [noWiFi]]]]]]]" sets MQTT server details and, for ESP01s taking input over MQTT, 4th byte of IPv4 of data source (with 0 for subscribing to P1P2/R/#). hwId sets hwId (useful only to reset to 0 for August 2022 batch after flash erasure). noWiFi can be set to 1 to prohibit WiFi use (no WiFi fall-back if ethernet fails).
- "D0" Reset ESP8266
- "D1" Restart ESP8266
- "I [ use_static_ip [ static IPv4 address [ gateway [ netmask ]]]]" sets static IPv4 address (if use_static_ip = 1) or DHCP (if 0)
- "S" Display output filter level (replaces previous changed-only mode)
- "Sx" Sets output filter level:
- 0 all parameters
- 1 parameters only when new or when value changes
- 2 like 1, without temperature/flow measurements (unless new)
- 3 like 2, without date/time
- "J" Display output mode
- "Jx" Sets output mode, sum of:
- 0x0001 to output raw packet data (including pseudo-packets) over mqtt P1P2/R/#
- 0x0002 to output mqtt individual parameter data over P1P2/P/#
- 0x0004 to output json data over P1P2/J/#
- 0x0008 to include parameters in mqtt/telnet/serial output even if functionality unknown, easily overloads ESP8266
- 0x0010 ESP to output raw data over telnet
- 0x0020 to output mqtt individual parameter data over telnet
- 0x0040 to output json data over telnet
- 0x0080 (reserved for adding time string in R output)
- 0x0100 ESP to output raw data over serial
- 0x0200 to output mqtt individual parameter data over serial
- 0x0400 to output json data over serial
- 0x0800 to output raw binary data over P1P2/X/#
- 0x1000 output timing data (if scope mode is set to 1) via P1P2/R/xxx (with prefixes C and c)
- 0x2000 output packets with errors also over P1P2/R/xxx (with prefix *)
- 0x4000 to use P1P2/R/xxx as input instead of serial (requires MQTT_INPUT_HEXDATA)
- 0x8000 to use P1P2/X/xxx as input instead of serial (requires MQTT_INPUT_BINDAT)
- 0x10000 to include non-HACONFIG parameters in P1P2/P/#
- "V" Display verbosity (and displays software version + compile date/time of both P1P2MQTT and P1P2Monitor)
- "Vx" Sets verbosity (and displays software version + compile date/time of both P1P2MQTT and P1P2Monitor) (for verbosity levels 0-4, see P1P2Monitor-commands.md; level 9: ESP8266 ignoring serial input (safe mode))
- "U" Display scope mode (0 off, 1 on)
- "Ux" Sets scope mode (0 off (default), 1 on)
Further, supported but advised not to use, and not really needed (some may be removed in a future version); these commands are handled by both CPUs:
- "G" Display current crc_gen value
- "Gx" Sets crc_gen (default 0xD9) (we have not seen any other values so no need to change)
- "H" Display current crc_feed value
- "Hx" Sets crc_feed (default 0x00) (we have not seen any other values so no need to change)
No longer supported:
- "Ux" Display-unknown mode on/off, replaced by 0x0008 contribution in J command
- "U" Display display-unknown mode
- ("U" command is now used to switch scope-mode in P1P2Monitor)
All other commands received by P1P2MQTT (as well as the CRC-related G and H commands) are forwarded to P1P2Monitor on the ATmega328P. A full list of commands supported by P1P2Monitor is specified here but in practice you will only need the following ones:
- "L1" to start auxiliary controller ("L" state info maintained in EEPROM)
- "L0" to stop auxiliary controller
- "C2" to start requesting counters ("C" state info maintained in EEPROM)
- "C0" to stop requesting counters
- "E" for parameter writing for Daikin E-series, for example,
- "E 35002F01" to switch heating on (packet type 0x35, parameter 0x002F, value 0x01). Other allowable formats are space-separated "E 35 2F 1" or shortening the third parameter as in "E35002F1".
- "F" (not released yet) for writing for Daikin F-series, for example,
- "F 38 0 1" to set packet type 38 byte 0 to 0 to power FDY model on
- "F 38 0 0" to power FDY model off
- "F 38 8 51" to set FDY model heating fan mode high