Categorygithub.com/fpersson/gosensor
repository
0.0.0-20240919173637-d14928b5ddf3
Repository: https://github.com/fpersson/gosensor.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

example workflow

Usage

Hardware Requirement

build

Require go 1.22 or later

    cd sensor
    go install

build for rpi-zero

    cd sensor
    GOOS=linux GOARCH=arm GOARM=6 go build -o sensor main.go

build for rpi 3/4

    cd sensor
    GOOS=linux GOARCH=arm64 go build -o sensor main.go

run

Configurations

Default path for config files is $XDG_DATA_DIRS/tempsensor

    CONFIG=. ~/go/bin/sensor

With test device, the DEVICE is a fake device for testing

    CONFIG=./testdata DEVICE=./fejksensor/ go run ./sensor

With logging to file

    LOGDIR=./testlog.log CONFIG=./testdata DEVICE=./fejksensor/ go run ./sensor

Grafana dashboard

    SELECT mean("last") FROM "sensor_1" WHERE ("unit" = 'temperature') AND $timeFilter GROUP BY time($__interval) fill(null)

Health Check

    http://localhost:8081/health_check

Supported env

You can add some configurations as env or in .env

envdefaultNote
CONFIG$XDG_DATA_DIRSpath to your configuration
HTTPDIRoverride default http
DEVICEoverride device dir for testing
LOGDIRdefine file to log to
ALIVE5values given in minutes

Hardware

Setup DS18B20

Your DS18B20 should be connected to pin 7 (BCM4), gnd, and 3v.

Edit config.txt on raspbian it can be found in /boot nad opensuse it can be found in /boot/efi/ config.txt

# Enable gpio for DS18BS20
dtoverlay=w1-gpio,pinout=4,pullup=on

Reastart your system, check for /sys/bus/w1/devices/28-xxxxxxxxxx. If your device does not show up try:

    sudo modprobe w1-gpio
    sudo modprobe w1-therm

Note

This is the go version of tempSensor

Licens (Zero Clause BSD)

    Copyright (C) 2019, Fredrik Persson <[email protected]>

    Permission to use, copy, modify, and/or distribute this software
    for any purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
    OF THIS SOFTWARE.