Code Monkey home page Code Monkey logo

onewire's Introduction

Usage

    $ go get github.com/qmsk/onewire
    $ go install github.com/qmsk/onewire/cmd/...
    $ $GOPATH/bin/onewire-server -config-path config/test.toml -influxdb-server=localhost
    2016/01/23 13:41:14 server.LoadConfig config/test.toml
    2016/01/23 13:41:14 server.InfluxWriter {localhost onewire}
    2016/01/23 13:41:14 hidraw.List...
    2016/01/23 13:41:14 hidraw.Monitor...
    2016/01/23 13:41:14 http.ListenAndServe :8283...
    2016/01/23 13:41:21 AddHidrawDevice hidraw.DeviceInfo{Device:libudev.Device{DevPath:"/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.006D/hidraw/hidraw0", Subsystem:"hidraw", DevType:"", SysPath:"/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.006D/hidraw/hidraw0", SysName:"hidraw0", SysNum:"0", DevNode:"/dev/hidraw0"}, DeviceConfig:hidraw.DeviceConfig{VendorID:0x16c0, ProductID:0x480}}: &avrtemp.Device{hidrawDevice:(*hidraw.Device)(0xc20803c080), status:avrtemp.Status{Device:"/dev/hidraw0", Time:time.Time{sec:0, nsec:0x0, loc:(*time.Location)(nil)}, SensorCount:0x0}}
    2016/01/23 13:41:21 server.Server: Start avrtemp device hidraw0
    2016/01/23 13:41:23 server.Server: Stat 28ffc256921503ae: 245
    2016/01/23 13:41:24 server.Server: Stat 28ff1032921503ed: 244
    2016/01/23 13:41:25 server.Server: Stat 28ffc256921503ae: 246
    2016/01/23 13:41:26 server.Server: Stat 28ff1032921503ed: 244
    2016/01/23 13:41:27 server.Server: Stat 28ffc256921503ae: 246
    2016/01/23 13:41:28 server.Server: Stat 28ff1032921503ed: 244
    2016/01/23 13:41:28 server.Device hidraw0: avrtemp.Device /dev/hidraw0: Read: read /dev/hidraw0: input/output error
    2016/01/23 13:41:28 RemoveHidrawDevice hidraw0...
    2016/01/23 13:41:28 server.Server: Stop device hidraw0
    2016/01/23 13:41:45 AddHidrawDevice hidraw.DeviceInfo{Device:libudev.Device{DevPath:"/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.006E/hidraw/hidraw0", Subsystem:"hidraw", DevType:"", SysPath:"/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.006E/hidraw/hidraw0", SysName:"hidraw0", SysNum:"0", DevNode:"/dev/hidraw0"}, DeviceConfig:hidraw.DeviceConfig{VendorID:0x16c0, ProductID:0x480}}: &avrtemp.Device{hidrawDevice:(*hidraw.Device)(0xc20803c150), status:avrtemp.Status{Device:"/dev/hidraw0", Time:time.Time{sec:0, nsec:0x0, loc:(*time.Location)(nil)}, SensorCount:0x0}}
    2016/01/23 13:41:45 server.Server: Start avrtemp device hidraw0
    2016/01/23 13:41:47 server.Server: Stat 28ffc256921503ae: 245
    2016/01/23 13:41:48 server.Server: Stat 28ff1032921503ed: 243
    2016/01/23 13:41:49 server.Server: Stat 28ffc256921503ae: 245
    2016/01/23 13:41:50 server.Server: Stat 28ff1032921503ed: 243

InfluxDB

Supports writing stats to server -influxdb-server=... -influxdb-database=....

Grafana Screenshot

Grafana Query:

SELECT mean("temperature") FROM "onewire" WHERE "family" = 'ds18b20' AND $timeFilter GROUP BY time($interval), "id", "name" fill(null)

Config

The configuration file can be used to name connected sensors.

[sensors.test1]
ID  = "28ff1032921503ed"

[sensors.test2]
ID  = "28ffc256921503ae"

REST API

$ curl -s http://localhost:8283/api/config |json_pp
{
   "Sensors" : {
      "test1" : {
         "ID" : "28ff1032921503ed"
      },
      "test2" : {
         "ID" : "28ffc256921503ae"
      }
   }
}
$ curl -s http://localhost:8283/api/ |json_pp
[
   {
      "hidraw_device" : {
         "VendorID" : 5824,
         "DevNode" : "/dev/hidraw0",
         "SysName" : "hidraw0",
         "ProductID" : 1152,
         "DevPath" : "/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.0068/hidraw/hidraw0",
         "SysPath" : "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:16C0:0480.0068/hidraw/hidraw0",
         "DevType" : "",
         "SysNum" : "0",
         "Subsystem" : "hidraw"
      },
      "avrtemp_device" : {
         "sensor_count" : 2,
         "time" : "2016-01-23T12:40:58.593460789+02:00",
         "device" : "/dev/hidraw0"
      },
      "stats" : {
         "28ffc256921503ae" : "test2",
         "28ff1032921503ed" : "test1"
      },
      "name" : "hidraw0"
   }
]
$ curl -s http://localhost:8283/api/stats |json_pp
[
   {
      "sensor_name" : "test2",
      "family" : "ds18b20",
      "temperature" : 29.9,
      "id" : "28ffc256921503ae",
      "time" : "2016-01-23T12:41:05.703672347+02:00"
   },
   {
      "temperature" : 25.4,
      "sensor_name" : "test1",
      "family" : "ds18b20",
      "time" : "2016-01-23T12:41:04.687577945+02:00",
      "id" : "28ff1032921503ed"
   }
]

Devices

The server uses libudev to enumerate and monitor connected USB devices matching the configured -device-vendor= -device-product=. USB devices can be disconnected and reconnected without needing to restart the server.

Supported hardware

  • Diamex GmbH / AVR Temp Sensor (USB 16c0:0480)

Dependencies

  • libudev-dev

Configuration

/etc/udev/rules.d/90-hidraw.rules

KERNEL=="hidraw*", ATTRS{idProduct}=="0480", ATTRS{idVendor}=="16c0", \
    GROUP="plugdev", MODE=0660

onewire's People

Contributors

spcomb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

onewire's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.