Using the CAN Bus of a Viessmann Vitocal 252-A for Data Collection
The Viessmann Vitocal 252-A is a popular heat pump used for residential heating systems. By interfacing with its CAN bus (Controller Area Network), you can collect various metrics from the system - even more than the Viessmann API offers - such as temperature, electrical power, water temperature and operational data. This data can then be forwarded to a home automation system using MQTT and integrated with platforms like ioBroker.
In this article, we will walk through how to connect the CAN bus of a Viessmann Vitocal 252-A heat pump to a Raspberry Pi using a CAN to USB adapter. We will use the Open3e project to read the data from the CAN bus and publish it via MQTT (using Mosquitto) to an ioBroker instance.
📋 Prerequisites
🔧 Hardware:
- Viessmann Vitocal 252-A heat pump with a CAN bus interface.
- Raspberry Pi (any version with USB ports; we’ll use RPi 4 for this tutorial).
- CAN to USB Adapter (e.g., PEAK-System PCAN-USB, CANable, or any compatible device - I used a model from Innomaker (1).
- CAN Bus Cable to connect the heat pump’s CAN interface to the adapter.
- Home automation system (like ioBroker) with MQTT support.
- MQTT broker (we’ll use Mosquitto in this tutorial).
💻 Software:
- Raspberry Pi OS installed on your Raspberry Pi.
- Open3e project (available on GitHub).
- Mosquitto MQTT Broker installed on the Raspberry Pi.
- ioBroker installed and configured on your home automation server.
🛠️ Step 1: Setting Up the CAN to USB Adapter
- Plug the CAN to USB adapter into your Raspberry Pi.
- Connect the CAN bus from your Viessmann Vitocal 252-A heat pump to the adapter. On my heat pump this is the interface 91 - ports 6 (CAN-L), 7 (GND) and 8 (CAN-H):
⚡ Note: You should be comfortable working with electrical wiring or consult an electrician for installation. Always prioritize safety.
- Confirm the adapter is recognized by the Raspberry Pi by running the following command:
1
dmesg | grep can
This should show output indicating that the CAN interface is up and running.
Configure the CAN interface: In order to read the CAN bus data, we need to set up the CAN interface on the Raspberry Pi. If you are using a USB to CAN adapter like PCAN-USB or CANable, follow these steps:
To bring up the CAN interface, execute the following command:
1
sudo ip link set can0 up type can bitrate 250000
This command configures the CAN interface (
can0
) with a baud rate of 500 kbps, which is commonly used for the Vitocal 252-A.Test the connection: You can verify the connection to the CAN bus by using the
candump
tool:1
candump can0
If the system is connected correctly, you should start seeing CAN frames being printed on the screen.
💻 Step 2: Setting Up Open3e on the Raspberry Pi
The Open3e project is a powerful open-source software designed to read data from heat pumps like the Viessmann Vitocal 252-A via the CAN bus. It provides a way to access and interpret the heat pump data and can publish it to MQTT.
📦 Install required Python Libs
Open3e needs Python top be run, so we will install this by:
1
sudo apt install git python3 python3-pip
🔄 Clone the Open3e repository:
To begin, clone the Open3e GitHub repository:
1
pipx install git+https://github.com/open3e/open3e.git
📊 Create Datapoints:
Open3e will scan your CAN bus for all available datapoints. You should run this command once to get all available addresses:
1
2
mkdir open3e
open3e_depictSystem
▶️ Run and Test Open3e:
To read data from the heat pump, start Open3e to fetch some metrics:
1
open3e -c can0 -m 127.0.0.1:1883:open3e -t 30 -a
The program will begin reading data from the CAN bus and publishing it to the console. You can customize the parameters and data points being read by modifying the Open3e configuration files.
🔌 Step 3: MQTT Integration with Mosquitto
Mosquitto is a lightweight MQTT broker that will allow you to send the heat pump data from the Raspberry Pi to your ioBroker instance.
🖥️ Install Mosquitto MQTT Broker:
To install Mosquitto on the Raspberry Pi, run:
1
sudo apt-get install mosquitto mosquitto-clients
Start the Mosquitto service:
1
2
sudo systemctl enable mosquitto
sudo systemctl start mosquitto
🔐 Configure Mosquitto for Authentication (Optional):
You may want to configure Mosquitto with username and password for security. Open the Mosquitto configuration file:
1
sudo nano /etc/mosquitto/mosquitto.conf
Add the following lines to enable authentication:
1
2
allow_anonymous false
password_file /etc/mosquitto/passwd
Then, create the password file:
1
sudo mosquitto_passwd -c /etc/mosquitto/passwd your_username
You’ll be prompted to enter a password.
After editing the configuration file, restart Mosquitto:
1
sudo systemctl restart mosquitto
📡 Publish Data to MQTT:
Once Open3e is running and connected to the CAN bus, it will automatically publish the heat pump data to the MQTT broker when passing the option -m 127.0.0.1:1883:open3e
. You can check the data being published by subscribing to the MQTT topic. Run the following in a terminal:
1
2
open3e -c can0 -r 548,565,1211,1391,268,269,271,274,2488,1190 -m 127.0.0.1:1883:open3e -t 30
mosquitto_sub -h localhost -t "#"
This will show all data being published to the MQTT broker. Open3e typically publishes data to topics like:
1
2
3
/open3e/temperature
/open3e/pressure
/open3e/system_status
🏠 Step 4: Integrating with ioBroker
Finally, you need to configure ioBroker to subscribe to the MQTT topics and display the data.
📥 Install the MQTT Adapter in ioBroker:
- Go to the ioBroker Admin interface.
- Navigate to Adapters, then search for MQTT.
- Click Install to install the MQTT adapter.
⚙️ Configure the MQTT Adapter:
- Once installed, go to the MQTT Adapter settings.
- Set the MQTT Broker to the IP address of your Raspberry Pi (e.g.,
mqtt://192.168.x.x
). - Set the username and password (if configured in Mosquitto).
- In the MQTT Topics section, specify the topics published by Open3e (e.g.,
/open3e/temperature
,/open3e/pressure
, etc.).
📊 Visualizing Data in ioBroker:
After configuring the MQTT adapter, ioBroker will automatically recognize the topics and display them in the object tree. You can now use ioBroker’s visualization tools to create dashboards and monitor the heat pump data in real-time.
🧠 Final Thoughts
By following these steps, you can connect the CAN bus of the Viessmann Vitocal 252-A heat pump to a Raspberry Pi using a CAN to USB adapter, and use the Open3e project to read data from the heat pump. The data is then forwarded to an MQTT broker (Mosquitto), and can be visualized in your home automation system (like ioBroker).
This setup allows you to monitor the performance of your heat pump, track important metrics like temperature and pressure, and integrate this data into a larger home automation system. Whether you’re looking to optimize energy use, automate heating schedules, or simply keep an eye on your system’s performance, this project can help you achieve those goals efficiently.
Affiliate link - if you make a purchase through this link, I may earn a small commission. There are no additional costs for you. Of course, when, where, and how you buy a product is entirely up to you. ↩︎