The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hardware::1Wire::HA7Net, Hardware::1Wire::HA7Net::DS1820, Hardware::1Wire::HA7Net::DS18B20, Hardware::1Wire::HA7Net::HMP2001S

SYNOPSIS

    use Hardware::1Wire::HA7Net;
    $unit = new Hardware::1Wire::HA7Net "http://ha7net.local.net";

    for $s ($unit->sensors) {
        if ($s->isa("ds1820")) {
            print scalar $s->temperature, "\n";
            push @addrs, $s->address;
            }
        if ($s->isa("ds18b20")) {
            $s->resolution(10);
            printf "Addr: %s, Temp: %s, Resolution: %s\n", $s->temperature;
            push @addrs, $s->address;
            }
        if ($s->isa("hmp2001s")) {
            print scalar $s->value, "\n";
            push @addrs, $s->address;
            }
        }

    %sensors = $unit->read(@addrs);
    %sensors = $unit->read($unit->sensors);
    %sensors = $unit->read();

    if ($unit->scan(\@added, \@deleted)) {
        for $s (@added) {
            print "Added sensor: ", $s->type, $s->address;
            }
        }

DESCRIPTION

This module provides an interface to the Embedded Data Systems HA7Net 1-Wire bus master.

Methods

The Hardware::1Wire::HA7Net exports the following methods:

new ( URL, [ scan ] )

This method creates a new Hardware::1Wire::HA7Net object. The first (required) parameter to this method is the URL of the sensor (which may be either http or https - if https, the Crytpo::SSLeay module must also be installed).

The second (optional) parameter determines whether the new method scans the HA7Net device at the specified URL to determine the current set of attached devices. Note that the default behavior is to scan the device! If the second parameter is present, a true value indicates to scan the device, while a false value does not scan. Scanning the device will cause the method to take a few seconds to complete.

Note that if you know a priori the addresses of the devices connected to the HA7Net, you do not need to scan it when calling the new method. Simply reading the device (with the read method) using a device address will cause it to be added to the list of known devices.

version

This method returns the version number of the HA7Net firmware. This software expects the firmware to be at least version 1.0.0.9. The package will not abort if this is not the case, but erroneous behavior may result. We strongly recommend that you upgrade your HA7Net to use version 1.0.0.13 (or later).

sensors

This method returns a list of known devices attached to the HA7Net. Note that devices become "known" when the HA7Net is scanned (by either the new or scan methods) or by reading a previously unknown device. Each device returned will be one of the subclassed devices as described below.

read ( [ device-address | device-object | ... ] )

This method accepts a list of devices and reads the sensors in as few chunked reads as possible (that is, it attempts to not call the individual temperature or value methods, if possible). The device may be a device object (of type Hardware::1Wire::HA7Net::some_type), or it may be the 1-Wire address of a device. If no parameters are specified, then all known devices on the HA7Net are read (a device is made to be known by scanning the HA7Net with the new or <scan> methods, or by reading the device value with the read method with a specific device address).

The value returned is a hash table, where the key(s) are the 1-Wire addresses and the values are the values read.

scan ( [ new [ , gone ] ] )

The method (re)scans the HA7Net device to determine the current set of attached devices (this the method may take a few seconds to complete). The method returns true if there have been any changes to the set of attached devices.

You may pass in up to two optional parameters to this method. Each is a reference to an array - the first will be filled with the set of devices that have been added, and the second will be filled wih the set of devices that have been removed.

SUBCLASSES

The Hardware::1Wire::HA7Net object also defines three subclassed objects: Hardware::1Wire::HA7Net::DS1820, Hardware::1Wire::HA7Net::DS18B20, and Hardware::1Wire::HA7Net::HMP2001S.

Common Methods

Each of these object types exports the following methods (there is no new method - the only way to create the subclassed devices is to have the connected to the HA7Net at the time the Hardware::1Wire::HA7Net object is created).:

isa ( type )

This method takes a single string parameter, and returns true if the object is of that type.

ha7net

This method returns the Hardware::1Wire::HA7Net object that this device is associated with. This method is the complement to the sensors method, which lists all devices associated with an HA7Net.

family

This method returns a two-digit Dallas Semiconductor family number associated with a device.

address

This method returns the unique 16-digit hexadecimal address of a device.

units

This method returns the units that the device reads (for example, "Degrees C" or "% Relative Humidity").

type

This method returns an array containing the sensor type. There may be more than one possible type listed - for example, "DS1820" and "DS18S20". This list may be easily searched using the isa method. If called in a scalar context, the method will return the first element of the array (which is the Dallas Semiconductor sensor type).

part_of

If the sensor is a temperature sensor that is part of a larger sensor (for example, the DS1820 temperature sensor in the HMP2001S Humidity/Temperature sensor), this method returns the analog sensor object.

Additionally, the sub-classed objects have methods that are specific to the type of sensor:

Hardware::1Wire::HA7Net::DS1820

temperature

This method returns the current temperature value seen by the sensor. When called in an arrray context, the method returns the device address and the temperature. When called in a scalar context, the method returns only the temperature.

Hardware::1Wire::HA7Net::DS18B20

resolution

If the method is passed a parameter, the number of bits of resolution measured by the sensor will be set to that value (the value may range from 9..12 bits of resolution). This method always returns the number of bits of resolution currently measured by the sensor.

temperature

This method returns the current temperature value seen by the sensor. When called in an arrray context, the method returns the device address, the temperature, and the number of bits of resolution. When called in a scalar context, the method returns only the temperature.

Hardware::1Wire::HA7Net::Analog

value

This method returns the current value seen by the sensor. When called in an array context, this method returns the analog sensor address, the analog value, the temperature sensor address, and the temperature value. When called in a scalar context, this method returns only the analog sensor value.

AUTHOR

Daniel V. Klein <dan@klein.com>

SEE ALSO

http://www.embeddeddatasystems.com/ for full product and sensor details.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 626:

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