-
-
Notifications
You must be signed in to change notification settings - Fork 20
pi4
This is a Raspberry Pi 2B (1GB) version 1.1 running Raspberry Pi OS (Debian Buster) with the latest VSCP daemon installed and among other things have a Frankfurt RS-232 module that connects to a CAN bus that is run to our kitchen on the upper floor of our house. Here there are some nodes that control a refrigerator and a fridge.
The Frankfurt RS-232 module is connected to the VSCP daemon with the level I/CANAL CAN4VSCP driver. The configuration file vscpd.json for the VSCP daemon looks like this
{
"runasuser": "vscp",
"debug": 18446744073709551615,
"guid": "25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00",
"servername": "The VSCP daemon",
"classtypedb": "/var/lib/vscp/vscpd/vscp_events.sqlite3",
"maindb": "/var/lib/vscp/vscpd/vscp.sqlite3",
"discoverydb": "/var/lib/vscp/vscpd/vscp.sqlite3",
"vscpkey": "/etc/vscp/vscp.key",
"logging": {
"file-enable-log": true,
"file-log-level": "debug",
"file-pattern": "[vscp: %c] [%^%l%$] %v",
"file-path": "/var/log/vscp/vscpd.log",
"file-max-size": 5242880,
"file-max-files": 7,
"console-enable-log": true,
"console-log-level": "debug",
"console-pattern": "[vscp: %c] [%^%l%$] %v"
},
"mqtt": {
"bind": "",
"host": "192.168.1.7",
"port": 1883,
"mqtt-options": {
"tcp-nodelay": true,
"protocol-version": 311,
"receive-maximum": 20,
"send-maximum": 20,
"ssl-ctx-with-defaults": 0,
"tls-ocsp-required": 0,
"tls-use-os-certs": 0
},
"user": "vscp",
"password": "secret",
"clientid": "the-vscp-daemon-pi4",
"publish-format": "json",
"subscribe-format": "auto",
"qos": 1,
"bcleansession": false,
"bretain": false,
"keepalive": 60,
"bjsonmeasurementblock": true,
"topic-daemon-base": "vscp-daemon/{{guid}}/",
"topic-drivers": "drivers",
"topic-discovery": "discovery",
"reconnect": {
"delay": 2,
"delay-max": 10,
"exponential-backoff": false
},
"tls": {
"cafile": "",
"capath": "",
"certfile": "",
"keyfile": "",
"pwkeyfile": "",
"no-hostname-checking": true,
"cert-reqs": 0,
"version": "",
"ciphers": "",
"psk": "",
"psk-identity": ""
},
"will": {
"topic": "vscp-daemon/{{srvguid}}/will",
"qos": 1,
"retain": true,
"payload": "VSCP Daemon is down"
},
"subscribe": [
{
"topic": "vscp/pi4",
"qos": 0,
"v5-options": 0,
"format": "auto"
}
],
"bescape-pub-topics": true,
"user-escapes": {
"escape1": "value1",
"escape2": "value2"
},
"publish": [
{
"topic": "vscp/{{guid}}",
"qos": 0,
"retain": false,
"format": "json"
}
],
"v5": {
"user-properties": {
"prop1": "value",
"prop2": "value"
}
}
},
"drivers": {
"level1": [
{
"enable": true,
"name": "can4vscp",
"config": "/dev/vscp_serial0",
"flags": 2147483648,
"translation": 2,
"path": "/var/lib/vscp/drivers/level1/vscpl1drv-can4vscp.so.1.1.1",
"guid": "25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:00",
"mqtt": {
"bind": "",
"host": "192.168.1.7",
"port": 1883,
"mqtt-options": {
"tcp-nodelay": true,
"protocol-version": 311,
"receive-maximum": 20,
"send-maximum": 20,
"ssl-ctx-with-defaults": 0,
"tls-ocsp-required": 0,
"tls-use-os-certs": 0
},
"user": "vscp",
"password": "secret",
"clientid": "vscp-level1-can4vscp-driver",
"publish-format": "json",
"subscribe-format": "auto",
"qos": 1,
"bcleansession": false,
"bretain": false,
"keepalive": 60,
"bjsonmeasurementblock": true,
"reconnect": {
"delay": 2,
"delay-max": 10,
"exponential-backoff": false
},
"tls": {
"cafile": "",
"capath": "",
"certfile": "",
"keyfile": "",
"pwkeyfile": "",
"no-hostname-checking": true,
"cert-reqs": 0,
"version": "",
"ciphers": "",
"psk": "",
"psk-identity": ""
},
"will": {
"topic": "vscp-daemon/{{srvguid}}/drivers/{{ifguid}}/will",
"qos": 1,
"retain": true,
"payload": "vscpl2drv-energy-p1 driver down"
},
"subscribe": [
{
"topic": "vscp/{{guid}}/can4vscp",
"qos": 0,
"v5-options": 0,
"format": "auto"
}
],
"user-escapes": {
"host": "pi4",
"drv": "can4vscp"
},
"publish": [
{
"topic": "vscp/{{guid}}/{{class}}/{{type}}/{{nickname}}/{{data[0]}}",
"qos": 0,
"retain": false,
"format": "json"
}
],
"v5": {
"user-properties": {
"prop1": "value",
"prop2": "value"
}
}
}
}
],
"level2": [
]
}
}
The file is pretty standard. Full debugging is used. The GUID is set to
25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00
connection is made to a local in-house Linux server. Publishing is done in JSON format. Subscription accept all formats (json, string, xml, binary). Server events are published on topic
vscp-daemon/{{guid}}/
which will translate to
vscp-daemon/25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00/
driver info will be published to
vscp-daemon/25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00/drivers
discovery information will be published to
vscp-daemon/25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00/discovery
last will is published at
vscp-daemon/25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00/will
Server events (like server heartbeast and capability events) are published on topic
vscp-daemon/25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00
The entry
"bjsonmeasurementblock": true
will add a the measurement block to json coded events if the event is a measurement.
All pretty standard.
There is only one driver enabled. The can4vscp level I driver. It uses the udev device /dev/vscp_serial0 which is a serial USB adapter that connects to the Frankfurt CAN4VSCP module and thru it the CAN bus.
"translation": 2
is set for the driver. This will translate received Level I measurement events to Level II measurement events to (CLASS2.MEASUREMENT_STR )[https://grodansparadis.github.io/vscp-doc-spec/#/./class2.measurement_str]. Translation settings are described here.
Published events are on json form and published on the topic
vscp/{{guid}}/{{class}}/{{type}}/{{nickname}}/{{data[0]}}
which will be escaped with real values on publish time as below.
- {{guid}} will be replaced by the events GUID.
- {{class}} will be replaced by the events class code. It is possible to use the symbolic name instead.
- {{type}} will be replaced by the events type code. It is possible to use the symbolic name instead.
- {{nickname}} will be replaced with the remote nodes id (nickname).
- {{data[0]}} will be replaced with data byte zero which for a level II measurement is the sensor index for the sensor the measurement comes from.
A full list of topic escapes are here.
The following events are published to the MQTT demo servers demo.vscp.org and test.mosquitto.org (see VSCP-Demo-server). Events are publish to a topic that is built in the following way
vscp/guid/class/type/nodeid/data byte 0
For measurements data byte 0 will be the same as the sensorindex for the sensor originating the measurement value. For example the fridge temperature will be published on topic
vscp/25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:01/1040/6/1
So subscribing to this topic on the demo server will get you live fridge temperature values. The kitch3en temperature on the other hand is on the sensor with index=4 so subscribing to topic
vscp/25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:01/1040/6/4
will get you the live temperatures in our kitchen.
GUID | Description |
---|---|
25:00:00:00:00:00:00:00:00:00:00:00:06:00:00:00 | This is the Raspberry Pi itself. Heartbeats on similar use this GUID. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:00 | GUID for Level I CAN4VSCP driver. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:01 | GUID for node Kelvin NTC10K module inside fridge with nickname=1. There is three temperature sensors. Sensorindex=0 for the on board temperature sensor. Sensorindex=1 for the fridge temperature sensor. Sensorindex=2 for the compressor temperature sensor. Sensorindex=4 for kitchen temperature sensor. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:02 | GUID for node with nickname=2. Paris relay module controlling relays for workshop lights. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:03 | GUID for node with nickname=3. Paris relay module controlling relay in the fridge. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:04 | GUID for node with nickname=4. Beijing I/O module in refrigerator. Controls compressor and light on refrigerator. |
25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:05 | GUID for node with nickname=5, Kelvin NTC10K in refrigerator. There is three temperature sensors. Sensorindex=0 for on board sensor. Sensorindex=1 for upper cabin. Sensorindex=2 for lower cabin. |
FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:0A:11:62:00:00 | Heartbeat from Pi4 |
FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:0A:11:62:00:01 | CPU temperature of Pi4 |
FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:0A:11:62:00:02 | GPU Temperature of Pi4 |
The VSCP Project (https://www.vscp.org) - Copyright © 2000-2024 Åke Hedman, the VSCP Project