canpicker
Collect data from the CAN bus using the Elster protocol
Table of Contents
Requirements
- Python 3.9
- MySQL (optional)
- Grafana (optional)
- Raspberry Pi + CANable (or similar devices)
Installation
- Download the latest version
wget https://github.com/fknipp/canpicker/archive/refs/heads/main.zip
- Unzip the package
unzip canpicker-main.zip
- Change the directory
cd canpicker-main
- Install the dependencies
pipenv install
Cron Job
To collect the data every x minutes, it's necessary to create a cron job. This is an example to query the data every two minutes:
*/2 * * * * /home/pi/canpicker-main/bin/canpicker
Database (optional)
Execute the seed file via MySQL command line or copy the query into your MySQL shell.
Grafana (optional)
With Grafana you can create your own dashboard with widgets or use the existing template.
Config
The configuration for the CAN bus and for the data to be queried is located in config.yml. The database configuration is located in .env.
CAN bus
File: config.yml
Example
can:
interface: can0
sender: 680
Description
interface
: CAN bus interfacecan0
sender
: Sender ID680
Data
File: config.yml
See http://juerg5524.ch/data/ElsterTable.inc for the indexes.
Example
data:
- name: AUSSENTEMPERATUR
index: 180.000c
format: dec_val
- name: QUELLENTEMPERATUR
index: 180.01d4
format: dec_val
- name: FEHLER
index: 180.0001
Description
name
: Name for the data pointAUSSENTEMPERATUR
index
: Receiver and Register separated by a dot180.000c
format
(optional):dec_val
mil_val
little_endian
Datasinks
Configuration File
File: .env
Rename the .env.example
file to .env
and adapt it for your needs.
Otherwise create it with the content for your usecase.
Storing Data to MySQL
Tha values are stored in the table sepicker. See the seed file for the data definition.
DB_DATABASE=heat-pump
DB_HOST=127.0.0.1
DB_USER=root
DB_PASSWORD=
Sending Data to an HTTP Endpoint
The data is sent as GET request to a configurable URL.
The URL template allows the substitutions:
- $timestamp for the timestamp in the ISO format
- $name for the name as configured in config.yml
- $value for the value retrieved on the CAN bus
HTTP_URL_TEMPLATE=http://loxone.local/dev/sps/io/$name/$value
HTTP_USERNAME=
HTTP_PASSWORD=
Output to the Console
This is helpful for debugging.
CONSOLE_OUT=1
Resources
- http://juerg5524.ch/list_data.php
- https://github.com/andig/goelster
- https://github.com/Andy2003/heat-pump-api
- https://github.com/danielbayerlein/sepicker
- Integration with Loxone: https://github.com/fknipp/python-can-loxone-heating-integration
License
© 2020-present Daniel Bayerlein
© 2023-present Franz Knipp
See LICENSE for details.