NSLU2-Linux
view · edit · print · history

HowTo.AddUSBOneWireAdapter History

Hide minor edits - Show changes to markup

January 10, 2009, at 12:01 AM by Neil Ronketti --
Changed lines 119-121 from:

[@# cat /opt/etc/init.d/S90digitemp

  1. !/bin/sh
to:

[@#!/bin/sh

January 10, 2009, at 12:00 AM by Neil Ronketti --
Changed line 119 from:

[# cat /opt/etc/init.d/S90digitemp

to:

[@# cat /opt/etc/init.d/S90digitemp

Changed lines 127-128 from:

/opt/bin/digitemp_DS2490 -q -a -d 300 -n 0 -r 1000 -c /root/.digitemprc -l /var/log/temperature &]

to:

/opt/bin/digitemp_DS2490 -q -a -d 300 -n 0 -r 1000 -c /root/.digitemprc -l /var/log/temperature &@]

January 09, 2009, at 11:56 PM by Neil Ronketti -- Starting digitemp from init.d
Added lines 117-130:

To start digitemp automatically when the NSLU2 is booted, a simple script can be added to the init.d directory, as follows:

[# cat /opt/etc/init.d/S90digitemp

  1. !/bin/sh

if [ -n "`pidof digitemp_DS2490`" ] ; then

    killall digitemp_DS2490 2>/dev/null

fi

sleep 2 /opt/bin/digitemp_DS2490 -q -a -d 300 -n 0 -r 1000 -c /root/.digitemprc -l /var/log/temperature &]

The parameters passed to the command will need to be modified to suit your requirements.

July 01, 2008, at 08:23 AM by Lee Kimber -- Minor addition
Added lines 121-123:

You can also read DigiTemp? author Brian Lane's usage notes at http://www.debian-doc.org/packages/d/digitemp/README.html, noting as you do that the comments there about supplying a '-s /dev/ttyS0' port do not apply in our scenario.

June 30, 2008, at 10:55 AM by Lee Kimber -- Small additional comment
Changed lines 3-4 from:

This is how to configure a NSLU2 running slugos/be 4.8 beta to act as a temperature monitor using DigiTemp and a http://www.homechip.com/catalog/product_info.php?cPath=22&products_id=30 DS9490R? USB-to-1-wire adapter.

to:

This is how to configure a NSLU2 running slugos/be 4.8 beta to act as a temperature monitor using DigiTemp and a http://www.homechip.com/catalog/product_info.php?cPath=22&products_id=30 DS9490R? USB-to-1-wire adapter.

Added lines 7-8:

Feel free to contact me at lee atnospam kimberconsulting.com with comments and ideas for improvement. One thing I am seeing is that the system is sometimes unable to print a response from the second sensor of my two-sensor 1-wire LAN, as can bee seen from the output reproduced below.

June 29, 2008, at 03:46 PM by Lee Kimber -- Fixed typo
Changed lines 3-4 from:

This is how to configure a NSLU2 running slugos/be 4.10 beta to act as a temperature monitor using DigiTemp and a http://www.homechip.com/catalog/product_info.php?cPath=22&products_id=30 DS9490R? USB-to-1-wire adapter.

to:

This is how to configure a NSLU2 running slugos/be 4.8 beta to act as a temperature monitor using DigiTemp and a http://www.homechip.com/catalog/product_info.php?cPath=22&products_id=30 DS9490R? USB-to-1-wire adapter.

June 29, 2008, at 02:39 PM by Lee Kimber -- formatting improvement
Changed lines 23-32 from:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -w
DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Found DS2490? device #1 at 3/2
Turning off all DS2409? Couplers
...
Devices on the Main LAN
1092495500080011 : DS1820?/DS18S20?/DS1920? Temperature Sensor
10E71C5500080025 : DS1820?/DS18S20?/DS1920? Temperature Sensor
818B302A00000057 : Unknown Family Code\\

to:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -w DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490? device #1 at 3/2 Turning off all DS2409? Couplers ... Devices on the Main LAN 1092495500080011 : DS1820?/DS18S20?/DS1920? Temperature Sensor 10E71C5500080025 : DS1820?/DS18S20?/DS1920? Temperature Sensor 818B302A00000057 : Unknown Family Code

Changed lines 43-48 from:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -i
Found DS2490? device #1 at 3/2
1092495500080011 : DS1820?/DS18S20?/DS1920? Temperature Sensor
10E71C5500080025 : DS1820?/DS18S20?/DS1920? Temperature Sensor
ROM #0 : 1092495500080011
ROM #1 : 10E71C5500080025\\

to:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -i Found DS2490? device #1 at 3/2 1092495500080011 : DS1820?/DS18S20?/DS1920? Temperature Sensor 10E71C5500080025 : DS1820?/DS18S20?/DS1920? Temperature Sensor ROM #0 : 1092495500080011 ROM #1 : 10E71C5500080025

Changed lines 53-61 from:

[@root@deflation:~$ cat /root/.digitemprc
TTY USB
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "d M:s C: %.2C F: %.2F"
CNT_FORMAT "
d M:s #C"
HUM_FORMAT "
d M:s C: %.2C F: %.2F H: %"
SENSORS 2
ROM 0 0x10 0x92 0x49 0x55 0x00 0x08 0x00 0x11\\

to:

[@root@deflation:~$ cat /root/.digitemprc TTY USB READ_TIME 1000 LOG_TYPE 1 LOG_FORMAT "d M:s C: %.2C F: %.2F" CNT_FORMAT "d M:s #C" HUM_FORMAT "d M:s C: %.2C F: %.2F H: %" SENSORS 2 ROM 0 0x10 0x92 0x49 0x55 0x00 0x08 0x00 0x11

Changed lines 72-78 from:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0
DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Found DS2490? device #1 at 3/2
Jun 29 13:16:26 Sensor 0 C: 25.75 F: 78.35
Jun 29 13:16:28 Sensor 1 C: 20.88 F: 69.57
Jun 29 13:16:56 Sensor 0 C: 25.75 F: 78.35\\

to:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0 DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490? device #1 at 3/2 Jun 29 13:16:26 Sensor 0 C: 25.75 F: 78.35 Jun 29 13:16:28 Sensor 1 C: 20.88 F: 69.57 Jun 29 13:16:56 Sensor 0 C: 25.75 F: 78.35

Changed lines 90-96 from:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0
DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Found DS2490? device #1 at 3/2
Jun 29 13:18:37 Sensor 0 C: 25.75
Jun 29 13:18:38 Sensor 1 C: 20.88
Jun 29 13:19:37 Sensor 0 C: 25.75\\

to:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0 DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com Found DS2490? device #1 at 3/2 Jun 29 13:18:37 Sensor 0 C: 25.75 Jun 29 13:18:38 Sensor 1 C: 20.88 Jun 29 13:19:37 Sensor 0 C: 25.75

Changed lines 101-104 from:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0 -l /var/log/temperature

DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com\\

to:

[@root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0 -l /var/log/temperature DigiTemp? v3.4.0 Copyright 1996-2005 by Brian C. Lane GNU Public License v2.0 - http://www.digitemp.com

Changed lines 108-112 from:

[@root@deflation:~$ tail -f /var/log/temperature
Jun 29 13:22:50 Sensor 0 C: 25.75
Jun 29 13:23:20 Sensor 0 C: 25.75
Jun 29 13:23:22 Sensor 1 C: 20.88
Jun 29 13:23:50 Sensor 0 C: 25.69\\

to:

[@root@deflation:~$ tail -f /var/log/temperature Jun 29 13:22:50 Sensor 0 C: 25.75 Jun 29 13:23:20 Sensor 0 C: 25.75 Jun 29 13:23:22 Sensor 1 C: 20.88 Jun 29 13:23:50 Sensor 0 C: 25.69

June 29, 2008, at 02:21 PM by Lee Kimber -- How to add a USB-to-1-Wire Adapter
Added lines 1-120:

Add USB-to-1-Wire Adapter

This is how to configure a NSLU2 running slugos/be 4.10 beta to act as a temperature monitor using DigiTemp and a http://www.homechip.com/catalog/product_info.php?cPath=22&products_id=30 DS9490R? USB-to-1-wire adapter.

The same steps probably apply to an Unslung NSLU2 but I haven't tried that. They probably also apply to other USB-to-1-Wire adapters.

Some points to note:

  • I wasted a lot of time trying to configure to NSUL2? to present a /dev/ttyUSB0 device for drivers to use to comunicate to the DS9490R? USB-to-1-wire adapter. I cracked this problem when I stopped loading usbserial, stopped trying to figure out what vendor and productID arguments to feed usbserial when I loaded it it; stopped loading a device driver (pl2303 or ftdi_sio) and stopped chmodding the resulting /dev/ttyUSB0. I blame Google for misdirecting me down those paths and merely nod towards the role played by my own incompetence.
  • It also helped me to run the /opt/bin/digitemp_DS2490 binary installed by 'ipkg-opt digitemp', rather than the /opt/bin/digitemp_DS9097 and /opt/bin/digitemp_DS9097U binaries also installed by that package.

Wire up the sensors to the DS9490R? USB-to-1-wire adapter and plug the adapter into the NSLU2.

Turn it on. You can hot plug the USB-to-1-wire adapter if you want. While I was in the fruitless 'hunt for the USB port and load the correct drivers' loop described above, I did hot plug the DS9490R? USB-to-1-wire adapter so that I could identify what the NSLU2 saw it as by listing /dev/ and catting /dev/bus/usb/devices.

With the DS9490R? USB-to-1-wire adapter installed, on first run of digitemp, 'walk' it up the sensor network to see what sensors it can find. To do that, run it with the following '-w' argument:

/opt/bin/digitemp_DS2490 -w

You should see an output something like this:

root@deflation:~$ /opt/bin/digitemp_DS2490 -w\\
DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane\\
GNU Public License v2.0 - http://www.digitemp.com\\
Found DS2490 device #1 at 3/2\\
Turning off all DS2409 Couplers\\
...\\
Devices on the Main LAN\\
1092495500080011 : DS1820/DS18S20/DS1920 Temperature Sensor\\
10E71C5500080025 : DS1820/DS18S20/DS1920 Temperature Sensor\\
818B302A00000057 : Unknown Family Code\\

Looks like it found my two temperature sensors!

Now write a /root/.digitemprc file by running digitemp like this:

/opt/bin/digitemp_DS2490 -a -q -i

You should see an output that looks something like this:

root@deflation:~$ /opt/bin/digitemp_DS2490 -a -i\\
Found DS2490 device #1 at 3/2\\
1092495500080011 : DS1820/DS18S20/DS1920 Temperature Sensor\\
10E71C5500080025 : DS1820/DS18S20/DS1920 Temperature Sensor\\
ROM #0 : 1092495500080011\\
ROM #1 : 10E71C5500080025\\

You should also now find that there is a file called .digitemprc in your current directory. It's contents will look something like this:

root@deflation:~$ cat /root/.digitemprc\\
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 0x92 0x49 0x55 0x00 0x08 0x00 0x11\\
ROM 1 0x10 0xE7 0x1C 0x55 0x00 0x08 0x00 0x25

It's not hard to see in the above that digitemp has stored the ROM numbers of the devices that it found, as well as a default output format for the displaying the values that it finds.

We can now run digitemp in continuous mode by issuing commands like:

root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0

and should see an output something like this:

root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0\\
DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane\\
GNU Public License v2.0 - http://www.digitemp.com\\
Found DS2490 device #1 at 3/2\\
Jun 29 13:16:26 Sensor 0 C: 25.75 F: 78.35\\
Jun 29 13:16:28 Sensor 1 C: 20.88 F: 69.57\\
Jun 29 13:16:56 Sensor 0 C: 25.75 F: 78.35\\
Jun 29 13:16:57 Sensor 1 C: 20.88 F: 69.57

with the lines incrementing every 30 seconds.

The temperature format is being set by that .digitemprc file. We can change the .digitemprc file to give us more control over the output. For example, changing the line: LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F" to LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C"

gives us a Centigrade-only output thusly:

root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0\\
DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane\\
GNU Public License v2.0 - http://www.digitemp.com\\
Found DS2490 device #1 at 3/2\\
Jun 29 13:18:37 Sensor 0 C: 25.75\\
Jun 29 13:18:38 Sensor 1 C: 20.88\\
Jun 29 13:19:37 Sensor 0 C: 25.75\\
Jun 29 13:19:38 Sensor 1 C: 20.88

We can log the output to a file (and tail the file, which is helpful if we make intermittent connections to the NSLU2) by starting digitemp like this:

root@deflation:~$ /opt/bin/digitemp_DS2490 -a -d 30 -n 0 -l /var/log/temperature\\
\\
DigiTemp v3.4.0 Copyright 1996-2005 by Brian C. Lane\\
GNU Public License v2.0 - http://www.digitemp.com\\
Found DS2490 device #1 at 3/2

And tail the file like this:

root@deflation:~$ tail -f /var/log/temperature\\
Jun 29 13:22:50 Sensor 0 C: 25.75\\
Jun 29 13:23:20 Sensor 0 C: 25.75\\
Jun 29 13:23:22 Sensor 1 C: 20.88\\
Jun 29 13:23:50 Sensor 0 C: 25.69\\
Jun 29 13:23:51 Sensor 1 C: 20.88

There's more you can do to modify the output of digitemp, and you can see the full range of modifier arguments by just typing:

/opt/bin/digitemp_DS2490

Note: I found that setting argument -d to 10 or less occasionally prompted messages saying the software needed up to second seconds to read the sensors.

view · edit · print · history · Last edited by Neil Ronketti.
Based on work by Neil Ronketti and Lee Kimber.
Originally by Lee Kimber.
Page last modified on January 10, 2009, at 12:01 AM