Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/monttyle/public_html/sensor8/phpstyle.php on line 59

Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/monttyle/public_html/sensor8/phpstyle.php on line 60

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/monttyle/public_html/sensor8/phpstyle.php on line 62
sensor8 logo
RSS Links Projects Misc News


sensor8 and sensor20 are utilities for communicating with the DLP-IO8 and DLP-IO20 data acquisition modules. They are inexpensive, well-documented, Linux-compatible USB devices for digital and analog I/O. Individually controlled pins can function as any of the above, as well as being able to read 18b20 1-wire temperature sensors. The sensor20 adds two relays, two counters, some function-specific pins, and a more complex and efficient protocol to these options.

These utilities allow you to use them directly from a Linux commandline, shell script, cron job, etc. It was developed to monitor the thermal systems of a solar house, and now is used for greenhouses as well.

UPDATE: 0.0.2 has improved temperature handling, and by default will wait 600 milliseconds for a valid temperature if a DS18B20 sensor is detected. If no sensor is detected it won't wait at all.

UPDATE: 0.0.3 has an important bugfix preventing the program from quitting prematurely when it can't read from a temperature sensor.

UPDATE: 0.0.4 has much better error detection for invalid temperatures, and can take multiple readings from one temperature sensor in a row then choose the median, to better deal with single-bit errors and the like.

UPDATE: Added a similar sensor20 program for the related DLP-IO20 product. It's not as polished as sensor8 yet, but already has function for digital I/O, analog input, temperature sensors, and the built-in relays. It ought to support both big and little-endian systems but this hasn't actually been tested. The interface for the RB6/RB7 counters isn't yet finished.

UPDATE: sensor20-0.0.2 released. It's much more complete, with functioning analog-block commands and counters. --raw, --verbose don't work yet, those should be next.

UPDATE: sensor20-0.0.3 released. i2c support has been added, allowing you to chain sensors and devices and external IC's onto an IO20 module. It should be possible to add this feature to sensor8, as well.


UPDATE: sensor20-0.0.6 has been released. It features:

$ ./sensor8 --help --verbose

sensor8 v1.0.0, utility to talk to a DLP-I08 module
Written 2012 Tyler Montbriand.  Freeware.

Usage:  ./sensor8 ...
	--device(-d)	-d /dev/ttyUSB0
	--mode(-m)	-m 115200N81 (- means leave alone)
	--verbose(-v)	Enables debug output
	--bug	Works around kernel bug
	--help(-h)	Shows this listing
	--raw(-r)	Outputs raw bytes
	--tempms(-m)	Milliseconds between temp read retries
	--retries(-n)	Max # of tries to read a temp from a pin
	--count(-c)	Min # of valid temperature reads per sensor, 1-7
	--lock(-l)	Enables cooperative locking
	--SCL	What pin to use for i2c clock
	--SDA	What pin to use for i2c data
Valid commands:
	[1-8]:I		ex. 7:I, reads logic value on input 7
	[1-8]:V		ex. 7:V, reads analog voltage on input 7
	[1-8]:T		ex. 7:T, reads temperature from DS18B20 on pin 7
	[1-8]:[01]	ex. 1:0, sets logic 0 on pin 1
	[1-8]:Z		ex. 2:Z tristates pin 2
	PING		Pings device, waits for reply

	You can string these commands together, like
		3:10101010Z pulse pin 3 four times, then tristate it.

	D[0-9]+		ex. D100, delays 100 milliseconds
	U[0-9]+		ex. U1000, delays 1000 microseconds

	PING		Contact the device, or quit if it can't.

$ ./sensor20 --verbose --help

SENSOR20 v0.0.6, utility to talk to a DLP-IO20 module
Written 2013 Tyler Montbriand.  Freeware.

Usage:  ./sensor20 ...
        --help(-h)              Shows this listing
        --verbose(-v)           Debug output and better help
        --bug           Workaround FTDI kernel bug
        --device(-d)    VAL     -d /dev/ttyUSB0
        --rate(-r)      VAL     Sample rate 1K ... 20K
                Valid values 1K 2K 4K 8K 20K
        --avg(-a)       VAL     Multi-sample analog average
                Valid values 128 256 512 1024 2048 4096 8192
        --lock(-l)              Enables cooperative locking
        --vref  VAL             Voltage reference for the ADC
        --SDA   VAL             I2C data pin
                Valid values AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 AN8 AN9 
AN10 AN11 AN12 AN13 RA4 P5 P6 P7 RB7 RB6
        --SCL   VAL             I2C clock pin
                Valid values AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 AN8 AN9 
AN10 AN11 AN12 AN13 RA4 P5 P6 P7 RB7 RB6

Use these commands like 'sensor20 AN7:I AN6:0 AN5:V'.  Any commands
which output values will print their results to standard output, one
result to a line.  If the command fails, it will print ERR instead.

