max31855

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 4 Imported by: 0

README

MAX31855 driver for Go

Usage

package main

import (
	"fmt"
	"log"

	"github.com/lukechannings/max31855"

	"periph.io/x/periph/conn/spi/spireg"
	"periph.io/x/periph/host"
)

func main() {
	if _, err := host.Init(); err != nil {
		log.Fatal(err)
	}

	s, err := spireg.Open("")

	if err != nil {
		log.Fatal("Couldn't open SPI port! " + err.Error())
	}

	dev, err := max31855.New(s)

	if err != nil {
		log.Fatal("Couldn't open device! " + err.Error())
	}

	temp, err := dev.GetTemp()

  if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Current temperature: %v °C (%v °F)", temp.Thermocouple.Celsius(), temp.Thermocouple.Fahrenheit())
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOpenCircuit error = errors.New("Thermocouple is not connected")

ErrOpenCircuit - Thermocouple is not connected

View Source
var ErrReadingValue error = errors.New("Error Reading Value")

ErrReadingValue - Error Reading Value

View Source
var ErrShortToGround error = errors.New("Short Circuit to Ground")

ErrShortToGround - Short Circuit to Ground

View Source
var ErrShortToVcc error = errors.New("Short Circuit to Power")

ErrShortToVcc - Short Circuit to Power

Functions

This section is empty.

Types

type Dev

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

Dev - A handle to contain the SPI connection

func New

func New(p spi.Port) (*Dev, error)

New - Connects to the MAX31855

func (*Dev) GetTemp

func (d *Dev) GetTemp() (Temp, error)

GetTemp - Gets the current temperature in Celcius

type Temp

type Temp struct {
	Thermocouple physic.Temperature
	Internal     physic.Temperature
}

Temp - contains the temperature at both ends of the thermcouple

Jump to

Keyboard shortcuts

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