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

HiPi::Interface::MS5611

This module provides an I2C interface to the MS5611 pressure and temperature sensor.

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

Currently only the I2C interface is implemented

Methods

Create a new instance of the class

use HiPi qw( :ms5611 );
use HiPi::Interface::MS5611;

my $sen = HiPi::Interface::MS5611->new( address => 0x76 );

Reset the MS5611

$sen->reset()

Read the pressure in millibars and temperature in degrees C from the sensor.

  • $pressure_osr - the oversampling rate used for pressure calculation. Default is MS5611_OSR_4096. Specify this optional value using the constants
    • MS5611_OSR_4096
    • MS5611_OSR_2048
    • MS5611_OSR_1024
    • MS5611_OSR_512
    • MS5611_OSR_250
  • $temp_osr - the oversampling rate used for temperature calculation. Default is MS5611_OSR_4096. Specify this optional value using the constants
    • MS5611_OSR_4096
    • MS5611_OSR_2048
    • MS5611_OSR_1024
    • MS5611_OSR_512
    • MS5611_OSR_256
use HiPi qw( :ms5611 );
use HiPi::Interface::MS5611;
my $sen = HiPi::Interface::MS5611->new( address => 0x76 );

my ( $pressure, $temperature ) = $sen->read_pressure_temp;

# get the answer quicker, using less power, but with lower precision
( $pressure, $temperature ) = $sen->read_pressure_temp( MS5611_OSR_256, MS5611_OSR_256 );


Read the pressure in pascals and temperature in degrees C from the sensor.

  • $pressure_osr - the oversampling rate used for pressure calculation. Default is MS5611_OSR_4096. Specify this optional value using the constants
    • MS5611_OSR_4096
    • MS5611_OSR_2048
    • MS5611_OSR_1024
    • MS5611_OSR_512
    • MS5611_OSR_250
  • $temp_osr - the oversampling rate used for temperature calculation. Default is MS5611_OSR_4096. Specify this optional value using the constants
    • MS5611_OSR_4096
    • MS5611_OSR_2048
    • MS5611_OSR_1024
    • MS5611_OSR_512
    • MS5611_OSR_256
use HiPi qw( :ms5611 );
use HiPi::Interface::MS5611;
my $sen = HiPi::Interface::MS5611->new( address => 0x76 );

my ( $pressure, $temperature ) = $sen->read_pressure_pa_temp;

# get the answer quicker, using less power, but with lower precision
( $pressure, $temperature ) = $sen->read_pressure_pa_temp( MS5611_OSR_256, MS5611_OSR_256 );


If we know the elevation of the sensor in meters , we can find the sea level pressure using the results of the call to read_pressure_temp or read_pressure_pa_temp.

my ( $pressure, $temperature ) = $sen->read_pressure_temp;

my $elevation = 38;'  # meters
my $sealevelpress = $sen->sea_level_pressure( $pressure, $elevation, $temperature )