Installing a USB Scale
I am trying to install a USB Scale that previously worked when I was on Windows. However, I am a complete newb and have no idea what to do to get this thing going. I am using Ubuntu 6.06 and kernel
2.6.15-27-386. When I plugged in the device, "dmesg" read as below. Code:
[17554543.240000] usb 3-2: new low speed USB device using uhci_hcd and address 2[17554543.448000] hiddev96: USB HID v1.10 Device [RadioShack Corporation USB Electronic Scale] on usb-0000:00:1d.2-2 |
Looks like there are no well-known open-source drivers available but perhaps an exhaustive search will turn up something. Try calling the manufacturer and see if they have any source code for Linux (or windows for that matter).
There is a chance that it works like a joystick. Open up KDE Control Center and look under Peripherals - Joystick. If so, you could hire a programmer or study up and write a "simple" program in C to read the joystick and calibrate it to weight in pounds, ounces, kilograms or stones, whatever. If it's not a joystick or mouse-like device, it will require more delving into the uhci_hcd source code and docs. Not a problem if you have the time--or the money. A "quick and dirty" solution is to use qemu with the new usb support and boot up your old windows disk in a window, using the windows driver. Presto! |
Have you had any more progress on this project? I'm planning to do something similar. I have Pitney Bowes USB scale. I'd welcome any suggestions on usb hid interface as well.
Thx CHris |
I've not had further progress. It's just sitting by my desk until I want to deal with it again.
|
Hi,
OK, I think I have some good news. I've been playing around with that scale this evening and using the information that I found here : http://www.frogmouth.net/hid-doco/linux-hid.html and all over the Internet I've managed to write a little C program that reads events from the hid device. I don't know about your scale but mine seems to be regular HID device and there's no special event device created for it so I read directly from hid interface. Here's the code : Code:
#include <stdlib.h> Code:
gcc -o hidtest -Wall -W hid.c If you have problem compiling I noticed there's a bug in hiddev.h header that uses macro that wasn't defined in any of previuosly included files - HID_MAX_USAGES. The quick and dirty workaround is to edit the /usr/include/linux/hiddev.h and comment out the lines : Code:
//struct hiddev_usage_ref_multi { So, example output from my scale is : OK name = Pitney Bowes MP6V Reading values .. EV: PARAM 008d0050 : 2 EV: PARAM 008d0050 : 11 EV: PARAM 008d0050 : 255 EV: PARAM 008d0050 : 0 EV: PARAM 008d0050 : 0 and after putting 13.4 oz item on the scale it changes to : EV: PARAM 008d0050 : 4 EV: PARAM 008d0050 : 11 EV: PARAM 008d0050 : 255 EV: PARAM 008d0050 : 134 - looks exactly like what I'm looking for :) EV: PARAM 008d0050 : 0 I determined following meanings of the values (in the sequence): 1 : Status : 2-tray empty, 3-measuring in progress, 4-stable reading 2 : 11 probably first byte separator, never changes 3 : 255 probably second byte of separator, never changes 4 : weight - LSB 5 : weight - MSB therefore total weight in oz is: WEIGHT = (MSB * 25.5) + LSB / 10 I guessed number of structures (5) by experiment; if I read more the output looks like garbage. The only thing I have to figure out now is what to send to the scale to calibrate it. It presumably calibrates once turned on but it's better to have this function available. As hid devs are "self descriptive" I guess I have to look for a proper ioctl interface param and shoot it to the scale. |
Finally, I created a program that shows more user firendly results ;) - works with PitneyBowes SmallOffice Series scale. I believe it can be easily modified to work with any other HID compatible scale. Soon, I'll add a "calibrate" function.
Code:
#include <stdlib.h> |
Tried the code with a no-name USB scale
Just a note to let you know that I managed to get your code to work with a no-name USB scale. Instead of a EV_SIZE=5 I had to read the parameters into two separate variables, 8 events at a time. And the weight output was encoded in a different way.
Thanks! |
Glad to hear that, can you post a short description of how you calculate the final weight using your device?
|
looks like you have something for a page on Sourceforge.
|
How's the progress on the scale? I'm using F8, a total newb. I have the same scale but can't use it. I have a copy of the official radio shack osx and xp drivers, would any portions of those be useful in building a driver for Linux?
|
Hi,
Sorry for the late answer, I was quite busy recently. I think you can use the code that I posted above however hhhansen would have to help you modify it as he did (he also has RS scale). Did you try to compile the source? Chris |
compiling is a little beyond my ability at this time. I'm teaching the staff at the same time I learn something new, so everything's breaking, too! Trying to get them to call a file and interpret a reading is also a bit beyond the users here. I was hoping you or someone else had found or created a good scale driver and posted. I did find a reference to the vendor and product ID on another linux website for usb devices, but that ended up in another all-nighter search with no useful results. I also got the m$ and mac drivers, if those are of any help.
|
I'm afraid you will not find it. I was also looking for it. I took me so long that I wrote my own software to deal with it. Compiling is not that difficult though, I think I can help you with that. Let's start with this question : what Linux distribution are you using?
|
Hi Krizzz,
I got fap'ed by the bit gestapo, so everything is really slow. Anyway, I'm using f8kde on the target system. The USB scale I have is the Radio Shack one and Kinfo id's it as vendor#2233 product#6323. I'd like to get this thing working so we can weigh mail for postage. I was diddling around earlier with modprobe getting another usb device working today and I'm wondering if that was even necessary since the kernel already had the vendor and product numbers already in it. I haven't knowingly compiled a thing yet in Linux, so this sounds like a good reason to have Linux, sort of brings back the fun of having a computer in the first place. |
Alright, I assume that you know how to use terminal. Copy the code from the post #6 and save it to the file named hid.c . Then in the directory where the file is try to execute following :
Quote:
Quote:
Once we have all that info we can carry on... |
cd Desktop
[jan@alpha-site Desktop]$ ./hidtest /dev/usb/hiddev0 hiddev open: No such file or directory [jan@alpha-site Desktop]$ ls -l /dev/usb/hid* ls: cannot access /dev/usb/hid*: No such file or directory [jan@alpha-site Desktop]$ lsusb bash: lsusb: command not found hid.c and hidtest exist. Should I be doing this as root? I had a problem a little earlier when I tried to copy/paste post#6. The browser crashed, bug-report popped-up. I restarted the system and then the copy/paste started working again. |
I found a section in one of my manuals on programming, think I'll read it.
|
It seems that you successfully compiled the program so you're very close from actually getting it to work. I checked out the fedora core hiddev support and the device should be there by default but the path to it is a bit different. I used Slackware in my example. Try using /dev/hiddev0 instead of /dev/usb/hiddev0. That should work. Also, please post output from lsusb command and try ls -l /dev/hid* this time. Make sure the scale is connected.
|
I agree that you probably do have a SourceForge entry.
The only remaining "trick" is the USB bit. The piece you probably want to read more about is called hotplug. When you plug-in a device or remove it, the hotplug daemon looks-up information to find out what to do. (In your case, specifically look at /etc/hotplug/usb*.) In your case, this device really isn't privileged and probably won't be used by more than one client, so all you'd really like to do here is to have it set up a nice entry in /dev/input so that your user-application can expect to find the device by a nice name such as pitney_bowes_xyzzy_scale. Beyond that, no system-level driver-stuff is needed: you can read and write to the device as it is. A short user-level library might be a nice touch, with routines like "is there a device attached," "wait so-many seconds for device to be attached," "wait so-many seconds to read the weight," and so on. |
Actually the Pitney-Bowes scale has been working for me for quite a while. I read directly from the raw hiddev as the protocol is trivial - just like I demonstrated in the example. It would be good if hhhansen posted his modifications to the code for Radio Shack scale then the people like yonnieboy wouldn't have to struggle again. We could add the scale recognition and support for different USB scales over unified protocol. I'll open the SF project.
|
Quote:
|
cd Desktop
[jan@alpha-site Desktop]$ gcc -o hidtest -Wall -W hid.c [jan@alpha-site Desktop]$ ./hidtest /dev/hiddev0 hiddev open: Permission denied [jan@alpha-site Desktop]$ ps PID TTY TIME CMD 7706 pts/0 00:00:00 bash 7845 pts/0 00:00:00 ps [jan@alpha-site Desktop]$ lsusb bash: lsusb: command not found [jan@alpha-site Desktop]$ ls -l /dev/hid* crw-rw---- 1 root root 180, 96 2008-05-04 05:34 /dev/hiddev0 crw-rw---- 1 root root 251, 0 2008-05-04 05:34 /dev/hidraw0 [jan@alpha-site Desktop]$ I took your change as meaning the line in the file hid.c and changed it too. After altering the file I clicked on hidtest and nothing seemed to happen. So then I did the above from the terminal. I can't find the process using ps -ef so I can't kill it and try over. after reboot hiddev is still open permission denied |
Try to run it as root. You don't have permissions to the device.
|
ktop]# hidtest
bash: hidtest: command not found [root@alpha-site Desktop]# ./hidtest usage: ./hidtest hiddevice - probably /dev/hiddev0 [root@alpha-site Desktop]# ./hidtest /dev/hiddev0 RadioShack Corporation USB Electronic Scale ready... Reading values .. exit The display just sat there at reading values, I put envelopes on and my glasses, and my finger, no changes. So I tried exit, then q, then escape, no effect. So I closed the terminal. Doubleclicking the hidtest icon as root didn't appear to do anything either. But it apparently does something as root! |
radioshack USB scale
I wrote some terribly sloppy code that seems to mostly work with the "Radio Shack USB Scale"
(ID 2233:6323 RadioShack Corporation USB Electronic Scale) Even though it's been a while since anyone posted this thread helped me initially and is the first result in google for "linux usb scale" The places where it is divided by 2.55 may be further fine-tuned by changing that number. If someone finds a better value please reply, as I don't have a comparison scale handy. That is, if it's possible to make sense of this ;) Code:
#include <stdlib.h> I know it's ugly! But at least give it a try with your RadioShack USB Scale if you're interested. |
Thanks! I'll go hunt down where it may have gone! I haven't had the time to fiddle with it. Wife's all mad because her XP got replaced with Linux and then her scale don't work, and the system is broke, when all she wants most is solitaire. Well...I put a few nice things on like a whole bunch of solitaire games and gnucash, and cosmos screensavers, and grandkid education stuff ... well she likes it better now than the xp! Except for the scale! I'll try it out and get back to you!
Really appreciate the effort! |
Actually after some more testing, under heavier weight this is broken... but it's a start.
|
Here it is able to work off of heavier weights.
Might still need some tuning for completely accurate weights, but it's fairly close. Code:
#include <stdlib.h> Rather than continue editing it here i'll keep the newest working at http://kubes.org/src/usbscale.c |
works with RadioShack scale on Ubuntu 11.10 64-bit
Thanks @bkubes. I downloaded the source from your website, built it, and it works on my 64-bit machine. Nice job.
Any plans to host this somewhere for others to fork and work from, ala GitHub? |
Thanks lucasrangit. While I love programming I'm still very much a novice..
A while back I found someone who had ported it to python- http://www.thok.org/intranet/python/usb/README.html He cleaned up the code some, and some of the variable names are more intuitive. I don't have any future plans for the code.. perhaps if I can find the scale again. However, if anyone wants to use / modify the source code they're free to do whatever they like. Best Regards |
Kaw-410 usb
Hi all.
I'm trying to connect my USB scale on my Ubuntu 12.04 but i have some problems. I will explain step by step my procedure*: - open a terminal - connect the scale - in terminal*: lsusb*: Bus 002 Device 005: ID 0fff:0001 Aopen, Inc.*: good news - compile and run the C program on post 5*: the compilation works and the program said*: «*reading values*»*: good news - when i had put the scale on my computer, the LCD display «*LOAD*» … - i have try to put myself on the scale but the program had any reactions … The scale model is KAW-410 USB and my aim is just to keep the results in a file txt. |
Try this from the terminal:
Code:
ls -l /dev/usb/hiddev* Also, before "reading values" you should be getting the name of your scale displayed. |
Kaw-410 usb
Hi,
Thanks for your answer ! i have not the USB scale at this time. But i remember when i connect the scale and run the program, i could see the name of the USB scale before "reading values". In memory, the result of "ls -l /dev/usb/hiddev*" is "hiddev0". (sorry for my english, i'm french user ..) |
No worries, I'm not a native English speaker either. You should try to confirm that the scale is actually generating values by doing this:
Code:
cat /dev/usb/hiddev0 > testing.bin Make sure that the scale is turned on and weighting something while you do that. Then view the file with your favorite editor to see if anything was saved, there should be a whole bunch of random looking characters. Code:
vi testing.bin |
Test fails ...
Hi.
i have tryed the commands into last post but the test fails i think. After typing command-line : sudo cat /dev/usb/hiddev0 >testing_scale.bin, i try to put myself on the scale but not reaction with the Scale (the LCD displays "LOAD") ... After, i interrupted the process with Ctrl+C and see the content of the file testing_scale.bin with vi editor. It's an empty file ... When i type dmesg command-line, i can see this model : [ 4174.544035] usb 6-2: new low-speed USB device number 2 using uhci_hcd [ 4174.737490] generic-usb 0003:0FFF:0001.0003: hiddev0,hidraw2: USB HID v1.00 Device [SONiX Transtek-Scale v3] on usb-0000:00:1d.0-2/input0 What's happen ? |
It almost looks to me like you need to send something to your scale in order to initialize it. You will have to use some USB sniffing software on Windows to check if the driver sends something to the scale. It should not be too difficult with the right software.
Here is a free one : http://usbsnoop.sourceforge.net/ Let us know how it went. |
Bad news
Hi.
I have tryed some softs to snif USB port .. USBSnoop has some problems to display interface. When i run the program, the interface alway blinking ... i have tried xp-compatibilty mode but nothing change ... I tried 2 others softs : usblyzer and an other. I can seen datas (HEXA datas) when i put the scale into the USB port. But, when i try to put myself on the scale, no reaction, no logs ... I think, the USB-scale can't communicate in live with the OS .. I googled to find a USB Scale with usb live communication but i don't find any model. I find usb postal-scale only ! Have you some models of USB weighing scale ? |
Does the scale work on windows? Do you have a windows software for it?
|
Hi.
Ya, the scale works on Windows XP/7 and i have a specific software on a CDROM : "Body Scale" (the EXE name is FatScaleUsb.exe) |
up :]
Have-you a model name with real-time display results on the Computer ? i can't find model on web with this feature !!! |
.. up ?!
Can you gives me some usb scales supported by your program ? |
All times are GMT -5. The time now is 09:18 AM. |