Digitemp to VSCP tcp/ip link script
If you have a Linux machine with one or several 1-Wire sensors connected to digitemp. This script can be used to automatically (preferably with the help of cron) report the temperature readings to a VSCP daemon with a tcp/ip link interface activated.
By default VSCP GUID are setup using the 1-Wire id's for each sensors. This ensures globally unique id's.
The scripts works with both python version 2 and version 3.
Install digitemp with
sudo apt install digitemp
Locate the serial port where the serial adapter is connected to.
Now run the following command in the same folder as you intend to execute the script.
digitemp -s/dev/ttyS2 -i
Change /dev/ttyS2 to the serial port you use.
Typical output
DigiTemp v3.7.2 Copyright 1996-2018 by Brian C. Lane
GNU General Public License v2.0 - http://www.digitemp.com
Found DS2490 device #1 at 001/004
Turning off all DS2409 Couplers
...
Searching the 1-Wire LAN
10A8AF9201080061 : DS1820/DS18S20/DS1920 Temperature Sensor
103D9D920108003C : DS1820/DS18S20/DS1920 Temperature Sensor
ROM #0 : 10A8AF9201080061
ROM #1 : 103D9D920108003C
Wrote .digitemprc
This will discover the 1-wire sensors connected to the adapter and create a file .digitemprc in the same folder
You need to blacklist this adapter to make it work. Create a file /etc/modprobe.d/ds2490-blacklist.conf and put
# ds2490 driver interferes with digitemp_DS2490 operation
blacklist ds2490
into it and restart the machine.
Now run the following command in the same folder as you intend to execute the script.
digitemp_DS2490 -i
Typical output
DigiTemp v3.7.2 Copyright 1996-2018 by Brian C. Lane
GNU General Public License v2.0 - http://www.digitemp.com
Found DS2490 device #1 at 001/004
Turning off all DS2409 Couplers
...
Searching the 1-Wire LAN
10A8AF9201080061 : DS1820/DS18S20/DS1920 Temperature Sensor
103D9D920108003C : DS1820/DS18S20/DS1920 Temperature Sensor
ROM #0 : 10A8AF9201080061
ROM #1 : 103D9D920108003C
Wrote .digitemprc
This will discover the 1-wire sensors connected to the adapter and create a file .digitemprc in the same folder
Open the file .digitemprc with your favorite editor and change the line starting with LOG_FORMAT to
LOG_FORMAT "%R %.2C"
%R is the sensor id and %.2C is the temperature in centigrade Celsius printed with two decimals.
If you run the command
digitemp_DS2490 -a -q
or
digitemp_DS9097 -s/dev/ttyS2 -a -q
or
digitemp_DS9097U -s/dev/ttyS2 -a -q
you will get something like
10A8AF9201080061 15.38
103D9D920108003C 23.38
This is exactly what sendvalue.py want as input so
digitemp_DS2490 -a -q | ./sendvalues.py 192.168.1.7 admin secret
will send the temperatures to the server 192.168.1.7 with credentials user="admin" and password="secret".
To get temperature automatically sent to the server on even intervals cron can be used. Create a file dodigitemp in /etc/crontab.d with the following content
* * * * * root cd /root;digitemp_DS2490 -a -q | ./sendvalues.py 192.168.1.7 admin secret
This will send temperatures to the VSCP daemon every minute. Change cron interval to suite your case.
Note: To secure your credentials you can enter them in the sendvalue.py script instead. With the above username and password will be exposed on a multiuser machine.