usbwde

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Simple go package to read data from USB-WDE weather data logger (ELV)

Github Release GoDoc Go Report Card Build/Test Status

This package allows to extract structured data from a USB-WDE weather station device (available from here). Usage is fairly trivial (see examples directory for a simple console logger implementation).

Features

  • Extraction of USBWDE RF sensor data
    • Up to 8 temperature / humidity sensors
    • Hybrid sensor providing temperature / humidity, wind speed and precipitation data

Installation

go get -u github.com/fako1024/usbwde

Example

// Initialize a new USBWDE sensor / station
sensor, err := usbwde.New("/dev/ttyUSB0")
if err != nil {
    logrus.StandardLogger().Fatalf("Error opening /dev/ttyUSB0: %s", err)
}

// Continuously throw a log message upon reception of updated data
for {

    // Read single data point
    dataPoint, err := sensor.Read()
    if err != nil {
        logrus.StandardLogger().Errorf("Error reading data from %s: %s", devicePath, err)
    }

    // Log data
    logrus.StandardLogger().Infof("Read data from %s: %s", devicePath, dataPoint)
}

Documentation

Index

Constants

View Source
const ValueDelta = 0.000001

Variables

This section is empty.

Functions

This section is empty.

Types

type DataPoint

type DataPoint struct {
	TimeStamp   time.Time
	Temperature [8]float64
	Humidity    [8]float64

	HybridSensor HybridSensor
}

DataPoint denotes a set of data taken at a specific point in time

func (*DataPoint) IsComplete added in v1.0.7

func (p *DataPoint) IsComplete(includeHybridSensor bool) (bool, error)

IsComplete returns if the data point has all fields set (and at least one of each temperature / Humidity is non-zero)

func (*DataPoint) String

func (p *DataPoint) String() string

String returns a well-formatted string for the data point, fulfilling the Stringer interface

type HybridSensor

type HybridSensor struct {
	Temperature   float64
	Humidity      float64
	WindSpeed     float64
	Precipitation int
	IsRaining     bool
}

HybridSensor denotes the data from the hybrid sensor (if present)

type USBWDE

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

USBWDE denotes an ELV USBWDE endpoint

func New

func New(socket string) (*USBWDE, error)

New creates a new USBWDE object

func (*USBWDE) Close

func (s *USBWDE) Close() error

Close closes the connection to the device

func (*USBWDE) Read

func (s *USBWDE) Read() (*DataPoint, error)

Read extracts a single data point from the sensor / device

Directories

Path Synopsis
examples
logger command
monitor command

Jump to

Keyboard shortcuts

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