author

thone

9
Inbox View Profile
1Instructables44,924Views23Comments

Tell us about yourself!

Achievements

10K+ Views Earned a bronze medal
  • USB Barcode Scanner (Raspberry Pi)

    I'm glad I could help. Often times I go back and use my own comments as notes if it's been a while.

    View Instructable »
  • USB Barcode Scanner (Raspberry Pi)

    I just wanted to add a tip. I found that if I had anything else plugged in, like a mouse or keyboard, the scanner didn't always default to hidraw0 which broke the program. So to avoid having to manually change this every time, I did the following. 1. Install pyudev (https://pyudev.readthedocs.io/en/latest/guide.html):sudo pip install pyudev Note: This needs to be installed for the root since the script has to be run with root permissions.2. Determine which hidraw is your scanner.- start with your scanner unplugged- open a terminal on your raspberry pi and type: udevadm monitor- plug in your scanner and it will print a lot of lines- go through the text that printed and determine which hidraw# the scanner was assigned toNote: for this example my scanner is hidraw03. Find a unique identifier…

    see more »

    I just wanted to add a tip. I found that if I had anything else plugged in, like a mouse or keyboard, the scanner didn't always default to hidraw0 which broke the program. So to avoid having to manually change this every time, I did the following. 1. Install pyudev (https://pyudev.readthedocs.io/en/latest/guide.html):sudo pip install pyudev Note: This needs to be installed for the root since the script has to be run with root permissions.2. Determine which hidraw is your scanner.- start with your scanner unplugged- open a terminal on your raspberry pi and type: udevadm monitor- plug in your scanner and it will print a lot of lines- go through the text that printed and determine which hidraw# the scanner was assigned toNote: for this example my scanner is hidraw03. Find a unique identifier for your scannertype python3>>>import pyudev as pd # This imports the function>>>context = pd.Context() # pyudev requires a context to be used>>> for device in context.list_devices(subsystem='hidraw'):... print(device)(make sure you have 4 spaces before print(device) and hit enter twice)Copy the path right before /hidraw/, mine printed like this:Device('/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/0003:046A:B091.0014/hidraw/hidraw1')Device('/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:0416:C141.0013/hidraw/hidraw0')The information after the period will change depending on which usb port it's plugged into. So you will want to copy the part up to the period. For me this is 0003:0416:C1414. Add the pyudev code to provide dynamic support of your scanner.To do this open the python script in your preferred code editor or text editor and add the following code after the last import lineimport pyudev as pdcontext = pd.Context()for device in context.list_devices(subsystem='hidraw'): if ('{0}'.format(device.find_parent('hid'))).find('0003:0416:C141') != -1: location = device.device_nodeMake sure you replace the 0003:0416:C141 with your device informationchange def barcode_reader(): to def barcode_reader(device_local):change fp = open('/dev/hidraw0', 'rb') to fp = open(device_local, 'rb')now when you call the function you need to add the location i.e. UPC_lookup(api_key,barcode_reader(location)) instead of UPC_lookup(api_key,barcode_reader())I hope this helps!

    I just posted a comment that might help you with this.

    View Instructable »
  • That question is fairly broad so I hope this reply helps. I wanted to be able to use this with any audio so I found another instructable that broke out frequency, credit given above. That instructable is where I got the voltage splitter and all necessary parts for the audio input. It's not the most accurate for timing but is the best I could come up with for a live display.

    I apologise for the delayed response. You would use either the left or right. The ground goes to the ground on the Arduino and your chosen channel goes to the analog readout of the Arduino.

    View Instructable »