The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


OWNet Light weight access to owserver


OWNet is an easy way to access owserver and thence the 1-wire bus.

Dallas Semiconductor's 1-wire system uses simple wiring and unique addresses for it's interesting devices. The One Wire File System is a suite of programs that hides 1-wire details behind a file system metaphor. owserver connects to the 1-wire bus and provides network access.

OWNet is a perl module that connects to owserver and allows reading, writing and listing the 1-wire bus.

Then the following perl program prints the temperature:

 use OWNet ;
 print OWNET::read( "localhost:3000" , "/10.67C6697351FF/temperature" ) ."\n" ; 

There is the alternative object oriented form:

 use OWNet ;
 my $owserver = OWNET->new( "localhost:4304" ) ;
 print $owserver->read( "/10.67C6697351FF/temperature" ) ."\n" ; 



 my $owserver = OWNet -> new( address ) ;
 read( address, path )
 $owserver -> read( path )
 write( address, path, value )
 $owserver -> write( path, value )
 dir( address, path )
 $owserver -> dir( path )
 present( address, path )
 $owserver -> present( path )


TCP/IP address of owserver. Valid forms:

quad number: 123.231.312.213:3001
host localhost:3001
port 3001

Temperature scale can also be specified in the address. Same syntax as the other OWFS programs:

-C Celsius (Centigrade)
-F Fahrenheit
-K Kelvin
-R Rankine

Device display format (1-wire unique address) can also be specified in the address, with the general form of -ff[.]i[[.]c] (family id crc):

-ff.i /10.67C6697351FF (default)
-ffi /1067C6697351FF
-ff.i.c /10.67C6697351FF.8D
-ff.ic /10.67C6697351FF8D
-ffi.c /1067C6697351FF.8D
-ffic /1067C6697351FF8D

Warning messages will only be display if verbose flag is specified in address

-v verbose


owfs-type path to an item on the 1-wire bus. Valid forms:

main directories

Used for the dir method. E.g. "/" "/uncached" "/1F.321432320000/main"

device directory

Used for the dir and present method. E.g. "/10.4300AC220000" "/statistics"

device properties

Used to read, write. E.g. "/10.4300AC220000/temperature"


New value for a device property. Used by write.



new( address )

Create a new OWNet object -- corresponds to an owserver.

Error (and undef return value) if:

1 Badly formed tcp/ip address
2 No <B>owserver at address
Non object-oriented:

read( address , path )


$ownet->read( path )

Read the value of a 1-wire device property. Returns the (scalar string) value of the property.

Error (and undef return value) if:

1 (Non object) No owserver at address
2 (Object form) Not called with a valid OWNet object
3 Bad path
4 path not a readable device property
Non object-oriented:

write( address , path , value )


$ownet->write( path , value )

Set the value of a 1-wire device property. Returns "1" on success.

Error (and undef return value) if:

1 (Non object) No owserver at address
2 (Object form) Not called with a valid OWNet object
3 Bad path
4 path not a writable device property
5 value incorrect size or format
Non object-oriented:

present( address , path )


$ownet->present( path )

Test if a 1-wire device exists.

Error (and undef return value) if:

1 (Non object) No owserver at address
2 (Object form) Not called with a valid OWNet object
3 Bad path
4 path not a device
Non object-oriented:

dir( address , path )


$ownet->dir( path )

Return a comma-separated list of the entries in path. Entries are equivalent to "fully qualified names" -- full path names.

Error (and undef return value) if:

1 (Non object) No owserver at address
2 (Object form) Not called with a valid OWNet object
3 Bad path
4 path not a directory



OWFS is a suite of programs that allows easy access to Dallas Semiconductor's 1-wire bus and devices. OWFS provides a consistent naming scheme, safe multplexing of 1-wire traffice, multiple methods of access and display, and network access. The basic OWFS metaphor is a file-system, with the bus beinng the root directory, each device a subdirectory, and the the device properties (e.g. voltage, temperature, memory) a file.


