rjblake / remeha

Connect ESP8266 directly to Remeha CV/Boiler to read data using PHP
28 stars 13 forks source link

Connecting to my Remeha Tzerra #7

Closed AndreTzerra closed 6 years ago

AndreTzerra commented 6 years ago

Hello Richard,

Since a vew days I am trying to get your great script working. Thanks for sharing it! But I only got 'CRC' errors when I try to connect to the Tzerra boiler.

I am a servicetechnican who works with HVAC and my programming skill are at minimum level. I use Recom often for my work, and last autum I got a new Remeha Tzerra boiler at home. First I used the orginal Remeha cable, and later I made my own FTDI cable to connect.

I first have connected it with a raspberry pi3 running ser2net. After some testing with my laptop with a virtual port I can connect with Recom trough the network.

I also have found remeha.py and datanet.py. Got them running and sending the data to a second raspberry pi3 with Grafana running. This is working great. But I am missing a lot info. Like Parameters, counters, ect.

Thats why I want to get your script running. My goal is to get al the possible data pushed to Grafana. This is what I have done:

On my first PI3 Ser2net 3029:telnet:0:/dev/ttyUSB0:9600,8DATABITS,NONE,1STOPBIT So i can connect to the boiler trough "192.168.2.157:3029".

On the second raspberry Pi3 I have Grafana running and after installing php I tested your script by running 'sudo php -f remeha.php' trough the terminal window. This is the output:

======================================================================================================================================================================
PHP version: 7.0.27-0+deb9u1
Connected to 192.168.2.157:3029
Sending request...
Sample Data read: FFFB03FFFB01FFFE01FFFD00
Data written to log: /var/log/remeha_sample_data.log

************** CRC ERROR!!!! ***********
Sample Data read: FFFB03FFFB01FFFE01FFFD00
Data written to log: /var/log/remeha_sample_data.log

************** CRC ERROR!!!! ***********

The next is written in the Remeha_sample_data.log:

**** CRC Error **** | 2018-04-07 07:54:18 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:54:33 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:54:48 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:55:03 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:55:18 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:55:33 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:55:48 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:56:03 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:56:18 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:56:33 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:56:52 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:57:47 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:58:02 | 02 fb03fffb01fffe01fffd00  03| 
**** CRC Error **** | 2018-04-07 07:58:17 | 02 fb03fffb01fffe01fffd00  03| 

I also found a test script to run:

<?php
require('remeha_functions.php');
$data_sample = $argv[1];
$hexstrPayload = substr($data_sample, 2, 140);
$hexstrCRC = substr($data_sample, 142, 4);
$crcCalc = crc16_modbus($hexstrPayload);
echo "Payload: $hexstrPayload\n";
echo "CRC (in string) : $hexstrCRC\n";
echo "CRC (calculated): $crcCalc\n";
?>

This is the output:

PHP Notice:  Undefined offset: 1 in /var/www/html/remeha/test.php on line 3
Payload: 
CRC (in string) : 
CRC (calculated): ffff

The only thing what is going wrong is the CRC check. Thats what I think. After some digging in the hex code with wireshark I see similar strings. Below you can find some of my search results after connecting my Tzerra boiler to Recom.

Sample from my digging:

Sample 02fe010508020169ab03

counter1 02fe000508101c98c203
02fe000508101d590203
Id1 02fe000508010bd49c03
Id2 02fe010508010be95c03
Id3 02fe030508010b909c03

02fe0b0508010b715d03

param1 02fe0005081014990403
param2 02fe000508101558c403
param3 02fe000508101618c503
param4 02fe0005081017d90503
param5 02fe0005081018990103
param6 02fe000508101958c103
param7 02fe000508101a18c003
param8 02fe000508101bd90003

On this point I don't know how to continue? can you provide me some tips how to get trough te CRC check?

I also believe that after that I need to investigate the code later to get it work with the Tzerra instead of the Calenta.

Andre

rjblake commented 6 years ago

