HiPi
Perl Modules for Raspberry Pi
Version 0.92 - released 28 March 2024

HiPi::Device::OneWire

This module currently provides a front end to the w1-gpio kernel device driver. Currently only a simple read function is implemented. Enough to support reading the output of DS18B20 and DS18S20 temperature devices.

The module HiPi::Interface::DS18X20 is a wrapper for the functions provided by this module.

Class Functions

Returns an array of hash references providing details of the connected 1 wire devices.

the four hash keys are

    id           e.g. 28-00000400bed1
    family       e.g. 28
    name         e.g. 18B20
    description  e.g. programmable resolution digital thermometer
my @devices = HiPi::Device::OneWire->list_devices();
for my $w1 ( @devices ) {
    for ( qw( id family name description ) ) {
    print qq($_ = $w1->{$_}\n); 
    }
}

Returns the content of the file /sys/bus/w1/devices/$id/w1_slave

It is up to the caller to parse the content

my $data = HiPi::Device::OneWire->read_data( $id );

Returns true or false according to whether the specified $id is connected to the kernel device.

my $is_connected = HiPi::Device::OneWire->id_exists( $id );