Wire1 (1-wire) Level II driver

Available for: Linux (Kernel v2.6.29+)

1-Wire sensors especially the DS18B20 temperature sensor is extremely popular in the hobby community for it's ease of use. Also the possibility to have many sensors connected on one 1-wire bus is a big plus for this sensor.

The wire1 driver is built to take advantage of the 1-wire support that is available in the Linux kernel from version 2.6.29.

This driver reports temperature from any number of DS18B20 temperature sensors connected to a Linux system. The reported event is CLASS1.MEASUREMENT, Type=6 temperature.

Driver Linux: vscpl2_wire1.so

The configuration string has the following format


The parameter NumberOfSensors (which is optional) is the number of sensors the driver should report data from. This value can also be available as a VSCP daemon variable and if both are present the VSCP daemon variable will be used. Default is 1.

Variable name Type Description
_numberofsensors integer NumberOfSensors is the number of sensors the driver should report data from.
_path[0..n] string Path to the lm-sensor data file.
_guid[0..n] guid GUID to use when the data for the sensor is reported. If no GUID is used the reserved GUID for 1-wire with the unique id for the sensor will be used.
_interval[0..n] integer Sample interval in seconds for events. Default is 30 seconds.
_unit[0..n] integer Unit use. Allowed values 0=Kelvin,1=Celsius or 2=Fahrenheit. Default is 2 (Celsius).
_index[0..n] integer Measurement index 0-7. Default is 0.
_coding[0..n] integer Message coding 0-2. Default is 0. Allowed values 0=Normalized integer, 1=string, 2=floating point.

The full variable name is built from the name you give the driver (prefix before _variablename) in vscpd.conf. So in the examples below the driver have the name wire1 and the full variable name for the _numberofsensors will thus be


If you have another diver and name it wire2 it will therefore instead request variable wire2_numberofsensors

If your driver name contains spaces, for example “name of driver” it will get a prefix that is “name_of_driver”. Leading and trailing spaces will be removed.

Example of vscpd.conf entry for the wire1 driver.
<driver enable="true" >

Example for variable configuration. In this sample the temperature from two DS18B20 temperature sensors is reported every ten seconds.

<!-- ******************************************************** -->
<!--            VSCP wire1 Level II driver variables     -->
<!-- ******************************************************** -->
<!-- Number of sensors to read -->
<variable type="int" >

<!-- ******************************************************** -->
<!--           Variables for temperature sensor 1        -->
<!-- ******************************************************** -->

<!-- Interval for temperature reports -->
<variable type="int" >

<!-- VSCP GUID -->
<!-- We use the automatically generated GUID 
     (1-wire guid + sensor id)  -->

<!-- Path to sensor data file for sensor 1 -->
<variable type="string" >

<!-- ******************************************************** -->
<!--           Variables for temperature sensor 2        -->
<!-- ******************************************************** -->

<!-- Interval for temperature sensor 2 -->
<variable type="int" >

<!-- VSCP GUID -->
<!-- We use the automatically generated GUID 
     (1-wire GUID + sensor id)  -->     

<!-- Path to sensor data file for sensor 2 -->
<variable type="string" >    

Using the Level II wire1 driver

The 1-wiew support is yet quite limited on Linux systems and at the moment only memory and temperature devices are really supported. The wire1 driver currently just support temperature readings.

Loading the kernel driver


For the 1-wire subsystem to support you need to first add a master driver for the 1-wire bus. Popular is the now discontinued DS2490 USB adapter. To get a working system reading temperatures if you have this device you need to load the needed modules

modprob ds2490
modprob w1-term

If you have some other interface than DS2490 search for which driver to use.

If you have a Raspberry Pi you can instead use GPIO4 (pin 7) which have support for 1-Wire. You have to add a 4k7 pull up resistor to 3.3V yourself.

On the latest kernel builds on Raspberry Pi you need to add "dtoverlay=w1-gpio" to /boot/config.txt for any of this to work!

To get it all working

modprob w1-gpio
modprob w1_therm

After this is done temperature sensor will be visible in the folder /sys/bus/w1/devices

The id will start with the 1-wire family code which is 10 for 18S20 and 28 for 18B20.)

For exampel


Will show have a file content of where t=4937 is the temperature * 1000

0a 00 4b 46 ff ff 0d 10 79 : crc=79 YES
0a 00 4b 46 ff ff 0d 10 79 t=4937 

This is the file that is read by the wire1 driver and sent to the VSCP subsystem.

You way want to add the modules to /etc/modules so that they load automatically the next time you start your system.

Hooking up a Ds18B20 to Raspberry Pi

On this picture a standard DS18B20 and a water proof sensor with a DS18B20 is connected to the Raspberry Pi. The connection is very easy.

  • Fetch power from pin 1 - 3.3V

  • Fetch ground from pin 6.

  • The reserved 1-Wire pin is GPIO4 which is on pin 4.

A good pin out diagram can be found here

Click to see in full size.

A wiring diagram is here

Note the 4k7 pullup that should be connected from 3.3V to the data line of the sensor.

To be complete we include the DS18B20 pin out also

Very Simple Control Protocol
Thu Jan 17 2019 17:41:36 GMT+0000 (UTC)
This document is licensed under Creative Commons BY 4.0 and can be freely copied, redistributed, remixed, transformed, built upon as long as you give credits to the author.

results matching ""

    No results matching ""