1-wire is a protocol allowing simple connection of inexpensive devices. Each device has a unique ID number (used in it's OWFS address) and is individually addressable. The bus itself is extremely simple -- a data line and a ground. The data line also provides power. 1-wire devices come in a variety of packages -- chips, commercial boxes, and iButtons (stainless steel cans). 1-wire devices have a variety of capabilities, from simple ID to complex voltage, temperature, current measurements, memory, and switch control.


Connection to the 1-wire bus is either done by bit-banging a digital pin on the processor, or by using a bus master -- USB, serial, i2c, parallel. The heavy-weight OWFS programs: owserver owfs owhttpd owftpd and the heavy-weight perl module OW all link in the full OWFS library and can connect directly to the bus master(s) and/or to owserver.

OWNet is a light-weight module. It connects only to an owserver, does not link in the OWFS library, and should be more portable..


OWNet can be used in either a classical (non-object-oriented) manner, or with objects. The object stored the ip address of the owserver and a network socket to communicate. OWNet will use persistent tcp connections for the object form -- potentially a performance boost over a slow network.



owserver is a separate process that must be accessible on the network. It allows multiple clients, and can connect to many physical 1-wire adapters and 1-wire devices. It's address must be discoverable -- either set on the command line, or at it's default location, or by using Bonjour (zeroconf) service discovery.

An example owserver invocation for a serial adapter and explicitly the default port:

 owserver -d /dev/ttyS0 -p 4304


 use OWNet ;
 # Create owserver object
 my $owserver = OWNet->new('localhost:4304 -v -F') ; #default location, verbose errors, Fahrenheit degrees
 # my $owserver = OWNet->new() ; #simpler, again default location, no error messages, default Celsius

 #print directory
 print $owserver->dir('/') ;

 #print temperature from known device (DS18S20,  ID: 10.13224366A280)
 print "Temperature: ".$owserver->read('/uncached/10.13224366A280/temperature') ;

 # Now for some fun -- a tree of everything:
 sub Tree($$) {
   my $ow = shift ;
   my $path = shift ;

   print "$path\t" ;
   # first try to read
   my $value = $ow->read($path) ;
   if ( defined($value) ) { 
     print "$value\n"; 
     return ;

   # not readable, try as directory
   my $dirstring = $ow->dir($path) ;
   if ( defined($dirstring) ) { 
     print "<directory>\n" ; 
     my @dir = split /,/ ,  $ow->dir($path) ;
     foreach (@dir) {
        Tree($ow,$_) ;
     return ;
   # can't read, not directory
   print "<write-only>\n" ;
   return ;

 Tree( $owserver, '/' ) ;


Object properties (All private)


literal sting for the IP address, in ip:port format. This property is also used to indicate a substantiated object.


Flag sent to server, and returned, that encodes temperature scale and display format. Persistence is also encoded in this word in the actual tcp message, but kept separately in the object.


Print error messages? Set by "-v" in object invocation.


Socket address (object) for communication. Stays defined for persistent connections, else deleted between calls.

Private methods


Takes either the implicit object reference (if called on an object) or the ip address in non-object format. In either case a socket is created, the persistence bit is property set, and the address parsed. Returns the object reference, or undef on error. Called by each external method (read,write,dir) on the first parameter.


Takes command line invocation parameters (for an object or not) and properly parses and sets up the properties in a hash array.


Socket processing, including tests for persistence, and opening.


Sends formats and sends a message to owserver. If a persistent socket fails, retries after new socket created.


Reads a specified length from server


Reads whole packet from server, using _FromServerLow (first for header, then payload/tokens). Discards ping packets silently.


Uses the IANA allocated well known port (4304) for owserver. First looks in /etc/services, then just tries 4304.


Uses the mDNS service discovery protocol to find an available owserver. Employs NET::Rendezvous (an earlier name or Apple's Bonjour) This module is loaded only if available using the method of

Bounjour details for owserver at:


Paul H Alfille paul.alfille @ gmail . com


Support for proper timeout using the "select" function seems broken in perl. This might leave the routines vulnerable to network timing errors.


Documentation for the full owfs program suite, including man pages for each of the supported 1-wire devices, nand more extensive explanatation of owfs components.

Location where source code is hosted.


Copyright (c) 2007 Paul H Alfille. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 681:

'=item' outside of any '=over'

Around line 697:

You forgot a '=back' before '=head2'

Around line 699:

'=item' outside of any '=over'

Around line 735:

You forgot a '=back' before '=head1'