Skip to content

Instantly share code, notes, and snippets.

@jdye64
Created April 22, 2018 18:52
Show Gist options
  • Save jdye64/bf15b10dd73f686116c2630cfdcc7380 to your computer and use it in GitHub Desktop.
Save jdye64/bf15b10dd73f686116c2630cfdcc7380 to your computer and use it in GitHub Desktop.
import picamera
import usb.core
import usb.util
import time
VENDOR_ID = 0x0922
PRODUCT_ID = 0x8003
# Find the Dymo USB scale.
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
camera = picamera.PiCamera()
attach = False
if device.is_kernel_driver_active(0):
reattach = True
device.detach_kernel_driver(0)
device.set_configuration()
endpoint = device[0][(0,0)][0]
counter = 0
while True:
camera.capture('/tmp/getfile/cam_' + str(counter) + '.jpg')
data = device.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
file = open('/tmp/weight/weight_' + str(counter) + '.txt', 'w')
raw_weight = data[4] + data[5] * 256
file.write(str(raw_weight))
file.close()
counter = counter + 1
time.sleep(3) 30 30,22 All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment