sachingaikwad4554
Posts: 2
Joined: Tue Aug 13, 2013 4:44 pm

Attaching Weight scale or Force resistive sensor to PI

Wed Aug 21, 2013 10:22 am

Hi,

I want to attach an electronic weighing scale or Force Resistive sensor to Raspberry PI. This will help me to weigh the object and save the data in a CSV file or may be a database on PI.

Better if someone can suggest me some USB weighing scale which i can connect to USB port on my PI.

I am not sure about Force resistive sensors. May be they are analog and RPI can't read them. I dont want to purchase hardware analog to digital converter, external ADC (such as the MCP3008])
This can be used along with some bit banged SPI code in python to read external analog devies. However, I want some simple thing.

btidey
Posts: 1636
Joined: Sun Feb 17, 2013 6:51 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Wed Aug 21, 2013 3:20 pm

I think you need to say what range of weights you are interested in. There are mice with usb scales built in up to 500g, postal weighing scales up to 25kG, body weight methods (e.g. WiiFit balance board, bluetooth) etc.

You would need to think about driver compatibility as well. Some solutions may have Windows specific drivers.

User avatar
JRV
Posts: 270
Joined: Mon Apr 02, 2012 1:39 pm
Location: Minneapolis, MN

Re: Attaching Weight scale or Force resistive sensor to PI

Thu Aug 22, 2013 10:27 pm

It is possible to read a force sensitive resistor on an Pi by counting how long it takes a capacitor to charge. See this Adafruit tutorial:

http://learn.adafruit.com/basic-resisto ... i/overview

sachingaikwad4554
Posts: 2
Joined: Tue Aug 13, 2013 4:44 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Tue Sep 03, 2013 3:26 am

can any one guide me on connecting weighing scale to the raspberry pi. I want to attach a digital weighing scale which can measure weight of an object from 10 grams to 5 kilo gram.

How can I connect the weighing scale to my RPI?

tenochtitlanuk
Posts: 156
Joined: Fri Jul 06, 2012 8:51 pm
Location: Taunton, Somerset, UK
Contact: Website

Re: Attaching Weight scale or Force resistive sensor to PI

Tue Sep 03, 2013 10:54 am

I've just ordered a USB weighing scale to experiment with.
Google 'postal scales usb'. It cost around 20ukp.

If Linux works with it I'll report back. If not, it'll be run under XP!

andyseubert
Posts: 3
Joined: Mon Jun 10, 2013 10:21 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Thu Sep 19, 2013 7:15 pm

Dymo USB scales work OK

a bit expensive, but
http://www.amazon.com/DYMO-Pelouze-Digi ... +usb+scale

with some simple python it is possible to easily read the scale

Code: Select all

VENDOR_ID = 0x0922
devices = usb.core.find(find_all=True, idVendor=VENDOR_ID)

		for device in devices:	
			if device.is_kernel_driver_active(0) is True:
				device.detach_kernel_driver(0)
			devbus = str(device.bus)
			devaddr = str(device.address)
			productid=str(device.idProduct)
			try:
				if str(usb.util.get_string(device,256,3)) == serialno:
					if debug: print "scale id:" + id + " serial: "+ serialno
					if debug: print ("device serial:    <" + str(usb.util.get_string(device,256,3))) + ">"
					## set USB device endpoint here
					endpoint = device[0][(0,0)][0]
					# read a data packet
					attempts = 10
					data = None						
					while data is None:# and attempts > 0:
						try:
							data = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
							if debug: print "data: "+str(data)
						except usb.core.USBError as e:
							data = None
							if e.args == ('Operation timed out',):
								attempts -= 1
								print e
								continue
					
					# The raw scale array data
					#print data
					raw_weight = data[4] + (256 * data[5])

					if data[2] == DATA_MODE_OUNCES:
						ounces = raw_weight * 0.1
						weight = "%s oz" % ounces
					elif data[2] == DATA_MODE_GRAMS:
						grams = raw_weight
						weight = "%s g" % grams
						
					reading = weight
					if debug: print "raw reading '" + reading +"'"
					readval = float(reading.split(" ")[0])
					readunit = reading.split(" ")[1]
					## if the units are ounces ("oz") then convert to "g"
					if readunit == "oz" and readval !=0:
						readval = readval*28.3495
						if debug: print "converted oz to g"
					if debug: print "current weight : '" + str(readval) +"' "+readunit
					if debug: print "current time   : "+strftime("%Y-%m-%d %H:%M:%S", localtime())
					

User avatar
jbeale
Posts: 3675
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Attaching Weight scale or Force resistive sensor to PI

Thu Sep 19, 2013 8:11 pm

Adafruit has a tutorial about scales with serial (RS-232) data output. Easy enough to interface to the Pi (or any computer) using a USB-serial converter. Cost is $70 for the unit they mention, handles up to 10 pounds. http://learn.adafruit.com/digital-shipp ... le-0-10-lb

