Skip to content

How to send Digitemp readings to the VSCP daemon

Åke Hedman edited this page Aug 19, 2021 · 6 revisions

How to send Digitemp 1-wire readings to the VSCP daemon

Digitemp by Brian C. Lane has been a popular tool to read 1-wire temperature sensors like the DS18B20 for many years now and it is still around. Digitemp does not use the 1-wire support available in the Linux Kernel but instead use USB och serial adapters.

The software is available mainly for Linux but also an unsupported Windows version is available. We describe the Debian distribution Linux version in this document.

To make use of the software you must must have a 1-wire adapter. The ds9097u is the only option today if you want to buy a ready made adapter. There has been a USB adapter, DS2490, also but I am not sure if it still is on the market. I personally use this adapter. Search the Internet for information on how to build your own. There is some info here

Install digitemp with

sudo apt install digitemp

Digitemp actually is three executables

  • digitemp_DS2490 - Interfaces DS2490 USB adapter.
  • digitemp_DS9097 - Interfaces passive serial port adapter.
  • digitemp_DS9097U - Interface DS2480B based DS9097U adapter.

The man page for them all is here.

Initialize

The first thing you have to do is to find the sensors on the 1-wire bus. You do this with

digitemp_DS9097 -i -s /dev/ttyS0

Replace /dev/ttyS0 with your own serial device of course. This command will create a configuration file .digitemprc that will look something like this

TTY USB
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 2
ROM 0 0x10 0xA8 0xAF 0x92 0x01 0x08 0x00 0x61 
ROM 1 0x10 0x3D 0x9D 0x92 0x01 0x08 0x00 0x3C

For this howto to work you need to change the LOG_FORMAT line to

LOG_FORMAT "%R %.2C"

Last in the file you see the eight byte 1-wire sensor addresses (ROM x). VSCP has the ability to create a VSCP GUID from this address (described here). In the digitemp configuration file the addresses are stored least significant byte first and VSCP store everything most significant byte first, so the the above address should be reversed to be fitted in a VSCP 1-wire GUID, but no other changes are needed in the configuration file for this. It is handle by the script and no change to the Digitemp configuration needs to be done for this. But a good thing to remember.

The sendvalues script

We use a Python script called sendvalues (sendvalues.py here) to send the temperature values to the VSCP daemon (server). The script needs the hostname for the server where the VSCP daemon is installed, and username and password for a user that have access to the tcp/ip interface.

note If your VSCP Daemon has a version greater or equal to 15.0.0 you need to install the tcp/ip server driver (vscpl2drv-tcpipsrv)to get a tcp/ip interface. This was built into the server in earlier versions.

The sendvalues script expect digitemp data on standard input and we want to use cron to send temperature readings on regular intervals so construct a cron-file with the following content

* * * * * root cd /root;digitemp_DS2490 -a -q | ./sendvalues.py 192.168.1.7 admin secret

Replace the digitemp executable with the one you use and change /root to the folder where you have your sendvalues script.

And then we copy the file to /etc/cron.d. This is all we need to do. Temperature readings for the connected 1-wire sensors will now be sent every minute to the VSCP daemon for further processing.

Fahrenheit reporting

If you want temperature readings reported in Fahrenheit instead of Celsius you should replace the

LOG_FORMAT "%R %.2C"

with

LOG_FORMAT "%R %.2F"

and also change line 85 of the sendvalues script to

to

 datacoding = 0x40 | (2<<3) | 0 

This could me made a configurable option in the script as well of course. This is left to the reader as an exercise (I always wanted to write that! : ).

Clone this wiki locally