USB Barcode Scanner (Raspberry Pi)

About: the Raspberry Pi is Awesome!

Basic tutorial of how to setup a USB barcode scanner with the Raspberry Pi.

Step 1: Parts

Step 2: Setup

1. Plug in USB Barcode Scanner to Raspberry Pi

2. Boot Pi and open terminal

Type "sudo raspi-config"

3. Go to interfacing options and enable "Serial"

4. Install dependencies

Type "pip install requests"

5. Navigate to https://upcdatabase.org/ and create a free account and take note of api key

6. Edit line 6 of barcode.py and enter your api key

7. Type "sudo python barcode.py" to run script (press ctrl+c to exit script)

Step 3: Code

Dependencies:

"pip install requests"

run:

sudo python barcode.py

Step 4: Additional Info

Share

    Recommendations

    • Organization Contest

      Organization Contest
    • Epilog X Contest

      Epilog X Contest
    • Paper Contest

      Paper Contest

    8 Discussions

    0
    None
    skishn

    2 months ago

    I get this error message when running on my pi B+ using sudo:

    {
    "status": 400,
    "message": "Bad Request. The code you are trying to enter does not contain all digits.",
    "error": true
    }

    The barcode that gets reported on the terminal does include all digits. When I try to check the code on the website using my api key, I get an item not found, but that's different from this error. Any ideas?

    Sample UPC (bottle of tylenol):
    050428377512

    1 reply
    0
    None
    JohnphilC

    Question 7 months ago on Step 3

    where do i find the api key? what does it look like?

    0
    None
    tssparky

    Question 10 months ago

    Is a pi3 mandatory? I have a pi2, and I'm running into difficulties getting python script to respond with python2, and python3 can't install request.

    0
    None
    GuuZ

    Question 1 year ago

    Hello, i'm completely new with the raspberrypi. I've used arduino alot but was wondering what u use the micro SD and jumper cables for. I can't find any use for them in your project, do you have a cicuit I can follow?

    0
    None
    AkiraR2

    Question 1 year ago on Step 4

    It shows an error called
    No such file/directory dev/hidraw0 exists
    how should I fix it?

    1 answer
    0
    None
    piddlerintherootAkiraR2

    Answer 1 year ago

    What version RPI are you running it on? Are you running it in sudo? Try running the updated the code.

    0
    None
    bivav

    1 year ago

    Hi there... I just wanted to know if it is possible to buy any bar code scanner to work with this code.. can we?

    Thank you in advance!!