I see a 5-pound capacity "USB scale" listed as cheap as $16 (but I bet that is simply powered from USB, no data transfer over USB)
http://www.ebay.com/itm/USB-Digital-Sca ... 1289440752

This one at $38 I do believe supports data transfer via USB. But looks like the USB driver may be Windows only.
http://www.ebay.com/itm/ULTRASHIP-60-LB ... 0848074299

tenochtitlanuk
Posts: 156
Joined: Fri Jul 06, 2012 8:51 pm
Location: Taunton, Somerset, UK
Contact: Website

Re: Attaching Weight scale or Force resistive sensor to PI

Thu Sep 19, 2013 9:23 pm

. . . and the one I ordered online ( see earlier) turned out NOT to have the advertised USB connection. So I have all the hassle of returning it, and of course they DON'T have the higher spec model on their stock list. At least I've got them to correct their product description... and won't mention here their trading name.

Still on my list of projects-to-do tho'.

kevpartner
Posts: 10
Joined: Fri Jun 01, 2012 4:29 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Mon Dec 02, 2013 3:06 pm

Thanks for this Andy - I've been wondering how to weigh stuff using a Pi for ages - I'm going to give it a go with the Dymo scales. My business involves a lot of weighing and bagging small quantities and I'm looking to automate as much of it as possible.
andyseubert wrote:Dymo USB scales work OK

a bit expensive, but
http://www.amazon.com/DYMO-Pelouze-Digi ... +usb+scale

with some simple python it is possible to easily read the scale

Code: Select all

VENDOR_ID = 0x0922
devices = usb.core.find(find_all=True, idVendor=VENDOR_ID)

		for device in devices:	
			if device.is_kernel_driver_active(0) is True:
				device.detach_kernel_driver(0)
			devbus = str(device.bus)
			devaddr = str(device.address)
			productid=str(device.idProduct)
			try:
				if str(usb.util.get_string(device,256,3)) == serialno:
					if debug: print "scale id:" + id + " serial: "+ serialno
					if debug: print ("device serial:    <" + str(usb.util.get_string(device,256,3))) + ">"
					## set USB device endpoint here
					endpoint = device[0][(0,0)][0]
					# read a data packet
					attempts = 10
					data = None						
					while data is None:# and attempts > 0:
						try:
							data = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
							if debug: print "data: "+str(data)
						except usb.core.USBError as e:
							data = None
							if e.args == ('Operation timed out',):
								attempts -= 1
								print e
								continue
					
					# The raw scale array data
					#print data
					raw_weight = data[4] + (256 * data[5])

					if data[2] == DATA_MODE_OUNCES:
						ounces = raw_weight * 0.1
						weight = "%s oz" % ounces
					elif data[2] == DATA_MODE_GRAMS:
						grams = raw_weight
						weight = "%s g" % grams
						
					reading = weight
					if debug: print "raw reading '" + reading +"'"
					readval = float(reading.split(" ")[0])
					readunit = reading.split(" ")[1]
					## if the units are ounces ("oz") then convert to "g"
					if readunit == "oz" and readval !=0:
						readval = readval*28.3495
						if debug: print "converted oz to g"
					if debug: print "current weight : '" + str(readval) +"' "+readunit
					if debug: print "current time   : "+strftime("%Y-%m-%d %H:%M:%S", localtime())
					

deanajaib
Posts: 3
Joined: Wed Mar 09, 2016 7:46 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Wed Mar 09, 2016 7:50 pm

Hai sir. have u done this project?

pifreak87
Posts: 1
Joined: Fri Apr 29, 2016 10:12 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Fri Apr 29, 2016 10:16 pm

Hi kevpartner,

Did this code work for you ?
Will the same code work for 100 Pound Dymo weighing scale ?

caporeira
Posts: 73
Joined: Sun Aug 25, 2013 5:58 pm

Re: Attaching Weight scale or Force resistive sensor to PI

Sun Jun 26, 2016 9:03 pm

I'm looking for scale about 50 - 200 kg.

User avatar
bensimmo
Posts: 4622
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Attaching Weight scale or Force resistive sensor to PI

Mon Jun 27, 2016 5:52 am

thanks for bringing this up, I have quite a few RS232 capable scales I can use in various ranges and also USB scales, which to be honest are mainly just RS232 convertors they tag on since RS232 is the standard they have always used.

Another project to add to the list :roll: :lol:

bubyken
Posts: 1
Joined: Wed Mar 29, 2017 6:26 am

Re: Attaching Weight scale or Force resistive sensor to PI

Wed Mar 29, 2017 6:50 am

Is this great for all brand weight scales?

Return to “Interfacing (DSI, CSI, I2C, etc.)”