Andre - I will try to take a look tonight. Can you let me know exactly which model Tzerra and what Recom reports as the XML file and version it is using? The data being returned is not complete, that is certain (it should always start with an 02 and end with a 03). Also the test.php script requires you to incluse the data string to be checked (it doesn't read the boiler or any data file): e.g. "php testcrc.php 0201FE064802016C0F480F0080008080F300808610D607BC027C15D0070000000000BC020000000000000001C20B1000FFFF00000000FFFF1000BC020000000080000000000000E6B003" (without the "")

On a separate note, a RaspberryPi is a bit over an overkill to get/read data from the boiler unless you have it spare lying around, or plan to move all the processing of the data to it as well. Just beware that constant writing to the SD card may become an issue as others have had. A cheap €5.- ESP8266 is more than suitable, but understand if you prefer the RaspPi approach

AndreTzerra commented 6 years ago

Hello, Richard,

Recom found the PCU-05_P3. The boiler is a Tzerra 39C. I have read that the data must have start with 02 and end with an 03. But after that point it was to confusing for me. Where do I find your example string from above? But as always, I'm willing to learn. :o)

About the Raspberry Pi3. And I have the RPI3 lying arround. When I have some more time I want to test the linux software for the OTmonitor (Opentherm Gateway) Right now it's connected to my VeraPlus trough USB. I am planning to get that working over ethernet. Thats why I have the Rpi connected. I did not had any problems writing to the SD. Thanks for the hint!

bernie-gitmans commented 6 years ago

Dear Andre, as Richard has helped me with my setup (a Tzerra) I feel that I have to point you to the direction I went. Please take a look at the fork I made from the project that Richard has made.

The code I'm using still has ( I think) some timing issues, and the best working php script is the remeha-tzerra-samples.php which gives me the least number of rejected CRC checks.

AndreTzerra commented 6 years ago

Hello Bernie, Thank you for pointing me to your fork you made. I will take a closer look tonight.

Thanks in advance....

rjblake commented 6 years ago

@bernie-gitmans - thanks for stepping in. Indeed, take a look at Bernie's fork as he is using a Tzerra. On another note, one thing to bear in mind with the Raspberry Pi. The RX, TX and GPIO's are all 3.3V. You will likely run the risk of damage connecting the Tzerra (uses 5V TTL) without some additional circuits to bring the voltages down (some resistors, or better a level shifter . This was my main reason to use a 5V safe ESP8266 With regards testing, a terminal emulator to connect to Ser2Net will allow you to send the commands to and receive from the Tzerra

AndreTzerra commented 6 years ago

Hello Richard and Bernie, I have being searching and reading articles for some days. This is my plan for the next week:

I will let you know how it all worked out.

rjblake commented 6 years ago

@AndreTzerra - at the time I found using a Huzzah ESP & ESP-Link the simplest/quickest solution. I runs without a problem and have not had to reboot the ESP since installation. My config is as shown (I use a static IP address). Note that the "µC Console" will only display some "����" type characters as these are all in HEX which ESP-Link doesn't handle. image

AndreTzerra commented 6 years ago

Hello Richard, After recieving the board and some soldering yesterday, tonight I had to find out how to flash ESP-Link. After some retry's a have managed it to get it working!

Right now I have connected the board to my local network with a static IP adres. Tomorrow I will make a little cable to connect the board to the boiler and to find out how strong the Wifi connection is on the attic. Do you have placed the ESP8266 board inside the boiler or outside? The Remeha Tzerra has a plastic cover. I could place it inside the boiler to keep it 'closed'. It depends on the Wifi signal for my home situation.

I will let you know when I got the connection working! Thanks for al the help!

rjblake commented 6 years ago

I have it installed inside the boiler in a open space to the right of all the other controller electronics. Did not have any effect on my WiFi connection but I do have a second access point reasonably close by

AndreTzerra commented 6 years ago

When try to connnect to the ESP8266 HUZZAH breakout that is connected to the boiler it fails to work. I have a wireless connection trough a static IP adres. With the board mounted in the boiler.

image

This is the output from the µC Console:

�H %������������ �������1723016720680 Tzerra NL U��H %������������ �������1723016720680 Tzerra NL U��H %������������ �������1723016720680 Tzerra NL U�

image

This is the debug log: s, h=16808 366485> HTTP GET /log/text: 200, 395ms, h=17152 385315> HTTP GET /services/info: 200, 391ms, h=16600 385316> HTTP GET /menu: 200, 393ms, h=16808 387798> HTTP GET /console.js: 200, 213ms, h=17152 388047> HTTP GET /console/text: 200, 7ms, h=13800 388144> HTTP GET /console/fmt: 200, 205ms, h=14912 388145> HTTP GET /console/baud: 200, 207ms, h=15680 388149> HTTP GET /menu: 200, 212ms, h=16440 389203> HTTP GET /console/text: 200, 394ms, h=17128 392496> HTTP GET /console/text: 200, 200ms, h=17152 392753> HTTP GET /log/text: 200, 12ms, h=14568 392843> HTTP GET /menu: 200, 202ms, h=15680 392844> HTTP GET /log/dbg: 200, 203ms, h=16464 398824> HTTP GET /log/text: 200, 402ms, h=17152 400322> HTTP GET /log/text: 200, 252ms, h=17152 403942> HTTP GET /log/text: 200, 369ms, h=17152 407446> HTTP GET /log.html: 200, 213ms, h=17152 407867> HTTP GET /log/text: 200, 19ms, h=13728 408243> HTTP GET /log/dbg: 200, 395ms, h=14752 408243> HTTP GET /menu: 200, 396ms, h=14952 408247> HTTP GET /favicon.ico: 200, 399ms, h=16920 411331> Turning ON uart log 411923> HTTP POST /log/dbg: 200, 593ms, h=17128 412401> Turning OFF uart log 412713> HTTP POST /log/dbg: 200, 316ms, h=17128 414415> HTTP GET /log/text: 200, 5ms, h=17152 430755> HTTP POST /log/dbg: 200, 330ms, h=17128 432802> HTTP GET /log/text: 200, 392ms, h=17152 469684> HTTP GET /log.html: 200, 217ms, h=17152

Any idea whats going wrong? do I have to set the Pin assignment Presets to esp-brigde and leave it that way?

Recom can't find the boiler when I try to connect to it trough a virtual serial port.

When I connect with Bernie's Tzerra forked script it gives the next output. **** CRC Error **** | 2018-04-19 21:56:39 | 02 01fe06480201d913cd1380f3a80780f300800212a108c4098813d0070000000000bc020000006400000011c20b0000ffff00000000ffff00c0bc020000000080460359410000 11a4 03|

and on the debug log: 382725> Accept port 23, conn=0x3fff7318, pool slot 0 405851> Accept port 23, conn=0x3fff7318, pool slot 0 420997> Accept port 23, conn=0x3fff7318, pool slot 0 436146> Accept port 23, conn=0x3fff7318, pool slot 0 459160> Accept port 23, conn=0x3fff7318, pool slot 0 474420> Accept port 23, conn=0x3fff7318, pool slot 0 484467> HTTP GET /menu: 200, 199ms, h=16400 484611> HTTP GET /services/info: 200, 204ms, h=17496 487227> HTTP GET /console/baud: 200, 211ms, h=13808 487229> HTTP GET /menu: 200, 214ms, h=14568 487235> HTTP GET /console/fmt: 200, 218ms, h=15328 487335> HTTP GET /console/text: 200, 220ms, h=17096 488090> HTTP GET /console/text: 200, 925ms, h=17496 490108> Accept port 23, conn=0x3fff7318, pool slot 0 491141> HTTP GET /console/text: 200, 5ms, h=17496

Last night I lost connection with the board. I have reflashed it. I will test it again tonight.

rjblake commented 6 years ago

@AndreTzerra - a few things to check/take note of:

  1. The output shown in the µC Console will always look a mess - the esp-Link does not display the hex natively; so what you are seeing is expected
  2. The 'Debug Log' - this is for ESP-Link and other than seeing activity, it serves little purpose in this case, other than to see if requests are being received (which they are)

Sometime the boiler does not respond quickly enough and does occasionally returns CRC errors. The 'remeha-samples.php' sends the shortest string, so is probably the most suitable PHP file to use for testing. What you can do is just try running this from a command line (php -f remeha-samples.php) a number of times, with a short delay between runs if CRC errors are showing up. Suggest these are run using PHP version 7.0 (in my case I use version 7.0.27 or 7.0.28). If you are still getting CRC errors after quite a number of runs, you can click the 'Reset esp-link' on the 'Debug log' page. Also, check the 'UART debug log' is set to 'off'.

If you are using a Windows machine, you can also try using RealTerm to connect to the ESP (can create a Telnet connection directly to the ESP) and set it up for HEX. From there you can paste the HEX that is sent to the Tzerra and check the responses.

If you are still having problems, you will need to diagnose from first principles to determine the root cause of the problem.

AndreTzerra commented 6 years ago

Yeah,..... Richard, I got it working! What went 'wrong'? First I was testing the connection with recom and a virtual serial port on my laptop. I found out that Recom did not find the boiler fast enough. If I got it working the right way, I don't need Recom at all. ( only for my work than)

I was trying the code from Bernie because he also working on the Tzerra code. But I only kept de CRC errors. Tonight (after a 30 km walk I tried your code. And I found out that this code is working. It connects and reads the boiler info.

My next problem is that I don't use Domotics. I want the info to be send to Grafana. I will look at that tommorow. Maybe I will install Domotics on the Rasberry Pi 3.

rjblake commented 6 years ago

@andretzerra - good to hear. The only problem you will now see is that the mapping of codes for Calenta and Tzerra are not the same and result will be some wrong info. E.g. the DHW-in above (showing as -32). That’s where Bernie’s code is a better option for you.

AndreTzerra commented 6 years ago

Updated Message!!

Richard, beside some wrong values I had an other problem. I have installed Domotics on the RP3. When I started the remeha.php script I got some errors.

I found out that I had to install php-curl! That function was missing and causing the errors. After installing it, it works like a charm...

Right now I have to test everything and see that I get right parameters for the Tzerra trought Bernies Forked version. After that I have to figure out how to get the values into Grafana trought Domoticz.

If you want to close this issue, you may. Eventually I will contact you on the Domoticz forum if thats still posible...

Thanks, Richard and Bernie for all the help.

I really appreciated it.

rjblake commented 6 years ago

Indeed, there are a few modules required for php that may/may not have been installed by default. I see you sorted your earlier issue (assume you changed port to the same Domoticz port you access through web and not remote port). As far as Grafana, there are quite a few threads/blogs on the subject. Suggest starting here; although you may want to check out the standard Domoticz graphs as they are quite sufficient for most and don't require any additional complexity in setting up scripts, links, etc.