thermistor

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package thermistor is for temperature sensing using a thermistor such as the NTC 3950.

Datasheet: https://www.farnell.com/datasheets/33552.pdf

This code is an interpretation of Adafruit Thermistor module in Python: https://github.com/adafruit/Adafruit_CircuitPython_Thermistor

It uses the Steinhart–Hart equation to calculate the temperature based on the resistance: https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation

To use with other thermistors adjust the BCoefficient and NominalTemperature values to match the specific thermistor you wish to use.

sensor.NominalTemperature = 25
sensor.BCoefficient = 3950

Set the SeriesResistor and NominalResistance based on the microcontroller voltage and circuit that you have in use. Set HighSide based on if the thermistor is connected from the ADC pin to the powered side (true) or to ground (false).

sensor.SeriesResistor = 10000
sensor.NominalResistance = 10000
sensor.HighSide = true

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	SeriesResistor     uint32
	NominalResistance  uint32
	NominalTemperature uint32
	BCoefficient       uint32
	HighSide           bool
	// contains filtered or unexported fields
}

Device holds the ADC pin and the needed settings for calculating the temperature based on the resistance.

func New

func New(pin machine.Pin) Device

New returns a new thermistor driver given an ADC pin.

func (*Device) Configure

func (d *Device) Configure()

Configure configures the ADC pin used for the thermistor.

func (*Device) ReadTemperature

func (d *Device) ReadTemperature() (temperature int32, err error)

ReadTemperature returns the temperature in celsius milli degrees (ºC/1000)

Jump to

Keyboard shortcuts

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