General HowTo's VSCP

Howto: Read a #VSCP mdf file with node.js

The Module Description file is a XML file that all VSCP devices must have and which describe the device. It can either be stored on the device itself or more common linked by the device and stored on some external server storage. Software that wants to configure a device can fetch this file to get the knowledge to do so. Typically a user interface use this file to guide a user through device configuration. A good thing is that one software can handle and configure any device.

A sample MDF file is here an here.

Read a mdf file from a device, parse it and display the module name. A device can consist of several modules, there will always be one and result.vscp.module[0] will always refer to the first. Most devices contains only one module. You can get the number of modules with result.vscp.module.length

Below are some Javascript examples on how to get information from the MDF-file.

Display the module name

const axios = require('axios');
const xml2js = require('xml2js');

let parser = new xml2js.Parser();

  .then((response) => {
                         (err, result) => {
  .catch((err) => {    

Similar to above sample get a link to the manual for a device


List all registers with


Iterate through all registers an display there names

  .then((response) => {
    parser.parseString(, (err, result) => {
      for (let reg of result.vscp.module[0].registers[0].reg) {

  .catch((err) => {

List register descriptions with


You get the language code for a register name or a register description with


List abstractions with

  .then((response) => {
    parser.parseString(, (err, result) => {
      for (let reg of result.vscp.module[0].registers[0].reg) {

  .catch((err) => {

List number of events the module can generate and the events

console.dir('# events: ' + result.vscp.module[0].events[0].event.length);

If you want an url to a picture of the module


If you want the manual


or a firmware image


The number of firmware images available

  .then((response) => {
    parser.parseString(, (err, result) => {
  .catch((err) => {

The release date for a specific firmware


The way this works should be obvious by now. Enjoy!

HowTo's VSCP

HowTo: SMS Alarms

The problem

Just last week a house burned down to the ground here in my hometown. The family of two adults and three kids just made it out. This reminded me of the importance of alarms. My family as any family I guess have had some incidents over the year. In our case with a four floor building, cellar, office, apartment where we live and the attic it can be hard to, despite alarm equipment, to recognize what is happening in the cellar when your are in the apartment watching a film or even worse, sleeping. We have had our incident over the years as most people do. I use VSCP here of course. This system is intelligent enough to close down functionality  when things get bad. But a few weeks ago I had a bad incident. I have a VSCP node that control the water boiler in the cellar for warm water. This is a very simple setup. A relay, a sensor and a control node. I can thus remotely control sense and control the temperature of the hot water in the house. Sitting in the office I noticed a strange sound. I usually play music loud so it had been going on for some time I guess. I went around the house investigating the sound and when I came down to the cellar I heard that the boiler literally boiled hard. Not a good thing. There is a risk for a steam explosion from this so I got really worried. I turned of the power. Opened valves for hot water in the office and got steam and boiling water coming out. I checked the control unit and it had turned of the relay. Still the temperature was way over the limit. There is an independent security unit inside the boiler that should turn off power when it get over a certain temperature. Apparently this mechanism had not done it’s job. Also the security valve that prevent to hot water from going out in the system also malfunctioned otherwise I should not have got steam hot water out of the office valve. Two faults. The pressure security mechanism on the other side worked. But the boiler never got up to the 10 bar needed to release it. So things were actually not to bad. Bit could gone worse if I had been away for example. I later checked the cause and detected that the relays had gone stuck in the on position.  Something that happen to relays some times when load is heavy or control is a bit jumpy.  I also tested the overheat protection and it worked as it should, probably it would have just needed a bit more time to cut the power. The blender protecting the water line from to hot water was the only faulty component. Still this was a bit scary. I need to be alarmed if this happen again.

GSM Modem

I previously sold professional GPRS modems in the FrogShop from Caimore. Still have some around so I decided to put one to work. You can find may similar on Aliexpress or ebay. and even lower cost modules intended for Arduino or similar as the one below. They all have there pros and cons.

SIM Card

Next thing is to find a SIM card. In Sweden this is not a simple thing if you just want a module that sends a few SMS’s per year. The solutions available are highly overpriced. I know there are other and better options available in other countries. I just select a cash card to get started.


Initially I thought about writing a driver for the VSCP daemon and this may still be an option, we will see. I have for a long time used Smstools a wonderful package for uses like this. With the help of the decision matrix of the VSCP daemon it will be possible to do plenty without a driver. So this is the solution I go for. There is a nice getting started tutorial for smstools here. Thus no need for me to write one again. The only thing i ned to do to get things working is to set the device and the baudrate lines in /etc/smsd.conf file
device = /dev/ttyUSB0
as I use an USB adapter for serial communication. And
baudrate = 115200
as i use that higher speed. Then I just restart the smsd daemon with
sudo service smsd restart
and everything is working.

Sending SMS’s

We are just interested in sending SMS’s here so we stick to that. But receiving SMS’s (we look at that in a later post) is also equally simple. To send a SMS one just copy a formated file into the folder /var/spool/smsd/outgoing. So to send an SMS to +467012345678 one send a file
To: 467012345678
ALARM: The water in the boiler is way to hot!
Write this to a file and copy it to /var/spool/smsd/outgoing and the SMS will be delivered to the set recipient. You can set the header to
To: 467012345678
Flash: yes

ALARM: The water in the boiler is way to hot!
to send a flash SMS (is displayed on the users screen directly but not saved). It can hardly be simpler.


Another possibility is to make a call to a receiver instead. Add Voicecall to the header like this
To: 46730533146
Voicecall: yes
TONE: 5 #,#,#
Here the mentioned precipitant will receive a call and when answered five groups of three “#” DTMF tons will be sounded. Tones that can be used to tell the recipient about the cause of the alarm. I will for instance use the number of “#” sounds as an indication of what floor the alarm happened. Possible with different tones for different alarms.

vscpd and smstools

So now lets put this to work for our VSCP based system. Alarm related events is collected in the class CLASS1.ALARM. The CLASS1.ALARM, Type=2, Alarm occurred is intended for alarm conditions.  So if we let sensors that generate alarms send this event and trigger on it in the decision matrix of the VSCP daemon we can send our SMS and voicecalls from there. The zone and subzone can be used as markers for where the alarm occurred. The originating GUID can also be used to identify this.
<row enable="true" groupid="alarm" >

	<comment>Send alarm.</comment>
	<mask priority="0" class="65535" type="65535" guid="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" >
	<filter priority="0" class="1" type="2" guid="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" > 
	<param >/home/vscp/ %zone %subzone event.guid %isodate %isotime "Current boiler temp is %vardecode:[boiler-temp]"</param>
	<allowed_from>0000-01-01 00:00:00</allowed_from>
	<allowed_to>9999-12-31 23:59:59</allowed_to>
	<allowed_time>*-*-* *:*:*</allowed_time>
So what do we have here? We trigger on any alarm occurred event regardless of priority and from which originating GUID (which unit) it comes from. It would have been possible to do several DM rows for different GUID’s (originating nodes) of course to handle alarms from them different. The time block (form <allowed from> to the end) just say that this can happen anytime. Leaving this block out has the same meaning. And last the important action.  In this case, execute external program (0x10) and in the parameter for the action the actual program to execute is specified with the path to it (/home/vscp/ is given. The rest of the action parameter line is arguments to this external program.
  • – Zone for alarm event.
  • %event.subzone – Subzone for alarm event.
  • %event.guid – GUID for alarm event.
  • %isodate – Date on ISO format for alarm.
  • %isotime – Time on ISO format for alarm.
  • %vardecode:[//alarmtext//] – Specific text for alarm.
The description of the decision matrix is here. Zone and subzone is numericals that can be used to specify the place and equipment that generated the alarm. I have floor plan in zone and a room on that floor plan in subzone. The vardecode writes out the content of the given variable if it is present. We will come back to it later. When this row is added the external script will be executed when CLASS1.ALARM, TYPE=2 is generated by a node and received by the VSCP daemon. It is good if the script can do both voice calls and SMS sends and that both can be sent to a list of numbers.

The script

import sys
import uuid

filename_voice = str(uuid.uuid4())
filename_sms = str(uuid.uuid4())

# Dir that holds outgoing SMS messages

# Voicel recipients (comma separated list, empty for non)

# Set to true for flash SMS
bflash = False

# SMS recipients (comma eparated list, empty for non )

SMS_TEXT="An alarm condition has occured!"

# -----------------------------------------------------------------------------

voicetone="5 "
for x in range(0, int( sys.argv[1] ) ):
	voicetone = voicetone + "1,"

voiceRcvList = VOICE_RECEIVERS.split(",")

	for receiver in voiceRcvList:
		print( OUTDIR + "/" + filename_voice + str(cnt) )
		with open( OUTDIR + "/" + filename_voice + str(cnt), "w") as text_file:
			text_file.write( "To: {0}\n".format(receiver) )
			text_file.write( "Voicecall: yes\n\n" )
			text_file.write( voicetone )
		cnt = cnt + 1

SMSRcvList = SMS_RECEIVERS.split(",")

if SMS_RECEIVERS != "" :
	for receiver in SMSRcvList:
		print( OUTDIR + "/" + filename_voice + str(cnt) )
		with open( OUTDIR + "/" + filename_voice + str(cnt), "w") as text_file:
			text_file.write( "To: {0}\n".format(receiver) )
			if bflash:
				text_file.write( "Flash: yes\n" )
			text_file.write( "\n\n" )
			text_file.write( SMS_TEXT+"\n" )
			text_file.write( "Zone={0} SubZone={1} Time={2} Date={3}\n".format(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4] ) )
			text_file.write( "{0}".format(sys.argv[5]) )        
		cnt = cnt + 1
This is the script. It is written i Python to make things simple to edit and/or change. You can find the script in the VSCP repository. Just edit the variables in the beginning of the script to fit your setup and you are set to go. Note that the voice call will do five groups of a series of “1”-press DTMF where the count is the same as the supplied zone parameter. In my case this is the floor plan so I know instantly where something happened and runa way and fix it. The SMS also give me more info.

The variable

To come back to the variable that is sent as a parameter. Perfect is to save a  measurement value in another part of the DM. Like this
<row enable="true" groupid="temperature" >
    <mask priority="0" class="65535" type="65535" GUID="FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF" > </mask>
    <filter priority="0" class="10" type="6" GUID="FF:FF:FF:FF:FF:FF:FF:FF:3C:00:08:01:92:9D:3D:10" > </filter>
    <comment>Store boiler temperature in variable</comment>
    <allowed_from>0000-01-01 00:00:00</allowed_from>
    <allowed_to>9999-12-31 23:59:59</allowed_to>
    <allowed_time>*-*-* *:*:*</allowed_time>

An alternative way to do it

Another way is to do measurement compares, as in this case check the boiler temperature, you can read more about this method here and it is in many ways the same as the one we described above but more specific for boiler temp alarm.

And next?

Now you should be able to add your own alarms to your VSCP setup. Maybe something that will do good work in your remote cottage, alarming  freezing conditions before bad and costly things happens. In my house we will now sleep much better knowing that we will get alarms when things go wrong. I promised to continue with a follow up on how to react on incoming SMS mesages. This makes it possible to remotely control things as well such as turning on the heat in that remote cottage I mentioned above. I will try to write that story up soon. Time is my enemy, or rather lack of it. Cheers /Ake

#VSCP interfaces howto

Something that may confuse new users of VSCP is the GUID of interfaces. Looking at the interface above the CAN4VSCP driver have GUID set to


which means nodes connected to this interface will come in with GUID’s


If we look at the GUID’s if this machine we see that they all start with


As of  the spec we know that this is a GUID constructed from an Ethernet address. In this case only four of the six MAC digits is used. The


is the interface id as set by the VSCP daemon and the last two digits are the nickname id for a connected node.

The problem that can occur here is that the interface digits can be different at different runs of the VSCP daemon. The number is just set when the interface is set up and from time to time this setup can happen in different order. So sometime


can be


or even


One can’t tell beforehand.

This is a problem if one want to use the GUID to identify a node. Problematic as this is just what we want in most cases. To trigger on an event from a specific node in a decision matrix the GUID is the item to filter on. Just as in this case

Here we store a temperature measurement in a variable if it comes from a node with GUID


and measurement index = 1

If the interface ordinal  becomes something else like


we are in trouble here as the action (store measurement value in variable) will not be triggered.

If we look at the current driver for this setup it is set to


<!-- The can4vscp driver -->
<driver enable="false" >

The “problem” is solved by changing the <guid> tag from an all zero value (or not defined) to a valid GUID.  If not defined or all zero the VSCP daemon will assign a GUID as of above. But if a valid GUID is set this value will always be used.

In my case I can use


as I have some assigned GUIDs.  The two LSB’s is still used for the nicknames.

After that change the “problem” is no more and I can filter on the new GUID instead which alway will be the same.



ESP8266 General HowTo's

#ESP8266 #VSCP Development Intro – part 1

Serial port

Connect the USB cable to the board.  You will get a new CDC serial port. You can check which one you get with

ls /dev/tty*

Normally you get /dev/ttyUSB0 or /dev/ttyUSB1 or the like. To make them usable for you you should add yourself to the dialout group

addgroup user dialout

where “user” is your username. You can also do this manually in the /etc/group file or

chmod a+rw /dev/ttyUSB0

if you like brute force.

Loading code to the ESP8266

The ESP8266 CPU can be booted in three different ways:

  • Flash Mode: default booting mode. Firmware is read and executed from the flash memory. Pins need to be set to: GPIO15=0, GPIO0=0, GPIO2=1
  • UART Mode: used to program our board (through a Serial-to-Usb adapter). Pins need to be set to:  GPIO15=0, GPIO0=1, GPIO2=1
  • SDIO Mode: loads firmware from an SDIO card? Pins need to be set to:  GPIO15=1, GPIO0=0/1, GPIO2=0/1

The boot process is described here.

Switching from a mode to another requires to reset the module while the pin states listed is set.

With the nodemcu board and esptool flash uploader all this is handle automatically but if you have another board you must handle this yourself.


You find it here.

Fetch it

sudo git clone

cd esp-open-sdk

Install it

apt-get install make unrar autoconf automake libtool libtool-bin gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python sed

git clone --recursive

cd esp-open-sdk/

Error when building?  See this post
This builds the standalone version of the SDK (Non FreeRTOS)
You should add the bin directory to he path
echo 'PATH=$PATH:~/development/esp8266/esp-open-sdk/xtensa-lx106-elf/bin' >> ~/.profile

echo 'PATH=$PATH:~/development/esp8266/esp-open-sdk/esptool' >> ~/.profile


I have installed the toolchain in


so change paths above for your installation folders.

Update it (when updates are available)

make clean
git pull
git submodule update

Firmware upload tool

You need the to upliad firmware to the module, you find it here
Install with
pip install esptool

First code (blinky)

You find it here

cd ~/development/esp8266/esp-open-sdk/examples/blinky



to build it. Remember that the paths above must have been set. You may get some warnings. No problem.

For your information. If you build from source code should be loaded like this:

  • bin/0x00000.bin to 0x00000
  • bin/0x10000.bin to 0x10000

That is just what we do here. Upload to your module with --port /dev/ttyUSB1 write_flash 0x00000 blinky-0x00000.bin 0x10000 blinky-0x10000.bin

No need to press any buttons during flashing. It is handled automatically by the USB DTR circuitry.

Now we are ready to do some real work for our VSCP system with the ESP8266.  If you rather prefer Arduino this howto may be the one you should go for instead of this one. Life is much simpler in the Arduino world. But the degrees of freedom is better if you do it all by yourself. The penalty for freedom is more problems of course. As always.

Another intro is here
esp8266 wiki is here.

Part 2 will follow.

HowTo's – Getting started with VSCP

Source: – Getting started with VSCP

HowTo's – Updating VSCP firmware

Source: – Updating VSCP firmware

HowTo's – Installing VSCP Daemon on Windows

Source: – Installing VSCP Daemon on Windows

HowTo's – Installing USB2CAN on Linux

Source: – Installing USB2CAN on Linux


Howto: Minimum VSCP wifi Level II node (VSCP PID detector)

In this  howto we will build a simple VSCP level II node that with the help of a PIR motion sensor detects motion and sens this as a VSCP event wireless to a VSCP daemon.

We use the famous ESP8266  for this  and work in the even more famous Arduino environment.  The ESP8266 comes in many flavors but a convenient form factor is the NodeMCU board.  You can buy it on Aliexpress or Ebay at a low-cost (USD 2.2).

There is also a baseboard available for the NodeMCU and I use it as it is convenient when working with a new design. It to is available on Aliexpress and Ebay at a low-cost (USD 1.54).

The last item you need is the PIR sensor, they to are available at low-cost. I bought mine from Ebay (USD 0.99).

If you haven’t set up your Arduino IDE for work with the ESP8266 you need to do that now.  Here is an excellent tutorial on how to do this. Make the blink example work before you move on.

I find the Arduino IDE a bit crude to work with so I use Visual Studio Code instead.  An excellent programming editor that works on all the major operation systems. I tend to use it more and more. But there are other options to such as Atom. Anyway instructions on how to get it working for Arduino development is here.  Make sure to set the “output” tag to a valid location in the .vscode/arduino.json file otherwise upload will be VERY slow.

You also need a VSCP daemon/server running for this example. All info about it is here.

To connect the sensor to the NodeMCU we ned to know about he port mapping for the module which is a bit different from for other Arduino devices. It looks like this

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

D0 has a blue LED connected to it so it is an obvious candidate for status. D1 can be used to connect to the PIR

The PIR device I have outputs a 3V signal even when powered with +5V so it is OK to connect directly to D1. So the three pins on the PIR

1     +5V
2     Output to D1 (High on detect)
3     GND

The LED on D0 light up when a LOW is written to it. This is opposite to the PIR output. We take care of this in software.

We implement a dump VSCP device here. This is a device that does not handle any of the register reads that “normal” VSCP requires and which don’t have a MDF file either. A dumb device has been 14 set in the header.

We send two events. The heartbeat event (CLASS1.INFORMATION, Type=9) every minute. This event is recommended for all nodes as it is used for node discovery and detection. The other event we send is the detect event (CLASS1.INFORMATION, Type=49 detect) when an object is detected.

The test setup looks like this

and you can find the complete code is here

The heartbeat coming into the VSCP daemon (using VSCP works)

and the detect event

With the event in the VSCP daemon it is easy to add a DM row that for instance light up the lamps in a room. You can also use the rest or the websocket interface to do give visual feedback.

We will follow-up this howto with a post where we use the Expressif SDK instead of the Arduino and use a plain ESP8266 board. But also a ost where we implement a full Level II node that have registers and a MDF and show the advantage we get with a node like that over a dumb one.

An alternative wifi lib is documented here.

HowTo's VSCP

#VSCP update process #howto

In previous versions of VSCP whenever you did an install all configuration files were replaced with the latest version. This is not true anymore.  Now the new version is instead written as a copy with the date of the install appended to it.  So if you after a “make install” or a “dpkg -i vscpd” want the latest configs you have to copy the backup to the actual config file and restart the VSCP server.

Files that is handled in this way is


Also if you are on unstable code you should remove the databases before you start the updated server . Use

rm /srv/vscp/*.sqlite3

for this.

Also note that the web sample code is not installed in the install/update process no more. The process to get this subsystem installed with be described later.