Giter VIP home page Giter VIP logo

usb-scale-reader's Introduction

USBScaleReader

Latest Stable Version

This library lets you read weight from a standard USB scale using pure PHP.

Could be ported to other languages with ease, should they have unpack()

Tested with:

  • Stamps.com Stainless Steel 5 lb. Digital Scale
  • DYMO M25 25 lb Digital Postal Scale

See read_stupid.php or usbscale.c if you want to understand how it works at a glance.

Usage

composer require sanmai/usb-scale-reader

And then:

$reader = \USBScaleReader\Reader::fromDevice('/dev/scale');
$weightInGrams = $reader->getWeight();
var_dump($reader, $weightInGrams);

Sample output:

class USBScaleReader\Reader#2 (5) {
  public $report =>
  int(3)
  public $status =>
  int(4)
  public $unit =>
  int(2)
  public $exponent =>
  int(0)
  public $weight =>
  int(144)
}
int(144)

udev rules

Add to /etc/udev/rules.d/80-persistent-scale.rules:

KERNEL=="hidraw*", ATTRS{manufacturer}=="Maker Name", SYMLINK+="scale"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"

Maker name is either Stamps.com or DYMO.

And then reconnect your scale.

For other makers see:

udevadm info -a -p  $(udevadm info -q path -n /dev/hidrawN)

These rules imply that you should be in plugdev for the scripts to work.

C version

There is also a simple reading program written in C.

To build it and run tests against PHP implementation:

cd example
make test

Usage is as simple as it can be:

./usbscale /dev/hidraw3

Outputs something like

70.87 g

usb-scale-reader's People

Contributors

sanmai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

usb-scale-reader's Issues

trying to used code with Satorius Practium 313-1S

Hello -

I cloned the directory and made the c file, then attempted to run using 'sudo ./usbscale /dev/hidraw3', but there was no hidraw3. A quick glance showed that hidraw0 and hidraw1 exist, and I tried both of those but the program just stalls.

I have not changed any files, and am unsure exactly how to adjust the rules file to accept this scale. Can you explain to me how to do so??

Thanks!

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.