tmp102

package
v0.0.0-...-11ea3f4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

README

TMP-102 I2C

This provides a simple way to access the sensor value of a TMP-102 that is connected to an i2c bus on your system.

Usage

Import the packages:

// import the require modules
import(
	"github.com/mrmorphic/hwio"
	"github.com/mrmorphic/hwio/devices/tmp102"
)

Initialise by fetching an i2c module from the driver. You can get instances of devices attached to the bus.

// Get the i2c module from the driver. This is an example for the Raspberry Pi.
m, e := hwio.GetModule("i2c")

// Assert that it is an I2C module
i2c := m.(I2CModule)

Get the TMP102 device, so you make requests of it:

// Get a temp device on this i2c bus
temp := tmp102.NewTMP102(i2c)

Read values from the device whenever you want to:

// Get the temperature sensor value
t, e := temp.GetTemp()

Documentation

Index

Constants

View Source
const (
	// This is the default address.
	DEVICE_ADDRESS = 0x48
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TMP102

type TMP102 struct {
	// contains filtered or unexported fields
}

func NewTMP102

func NewTMP102(module hwio.I2CModule) *TMP102

func (*TMP102) GetTemp

func (t *TMP102) GetTemp() (float32, error)

Jump to

Keyboard shortcuts

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