max31855

package module
v1.0.1-0...-5b55b8c Latest Latest
Warning

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

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

README

MAX31855 driver for Go

Usage

package main

import (
	"fmt"
	"log"

	"github.com/blasphemy/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("Thermocouple Temp: %f ℃ Internal Temp: %f ℃", temp.Thermocouple, temp.Internal)
}

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() (Temps, error)

GetTemp - Gets the current temperature in Celcius

type Temps

type Temps struct {
	Thermocouple float64
	Internal     float64
}

Jump to

Keyboard shortcuts

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