Skip to content
/ bme280 Public

Golang library to read data from Bosch BME280 sensor.

License

Notifications You must be signed in to change notification settings

quhar/bme280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bme280

GoDoc

Golang library to read data from Bosch BME280 sensor. It requires library to talk to the device via following interface:

type bus interface {
	ReadReg(byte, []byte) error
	WriteReg(byte, []byte) error
}

One of the libraries which matches this interface is experimental standard I/O lib.

Example usage

package main

import (
	"fmt"

	"golang.org/x/exp/io/i2c"

	"github.com/quhar/bme280"
)

func main() {

	d, err := i2c.Open(&i2c.Devfs{Dev: "/dev/i2c-1"}, bme280.I2CAddr)
	if err != nil {
		panic(err)
	}

	b := bme280.New(d)
	err = b.Init()

	t, p, h, err := b.EnvData()

	if err != nil {
		panic(err)
	}

	fmt.Printf("Temp: %fC, Press: %fhPa, Hum: %f%%\n", t, p, h)
}

About

Golang library to read data from Bosch BME280 sensor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages