Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitoconnect passthrough #87

Open
challo2018 opened this issue Apr 20, 2023 · 16 comments
Open

Vitoconnect passthrough #87

challo2018 opened this issue Apr 20, 2023 · 16 comments
Labels
enhancement Something to improve or enhance VitoWiFi

Comments

@challo2018
Copy link

Is there any possibilty or any user which used VItoWifi together with viesmann vitoconnect due to longer viessmann guarantee when using vitoconnect?

ESP32 DEV board has CP2102 Serial Chip which is similar to the one from original optolink kabel.
So it is possible to connect ESP32 USP directl to the vitoconnect. But It's necessary to extend VItoWifi to put all trafic from IR Serial port to the USB Serial port and other way round.

I'm waiting for my ESP32 Dev boards to try such an implementation. Is there any user who allready tried?

@bertmelis
Copy link
Owner

Currently, VitoWiFi doesn't support sniffing.

VitoWiFi has long been neglected from my side since I didn't use it myself anymore. However, in a couple of months I will move back to a house where I have full control over the (Viessmann) heating and breath new life into this project.

I'm already thinking about creating a version 3 with more flexibility on how to use the library. Suggestions are welcome of course. Sniffing is on the list as extended warranty is definitely something you don't want to sacrifice on expensive equipment.

@bertmelis bertmelis added the enhancement Something to improve or enhance VitoWiFi label Nov 29, 2023
@bertmelis
Copy link
Owner

v3 is more modular and a sniffer is probably within the possibilities to create. not top priority...

@challo2018
Copy link
Author

Thanks for your answer. Do you have time schedule for V3?

@bertmelis
Copy link
Owner

V3 will be very soon. The sniffer features a bit later.

I'm already testing (on a raspberry pi, code is compatible).

@challo2018
Copy link
Author

Hello bert, any news here? I read that V3 is allready running stable on your system, so i will try it with my heat pump. do you recommend using esp32 or raspberry?

@bertmelis
Copy link
Owner

I'm running V3. I'm running on a raspberry pi because it's easier for me for testing. An ESP would be more stable but that has more to do with stability of the system (my RPI sometimes fails because of my power stability).

I'm working on a ESP version that Serial via USB.

Passthrough should also be possible with the separate components of the library. I will think of an example and add it to the repo.

@challo2018
Copy link
Author

thank you, would be great to test such an version!

@bertmelis
Copy link
Owner

Just for my understanding:

  • you connect the ESP to VitoConnect
  • you connect a diy serial optolink via one of the other UARTs
  • the firmware forwards USB to optolink and vice versa.

Could we start with just the forwarder and have a look at the messages? I don't have a Vitoconnect so I can't test how this device queries the machine (bulk, burst...). So we first create an ESP passthrough device and log the messages to MQTT?

PS To avoid any possible trouble, you should tie GPIO15 to ground to suppress boot messages.

@challo2018
Copy link
Author

Currently Viessmann OptoLink Adapter (CP2102 Serial Chip) is connected to vitoconnect via USB.

I can build DIY Optolink adapter and connect it to Serial2 and connect ESP32 USB Port(Serial1) to the vitoconnect.

We can start with your suggestion to have first passthrough and logging only.

@bertmelis
Copy link
Owner

UNTESTED (Quick and dirty, I don't even know it compiles or not.)
MQTT based on https://github.com/bertmelis/espMqttClient

#include <Arduino.h>
#include <WiFi.h>
#include <cbuf.h>  // Circular buffer from Espressif Arduino framework

#include <espMqttclient.h>

#define WIFI_SSID "yourSSID"
#define WIFI_PASSWORD "yourpass"

#define MQTT_HOST IPAddress(192, 168, 1, 10)
#define MQTT_PORT 1883

#define USBSerial Serial
#define OptolinkSerial Serial1
#define BUFFERSIZE 256

cbuf txBuffer(BUFFERSIZE);
cbuf rxBuffer(BUFFERSIZE);
uint8_t buf[BUFFERSIZE];

void setup() {
  USBSerial.begin(4800, SERIAL_8E2);
  OptolinkSerial.begin(4800, SERIAL_8E2);
  
  mqttClient.setServer(config.hostname, config.port)
            .setServer(config.hostIP, config.port);

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(5);
  }
  mqttClient.connect();
}

void loop() {
  // 1. read data from USB into txBuffer
  int fromUSB = USBSerial.available();
  if (fromUSB > 0) {
    size_t room = txBuffer.room();
    USBSerial.read(buf, room);
    txBuffer.write(buf, room);
    mqttClient.publish("VitoWiFiPassthrough/fromUSB", 0, false, buf, room);
  }

  // 2. write txBuffer to Optolink
  while (txBuffer.available()) {
    if (OptolinkSerial.write(txBuffer.read()) < 1) break;
  }

   // 3. read data from Optolink into rxBuffer
  int fromoptolink = OptolinkSerial.available();
  if (fromoptolink > 0) {
    size_t room = txBuffer.room();
    OptolinkSerial.read(buf, room);
    rxBuffer.write(buf, room);
    mqttClient.publish("VitoWiFiPassthrough/toUSB", 0, false, buf, room);
  }

  // 4. write rxBuffer to USB
  while (rxBuffer.available()) {
    if (USBSerial.write(rxBuffer.read()) < 1) break;
  }
}

@bertmelis
Copy link
Owner

The above is (or should be) a simple USB <--> Serial forwarder.
Instead of publishing the passed-through message via MQTT, you could parse using VitoWiFiInternals::ParserVS2 and it will give you a (reference to a) VitoWiFi::PacketVS2.

You can still choose to only parse messages coming from USB or only from Serial or both. Use a separate parser if you want both.
Depending on what the data looks like, the data is directly usable or has to be further split up.

If you could test the sample above and let me know how it goes...

@challo2018
Copy link
Author

Thank you!! I will build up my DIY Optolink and check the code as quick as possible!

@bertmelis bertmelis pinned this issue Sep 24, 2024
@bertmelis
Copy link
Owner

closing. feel free to reopen if further help is needed.

@bertmelis
Copy link
Owner

Maybe this is a solution for you: https://www.wemos.cc/en/latest/s3/s3.html

If Vitoconnect recognizes the ESP32-S3 as adapter, you could connect the original optolink to the ESP via the OTG port. Then this library could be integrated to communicate with the optolink: https://github.com/bertmelis/USBHostSerial

I have yet to adapt VitoWiFi to be compatible.

@bertmelis bertmelis reopened this Sep 24, 2024
@challo2018
Copy link
Author

i will get an ESP32-S3 and come back to you for test. Thank you!

@challo2018
Copy link
Author

@bertmelis : I got ESP32-S3 for Testing your suggestion. Can you give me some hint on how to proceed with testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something to improve or enhance VitoWiFi
Projects
None yet
Development

No branches or pull requests

2 participants