bmp280

package module
v0.0.0-...-e3d9b0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2020 License: MIT Imports: 5 Imported by: 0

README

input:

  • d = "/dev/i2c-1"
  • a = 0x76 (BMP280 on CJMCU8128 breakout board)
  • accuracy = "ULTRA_LOW","LOW","STANDARD","HIGH","ULTRA_HIGH"

output:

  • p = uint32 ( pressure in unit Pa )

Calibration:

Refer to https://cdn-shop.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf

Find your device address

i2cdetect -y 1

Find BMP280 Device ID, should be 0x58 or 0x56 or 0x57

i2cget 1 0x76 0xD0

Sample Code

package main
import(
	"log"
	"github.com/zack-wang/go-bmp280"

)
func main(){
// Atmosphere Pressure
	p,err:=bmp280.ReadPressurePa("/dev/i2c-1",0x76,"LOW")
	if err!=nil{
	  log.Fatal("Not BMP280",err)
	}else{
	  log.Println("p=",p)
	}
}

Documentation

Index

Constants

View Source
const (
	// BMP280 general registers
	BMP280_ID_REG        = 0xD0
	BMP280_STATUS_REG    = 0xF3
	BMP280_CNTR_MEAS_REG = 0xF4
	BMP280_CONFIG        = 0xF5
	BMP280_RESET         = 0xE0
	// BMP280 specific compensation register's block
	BMP280_COEF_START = 0x88
	BMP280_COEF_BYTES = 12 * 2
	// BMP280 specific 3-byte reading out temprature and preassure
	BMP280_PRES_3BYTES = 0xF7
	BMP280_TEMP_3BYTES = 0xFA
)

BMP280 sensors memory map

Variables

This section is empty.

Functions

func ReadCoeff

func ReadCoeff(d string, a int) error

Read compensation coefficients, unique for each sensor.

func ReadPressurePa

func ReadPressurePa(d string, a int, accuracy string) (uint32, error)

Read Pressure Multple by 10 in unit Pa .

func ReadUncompPressure

func ReadUncompPressure(d string, a int, accuracy string) (int32, error)

Read Pressure from ADC.

func ReadUncompTemprature

func ReadUncompTemprature(d string, a int, accuracy string) (int32, error)

Read Temprature from ADC.

func VerifiySensorID

func VerifiySensorID(d string, a int) bool

Verify BMP280

Types

type BMP280COEFF

type BMP280COEFF struct {
	// Calibration data
	Dig_T1 uint16
	Dig_T2 int16
	Dig_T3 int16
	Dig_P1 uint16
	Dig_P2 int16
	Dig_P3 int16
	Dig_P4 int16
	Dig_P5 int16
	Dig_P6 int16
	Dig_P7 int16
	Dig_P8 int16
	Dig_P9 int16
}

Unique BMP280 calibration coefficients

var (
	Cal BMP280COEFF
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL