NAME

Device::Chip::BMP280 - chip driver for BMP280

SYNOPSIS

use Device::Chip::BMP280;
use Future::AsyncAwait;

my $chip = Device::Chip::BMP280->new;
await $chip->mount( Device::Chip::Adapter::...->new );

await $chip->change_config(
   OSRS_P => 4,
   OSRS_T => 4,
   MODE   => "NORMAL",
);

my ( $pressure, $temperature ) = await $chip->read_sensor;

printf "Temperature=%.2fC  ", $temperature;
printf "Pressure=%dPa  ", $pressure;

DESCRIPTION

This Device::Chip subclass provides specific communication to a Bosch BMP280 attached to a computer via an I²C adapter. This module can also communicate with the BME280 chip; though to gain access to the additional humidity sensor on that chip see instead Device::Chip::BME280.

The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them.

MOUNT PARAMETERS

addr

The I²C address of the device. Can be specified in decimal, octal or hex with leading 0 or 0x prefixes.

METHODS

The following methods documented in an await expression return Future instances.

read_id

$id = await $chip->read_id;

Returns the chip ID.

check_id

await $chip->check_id;

Reads the ID register from the chip and checks for a valid ID result. If the chip's ID matches what is expected, nothing is returned. Otherwise an exception is thrown.

If a BME280 chip is encountered by the BMP280 driver, or vice versa, the message indicates this, suggesting you may wish to use the other driver module.

read_config

$config = await $chip->read_config;

Returns a HASH reference containing the chip config, using fields named from the data sheet.

FILTER   => OFF | 2 | 4 | 8 | 16
MODE     => SLEEP | FORCED | NORMAL
OSRS_H   => SKIP | 1 | 2 | 4 | 8 | 16
OSRS_P   => SKIP | 1 | 2 | 4 | 8 | 16
OSRS_T   => SKIP | 1 | 2 | 4 | 8 | 16
SPI3W_EN => 0 | 1
T_SB     => 0.5 | 10 | 20 | 62.5 | 125 | 250 | 500 | 1000

change_config

await $chip->change_config( %changes );

Writes updates to the configuration registers.

Note that these two methods use a cache of configuration bytes to make subsequent modifications more efficient.

read_status

$status = await $chip->read_status;

read_raw

( $adc_P, $adc_T ) = await $chip->read_raw;

Returns two integers containing the raw ADC reading values from the sensor.

This method is mostly for testing or internal purposes only. For converted sensor readings in real-world units you want to use "read_sensor".

read_sensor

( $pressure, $temperature ) = await $chip->read_sensor;

Returns the sensor readings appropriately converted into units of Pascals for pressure and degrees Celcius for temperature.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>