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

HiPi::Interface::MPL3115A2

This module provides an interface to the Freescale MPL3115A2 pressure and temperature sensor.

It uses HiPi::Device::I2C as a backend.

Currently only one shot methods and some utilities are wrapped. It is recommeded that you implement your own module inheriting from HiPi::Interface::MPL3115A2 to suit your own requirement.

Example

Methods

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Method Description

# Method Example

Example

use HiPi qw( :mpl3115a2 );
use HiPi::Interface::MPL3115A2;

my $mpl = HiPi::Interface::MPL3115A2->new( address => 0x60 );
    
my $mplid = $mpl->who_am_i;
print qq(Device ID     $mplid\n);
unless( $mplid == MPL3115A2_ID ) {
    die qq(bad device id);
}

my ( $alt, $pre, $tem ) = $mpl->os_all_data() ;
print qq(Temperature   $tem\n);
print qq(Raw Pressure  $pre\n);
print qq(Raw Altitude  $alt\n);

# Google tells me my elevation
my $elevation = 38.0;
my $msl = $mpl->sea_level_pressure($pre, $elevation, $tem );
print qq(SL Pressure   $msl\n\n);