PIN can be AN0-AN13, RA4, P5-P7, RB6-RB7.

        PIN:I           Read logic value from given pin, i.e.           AN7:I
        PIN:T           Read temperature from DS1820B, i.e.             AN7:T
        PIN:F           Like :T, but in Fahrenheit, i.e.                AN7:F
        PIN:'?'         Detect serial number of DS18b20, i.e.           AN7:'?'
        PIN:[0-1]       Set logic high or low on any pin, i.e.          AN7:1
        PIN:Z           Set tri-state on any pin i.e.                   AN7:Z
        AN[0-13]:V      ex AN7, reads ADC voltage from AN7, i.e.        AN7:V

        Any of the above can be strung together, like AN13:010101010Z
        ..which will pulse AN13 four times then tristate it.  The maximum
        speed the IO20 can pulse a pin is on the order of 20Khz.

        If you give sensor20 a --vref value, it will tell the IO20 to
        use an external voltage reference attached to AN3.  Otherwise,
        it will assume the 5.0v internal reference.  Give the INTREF
        command to make sure the IO20 really is using the internal
        reference if you used the external one last time.

                Capture many ADC samples at a given rate, i.e   AN7:M4K:128

        R:[1-2]:[0-1]   Set or reset contacts of relay 1 or 2, i.e.     R:2:0
        RB[6-7]:R       Enable and reset pulse counts on RB6/RB7, i.e.  RB6:R
        RB[6-7]:r       Same, but trigger on falling edge               RB6:r
        RB[6-7]:C       Print pulse counts from RB6/RB7, i.e.           RB7:C
        FLASH           Flash the built-in LED briefly, then keep on
        LED:[0-1]       Turns the built-in LED on/off, i.e.       LED:0
        PING            Checks if the IO20 is there, quits with error if not.
        D:[0-9]*        delay some milliseconds, i.e.             D:100
        U:[0-9]*        Delay some microseconds, i.e.             U:10000

        You can't depend on greater than 10 milliseconds accuracy on
        most systems.


        The following commands use bit-banging to communicate with 7-bit I2C
        devices attached to the DLP-IO20.  They expect the SCL and SDA
        environment variables to specify what pins to use.

        devid[reg]      Read I2C register, i.e.                 1d[00]
        devid[reg]:n    Like above but n bytes, i.e.            1d[00]:4
        devid[reg]=xx   Write one or more i2c registers, i.e.   1d[1e]=010203
        devid[]         Registerless I2C read                   7f[]
        devid[]:4       Like above, but n bytes, i.e.           7f[]:2
        devid[]=xx      Registerless i2c write of n bytes, i.e. 7f[]=2000

                Raw I2C sequence.  You can put start/stop/nack wherever
                you feel appropriate.  Wordy but should be capable of anything.
                        R               Read command
                        W               Write command
                        A               7-bit address
                        S               Send start bit
                        P               Send stop bit
                        N               Send NACK
                        xx              Send two hexadecimal digits
                Example:  Read device ID(register 00) from OSEPP
                accelerometer(addr 1D)

        Many commandline values can also be exported as environment
        variables instead.  useful if you're using sensor20 repeatedly.

        SENSOR20        Serial device to open.  Defaults to /dev/ttyUSB0
        SDA             Which pin to use for I2C data.
        SCL             Which pin to use for I2C clock.
        VREF            What the AN3 external vref is assumed to be.
                        causes EXTREF command.


sensor20 FLASH LED:0            # Flash built-in LED then turn it off
sensor20 R:1:0 D:100 R:1:1      # Click relay 1
sensor20 AN7:V AN6:I AN5:'?'    # Read AN7 V, AN6 bit, AN5 DS18B20 serial
sensor20 AN7:01010101Z          # Pulse 0 1 0 1 0 1 0 1 on AN7 then tristate it
sensor20 AN5:S D:1000 AN5:T     # Start DS18B20, wait 1 second, read temp in C
sensor20 AN3:M1K:128            # Dump 128 analog samples from AN3 at 1Khz
sensor20 RB6:R D:1000 RB6:C     # Enable RB6 counter, wait a sec, print count
# Read reg 00 of I2C devid 1d from pins AN5/AN6
sensor20 --SCL AN5 --SDA AN6 1d[00]
# Write 0b to reg 31 of I2C devid 1d via AN5/AN6
sensor20 --SCL AN5 --SDA AN6 1d[31]=0b

Broke your buffer?  Try ./sensor20 -v -h 2>&1 | less













Author Message
Tyler Montbriand on 2013-02-27 15:38:23 sensor20 0.0.6 has been released.
Tyler Montbriand on 2012-10-30 13:56:19 sensor20 0.0.4, sensor8 1.0.0 , and sensor8 0.0.6 released!
Tyler Montbriand on 2012-10-16 08:10:36 sensor20-0.0.2 released!
Tyler Montbriand on 2012-10-14 00:42:48 Version 0.0.1 of sensor20 released!
Tyler Montbriand on 2011-02-07 12:21:28 0.0.5 released, now supports locking(-l) to prevent multiple instances interfering with each other.
Tyler Montbriand on 2010-11-24 07:15:54 0.0.4 released. Can take several temperature readings and give the median. It no longer prints units, just values.
Tyler Montbriand on 2010-11-01 10:34:08 0.0.3 released, including a fix that prevents premature exit on sensor error.
Tyler Montbriand on 2010-10-20 09:50:41 The comments page is now OPEN.
[Use Any Browser]
Linux User #348010