sensors

package
v0.0.0-...-b95a7b5 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package to interact with various sensor modules.

A sensor module is a device that measures one or more aspects of the physical world (temperature, humidity, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Angle

type Angle int8

Angle represents an angular measurement (degrees).

type DLPTH1C

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

DLPTH1C represents an open serial connection to a DLP-TH1C sensor device.

Additional sensor information available at http://www.dlpdesign.com/usb/th1c.php

func NewDLPTH1C

func NewDLPTH1C(portName string) (*DLPTH1C, error)

NewDLPTH1C opens a serial connection to a DLP-TH1C sensor device and return a sensor object for device interaction.

func (*DLPTH1C) Close

func (d *DLPTH1C) Close() error

Close the open connection to the device.

func (*DLPTH1C) ConfirmConnection

func (d *DLPTH1C) ConfirmConnection(maxPingCount int) error

ConfirmConnection will confirm a good connection to the device by performing up to a specified maximum number of pings. If all fail, the error returned by the final call to Ping() will be returned.

func (*DLPTH1C) GetBroadbandSound

func (d *DLPTH1C) GetBroadbandSound() (SoundLevel, error)

GetBroadbandSound returns the broadband ambient sound level.

func (*DLPTH1C) GetHumidity

func (d *DLPTH1C) GetHumidity() (Humidity, error)

GetHumidity retrieves the current humidity value.

func (*DLPTH1C) GetLight

func (d *DLPTH1C) GetLight() (LightLevel, error)

GetLight returns the ambient light level.

func (*DLPTH1C) GetPressure

func (d *DLPTH1C) GetPressure() (Pressure, error)

GetPressure retrieves the current pressure value.

func (*DLPTH1C) GetSound

func (d *DLPTH1C) GetSound() (Frequencies, error)

GetSound returns the fundamental (peak-amplitude) frequency of ambient sound and five lower-amplitude peaks.

func (*DLPTH1C) GetTemperature

func (d *DLPTH1C) GetTemperature() (Temperature, error)

GetTemperature retrieves the current temperature value.

func (*DLPTH1C) GetTilt

func (d *DLPTH1C) GetTilt() (Tilt, error)

GetTilt retrieves the current X, Y, & Z tilt values.

func (*DLPTH1C) GetVibrationX

func (d *DLPTH1C) GetVibrationX() (Frequencies, error)

GetVibrationX retrieve the X-axis fundamental (peak-amplitude) frequency of vibration and five lower-amplitude peaks.

func (*DLPTH1C) GetVibrationY

func (d *DLPTH1C) GetVibrationY() (Frequencies, error)

GetVibrationY retrieve the Y-axis fundamental (peak-amplitude) frequency of vibration and five lower-amplitude peaks.

func (*DLPTH1C) GetVibrationZ

func (d *DLPTH1C) GetVibrationZ() (Frequencies, error)

GetVibrationZ retrieve the Z-axis fundamental (peak-amplitude) frequency of vibration and five lower-amplitude peaks.

func (*DLPTH1C) Ping

func (d *DLPTH1C) Ping() error

Ping the connected device and verify response.

Note: a device that is disconnected before its response value has been fully read may still have one byte in its internal response buffer. The first ping may fail in this case. It may be necessary to ping more than once to reset the device to a known state ready to receive new commands. ConfirmConnection can be used to perform multiple pings.

type Frequencies

type Frequencies struct {
	Fundamental Peak
	Peaks       [5]Peak
}

Frequencies stores a fundamental and five subharmonic peaks.

Note that lower-amplitude peaks can be above or below the fundamental. The response is always a single fundamental followed by five peaks as per https://www.dlpdesign.com/DLP-TH1C-DS-V10.pdf?page=6.

func (Frequencies) String

func (f Frequencies) String() string

type Frequency

type Frequency int

Frequency (Hz).

func (Frequency) String

func (f Frequency) String() string

type Humidity

type Humidity float32

Humidity represents the humidity (%RH). Value range: 0.0 → 100.0.

func (Humidity) String

func (h Humidity) String() string

type LightLevel

type LightLevel float32

LightLevel represents the ambient light level (unitless). Value range: 0.0 → 1.0.

func (LightLevel) String

func (l LightLevel) String() string

type Peak

type Peak struct {
	Freq      Frequency
	Amplitude SoundLevel
}

Peak stores a frequency and amplitude of sound measured.

func (Peak) String

func (p Peak) String() string

type Pressure

type Pressure float32

Pressure represents atmospheric pressure (hPa).

func (Pressure) String

func (p Pressure) String() string

type SoundLevel

type SoundLevel float32

SoundLevel represents the sound level or amplitude (dB).

func (SoundLevel) String

func (s SoundLevel) String() string

type Temperature

type Temperature float32

Temperature represents the temperature (°C).

func (Temperature) String

func (t Temperature) String() string

type Tilt

type Tilt [3]Angle

Tilt represents the angular tilt around the three axis: X, Y, and Z.

func (Tilt) String

func (t Tilt) String() string

Jump to

Keyboard shortcuts

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