Introduction

We're glad you could join us for another lesson in our series on programming for the Raspberry Pi 4. The previous chapter covered the steps required to build an IVR using a Raspberry Pi 4 and a Sim800l. Our familiarity with IVRs and how they function has significantly increased. The benefits and drawbacks of its use were also discussed, but what we're interested in for this article is how to connect a USB barcode scanner to a Raspberry Pi 4.

How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

Components 

  • Raspberry Pi 4 

  • USB Handheld Barcode Scanner

  • 16 * 2 alphanumeric LCD

  • I2C Module for LCD

  • Jumper Wires

  • Sample Barcoded Items

If you own a busy shop, you know how important it is to maintain the products your consumers desire in stock at all times. The quickest and easiest method is to stroll the shelves and fill in empty spots. Another option is to keep a tally of what sells at the register, use that information to place restocking orders, and discard the record. That's good if you are running a small shop, but how about if you are a big store selling hundreds of products? There are numerous other challenges to successfully managing a retail establishment. If you put the pricing on all of your products and then decide to modify them before selling them, you'll have to return and re-price everything. What about theft from stores, though? Can you be sure you've sold all of the whisky if you notice a lot of bottles are missing from the shelves? Is there a way to determine if unauthorized parties have taken any?

All of these issues can be mitigated using barcode technology in retail. It allows you to maintain an organized database of your items, costs, and inventory levels in one convenient location. Price changes can be implemented whenever you desire without requiring new labels for previously packaged goods. You can tell exactly when your supply of a particular item is getting low, so you may place a new purchase before you run out. Since the barcode system is so precise, you may assume that any missing (and seemingly unsold) items have been stolen, giving you time to relocate them to a safer portion of the shop or secure them with radio frequency identification.

Barcode Scanner can read a wide range of linear barcodes. Barcode scanners are commonly utilized in retail settings like supermarkets, grocery stores, restaurants, boutiques, and other retail establishments. Intelligent shopping carts now use barcode scanners to quickly and accurately identify products. In this post, you'll learn how to read the Barcode scanner's output in the Serial interface of the Pi 4 and show the scanned Code on the 16 * 2 LCD. When a User reviews an item's Code, the LCD will update to reflect the new total number of items in the shopping basket. This configuration allows us to create an intelligent cart with an integrated billing system.

Simple Bar Code Scanner: The Fundamentals

Connecting your handheld barcode scanner to a computer is as simple as plugging it into a USB port. Barcode scanners can typically decode at speeds of up to 300 scans/second. Additionally, they can easily read a wide range of scratchy, blurry barcodes.

Serial output through USB is provided in either H.I.D. mode or RS232 mode, depending on the device's configuration. Users can change the Baud rate from 9600 to 115200 and modify the Suffix by adding a C.R., L.F., CR+LF, or no ending characters. And you may set it to read in either Trigger Mode or Continuous Mode. Scanning the included settings sheet's Barcode will also restore the machine to its factory defaults.

How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

I have used this barcode reader. The USB and RS232 modes are compatible with one other. Additionally, the baud rate of this Barcode can be adjusted by programming.

Explanation of the Barcode's Operation

A barcode is a machine-readable graphic represented by a series of black-and-white parallel bars. Products can be conveniently located and tracked with the use of barcodes. Barcodes have several applications, including in-store purchases, warehouse inventory management, and invoices for improved bookkeeping.

We could print the number, but computers have difficulty distinguishing between decimal numbers. We need a foolproof method of printing digits that can be read quickly and correctly. Barcodes are a solution to this very problem.

How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

Looking at a barcode, it might be challenging to determine where one set of numbers stops and another begins. But in reality, it's pretty easy. There are precisely seven units of horizontal space between each letter in the product id. Then, we use a different color scheme for those seven units to symbolize any number from zero to nine. Therefore, two white lines, two black lines, two white lines, and one black line make up the number one, whereas two white stripes, one black cord, two white lines, and the remaining two black lines make up the number two.

As you may have observed, representing three different sorts of information causes barcodes to be extremely lengthy. Where a barcode was first issued is indicated by its first digits. In the following section, you will learn who made this item. The Barcode's last digits reveal information about the item being sold. The barcodes for many iterations of the same core product are uniquely different from one another.

The universal product code is a type of Barcode found on most consumer goods. It consists of a series of vertical stripes and numbers imprinted below (so the Barcode can be manually keyed in if it is incorrectly printed or scratched in the store). Barcodes are becoming more commonplace, but there is another type that contains far more data. Two-dimensional barcodes appear on some items, such as postal stamps printed at home.

How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

Let's pretend that barcodes are specific on-off binary sequences, with every black stripe representing a one and every white stripe representing a zero. (We've seen that actual barcodes are more complex than this, but for now, simplicity is in order.)

  1. The Barcode is illuminated by the scanning head's L.E.D. or laser.

  2. Second, a photoelectric cell, an electronic component that detects light, receives the light reflected from the Barcode. The Barcode's white spaces are the most reflective, while the black ones are the least.

  3. Third, the cell produces an on/off pulse sequence corresponding to black and white lines when the scanner goes through the Barcode. The cell would read "off off off off off off" if the shown Code were to be entered.

  4. These on/off pulses are then translated into numeric values via an electronic circuit connected to the scanner.

  5. A computer program generates the final Barcode using the digital data sent from the scanner.

How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

Some scanners use a single photosensitive cell that reads the barcode pixel by pixel as you slide the sensor head over the item (or the product across the reader). The complete Code is detected in a single pass thanks to a row of photoelectric cells in more complex scanners.

Variety of Barcodes

The following are examples of well-known barcode types:

  • The European Item Numbering Scheme (EAN) is a specialized version of the Uniform Product Code (U.P.C.) for items with a thirteen-digit identifier. There are 13 digits in an EAN13 barcode.

    How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

    • The retail sector heavily uses UPC-A barcodes based on the U.P.C. The Universal Product Code, Extended (UPC-A), comprises 12 digits.

      How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

      • (EAN -8) uses a set of numbers superseding the U.P.C. EAN-8 for compact shipments; these numbers include eight digits.

        How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

        • Like code 128's character set C, Intermingled 2 of 5 (I.T.F.) is an arithmetic barcode used to encode pairs of integers in a space-efficient manner.

          How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

          • The Code 39 Q.R. code is the most straightforward of all the alphanumeric barcodes because it performs its character verification.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            • Code 128 is a high-density, efficient symbology for encoding alphanumeric data. The checksum digit is incorporated into the symbology, and the Barcode's integrity can be checked by comparing the checksum with the original data or by comparing the Barcode's bytes to the original data's parity.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Since Code 128 is widely utilized for its ability to hold alphanumeric data of a fixed length, we've chosen a few randomly to employ in our project.

            The Various Forms of Barcode Scanners

            1. Pen type readers

            This scanner is widely used in stores and may function without a cord. A photodiode and L.E.D. are integrated into its very tip. When light is shone on a barcode, its dark bars soak up the rays. In addition, the photodiode's output is reflected in the white areas. Because of this, the scanner can read the generated output waveform. They guarantee low costs and long service life. More specifically, the scanner has to maintain a fixed angle as it moves across the barcodes at a fixed rate. The user may have to spend some time at the gym to get good at this.

            1. Scanner for barcodes that use lasers

            They follow the same principle as traditional pen readers. They use a laser beam as the light source and a revolving prism to detect it. Therefore, they are effective even at a distance of two feet. This allows them to be surface-mounted, eliminating the need for handshakes. Compared to traditional pen-style scanners, these are far superior due to their speed and accuracy.

            1. Light-Emitting Diode Scanner (C.C.D. scanner)

            The ambient light that the Barcode emits is what is measured. The information is translated into a voltage pattern, which is then read by an L.E.D. scanner. Unlike other barcode scanners, this one doesn't come with a light source. Although the C.C.D. systems are pricey, they are more adaptable and accurate than alternatives. They're commonly found in stores.

            1. Camera barcode reader 

            The two-dimensional Barcode is usually scanned using a barcode scanner with a two-dimensional camera. The camera must be set to auto-focus and maintained at a fixed distance. Multiple small lights are placed to form the camera. The barcodes will be photographed digitally and uploaded to the system.

            1. Imaging barcodes with a cell phone

            These days, practically every smartphone has a built-in scanner. Successfully scanning the 2-dimensional Bar code will not necessitate autofocus. These barcodes are unreadable by a regular scanner.

            Integration of a Barcode Reader into a Raspberry Pi and an LCD Display Circuit

            The Code Barcode detected by the barcode reader will be displayed on a 16 * 2  LCD connected to the Pi 4 in an I2C interface.

            The image below illustrates the Raspberry Pi connection for the Led display and barcode scanner. Due to its 4-wired nature, I2C has been shown here.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4
            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            All of the relevant relationships are displayed in the table above. Here, we're thinking about the Raspberry Pi's GPIO pin layout instead of its P.I.N. arrangement.

            You may look at the accompanying image if you need more confirmation that all the connections are directly coupled to the RPi with no intervening components like resistors or capacitors.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Let's have a peek at what it is that we're constructing. Various things, including a breadboard, hand sanitizer, and others, have been labeled with randomly generated barcodes, as shown above. You may also notice that our barcode reader has a configuration page.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Instructions for configuring the Raspberry Pi's I2C interface for use with an LCD

            To begin, we need to turn on I2C on the Raspberry Pi. Here is the command to enter the terminal to turn it on.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            sudo raspi-config

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Now, use the down arrow key to access the Interfacing menu, and from there, select the P5 option, which is the I2C Enable/Disable menu item.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Once that's done, it'll inquire whether or not "you want the A.R.M. interface to be enabled." If you want to see "The ARM I2C adapter is enabled," select "Yes>." Select "ok" and then "complete" to confirm your selections.

            To begin working on the Liquid crystal display, you must first verify its I2C address in the python console.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            sudo i2cdetect -y 1

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            The attached I2C device has address 27, as shown here.

            Barcode scanner configuration

            This came together with my barcode scanner. This card will allow us to quickly and easily alter the device's default settings and change the Data rate, Trigger mode, and more.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Make sure the method of data transmission is USB transmission before we begin programming. The reading mode should be set to Triggering, and the Suffix should be C.R.*. The end of a data set information is always signaled by an enter command when a carriage return is used.

            Code Reading with a Raspberry Pi

            Now, access the Pi's command prompt and type pip install RPI LCD to get the software package downloaded and set up. My laptop and Raspberry Pi share the same wifi network; thus, I can control it from here using a V.N.C. viewer. In addition, I used THONNY and Python 3.7.3 to write the Code. Please refer to the schedule at the end of this article for more details.

            Since we'll be using Delay to show the material on the LCD, we're starting the Program by importing the Sleep object from time. Then, the RPI LCD object, used for integrating the 16 * 2 display, will be imported.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            from time import sleep

            from rpi_lcd import LCD

            The number of objects scanned up until the loop's execution is kept in an item count variable. At first, it is set to 0 so that no invalid values are stored. For the same reason, the scanned Barcode will be saved in a variable called score, which will initially be empty.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            item_count=0   

            scode="" 

            LCD.text("Scan the Code... ", 1)   

            As long as the while loop is active, scanning will continue indefinitely unless the controller is reset. Terminal input is required for this loop's input() function, and the resulting String will be saved in the variable scope. Then, we'll get it shown on an LCD screen via printing.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            While 1:   

                scode= str(input())  

                LCD.text("Scanned Barcode is", 1)

                LCD.text(code,2)  

                sleep(2)   

                LCD.text("   Item Added", 1)

                sleep(2)

                item_count=item_count+1   

                IC=str(item_count)   

                LCD.text("  Total Item = ",1)

                LCD.text(IC,2) 

                sleep(1)

            The initial value of the item count was 0; however, it will be increased while the loop is executed. The item count is currently set to 1. We'll use typecasting to change the item count value from an integer to a string so that it can be shown on the LCD screen through the LCD.text() function. The LCD screen will then reflect that information.

            Viewing the accompanying illustrations may help clarify matters. After two seconds, the LCD will show the total number of items scanned rather than the scanned Barcode itself (which will remain on the screen for two seconds).

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Complete Code

            from time import sleep

            from rpi_lcd import LCD

            LCD = LCD() 

            item_count=0   

            scode="" 

            LCD.text("Scan the Code... ", 1)   

            while 1:   

                scode= str(input()) 

                LCD.text("Scanned Barcode is", 1)

                LCD.text(code,2)  

                sleep(2)   #Delay of 2 seconds

                LCD.text("   Item Added", 1)

                sleep(2)

                item_count=item_count+1   

                IC=str(item_count)  

                LCD.text("  Total Item = ",1)

                LCD.text(IC,2) 

                sleep(1)

            Assembling a shopping basket with a scanner: how to do it!

            Electrical Schematic of a High-Tech Shopping Cart

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            The following illustration depicts the wiring for connecting a barcode reader, thermal printers, and Liquid crystal display to a Raspberry Pi 4. The following table shows the relationships between these terms for your convenience.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4
            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Smart Shopping Cart Programming

            Now that we have all the parts hooked up, we can begin writing the Program for the intelligent cart. Before moving further, let's review the ideas we've covered in our prior assignments. I am compiling a summary of the essential takeaways from the preceding part.

            • Turn on the 12c port to connect the 20X4 alphanumeric LCD to the computer and the serial port to connect the thermal printer.

            • Adapt your USB barcode scanner to your specific needs.

            • Make a Google doc and use it with your Google Apps account.

            • Use as few commands as possible to test all of the peripherals.

            • Putting in the Necessary Libraries

            • Python ESCPOS

            • Python RPLCD

            • Python Gspread


            Complete Code

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            import spread

            from time import sleep

            from RPLCD.i2c import CharLCD

            LCD = CharLCD('PCF8574', 0x27)

            from escpos.printer import Serial

            from DateTime import DateTime

            now = DateTime.now()

            dt_string = now.strftime("%b/%d/%Y %H:%M:%S")

            lcd.cursor_pos = (0, 0)

            LCD.write_string("Initialising...")

            #locating the spreadsheet JSON file

            GC = spread.service_account(filename='/home/pi/Ali Proj/Proj 4 Shopping Cart with Thermal Printer/Shopping Cart on 20_4 LCD/shop-data-thermal-585dc7bffa1f.json')

            #sheet name is to be passed

            sh = GC.open("Shop Data for Thermal")

            worksheet=sh.get_worksheet(0)


            The preceding Code includes imports for all required libraries, including spread for the Google Sheets Application programming interface, time for wait or rest functions, RPLCD for 20X4 Liquid crystal display, escpos for serially controlling the Heated Printer, and date and Time for retrieving the current date.

            Using my Google account, I made a spreadsheet titled "Shop Data for Thermal." Please create your own and give it any name you wish. Please see the G spread docs for information on setting up your Google Spreadsheet and JSON for your Google service account.

            Next, we'll launch Sheet1 by invoking get worksheet(0) and loading it into the sh editor.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            """ 9600 Baud, 8N1, Flow Control Enabled """

            p = Serial(devfile='/dev/serial0',

                       baudrate=9600,

                       bytesize=8,

                       parity='N',

                       stopbits=1,

                       timeout=1.00,

                       dsrdtr=True)

            This Code will be used to set up and initialize the serial port based on the parameters provided.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            count=0

            item_cost=0

            totalCost=0

            SNo=0

            scode=""

            qty=1

            scodePrev=0

            item_name=""

            entryF=[]

            p.set(

                align="center",

                font="a",

                width=1,

                height=1, 

                )

            The necessary variables will now be initialized to " " or " 0 " to prevent any invalid data from being stored in them. In addition, the set() function will be used to establish the thermal printer's default printing settings.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            def print_receipt():

                p.text("\n")

                p.set(

                        align="center",

                        font="a",

                        width=1,

                        height=1,   

                    )

                #Printing the image

                p.image("/home/pi/Ali Proj/Proj 3 Interfacing thermal printer with pi/CD_new_Logo_black.png",impl="bitImageColumn")

                #printing the initial data

                p.set(width=2,

                     height=2,

                     align="center",)

                p.text(" ===============\n")

                p.text("Tax Invoice\n")

                p.text(" ===============\n")

                p.set(width=1,

                     height=1,

                     align="left",)

                p.text("CIRCUIT DIGEST\n")

                p.text("AIRPORT ROAD\n")

                p.text("LOCATION : JAIPUR\n")

                p.text("TEL : 0141222585\n")

                p.text("GSTIN : 08AAMFT88558855\n")

                p.text("Bill No. : \n\n")

                p.text("DATE : ")

                p.text(dt_string)

                p.text("\n")

                p.text("CASHIER : \n")

                p.text(" ===========================\n")

                p.text("S.No     ITEM   QTY   PRICE\n")

                p.text(" ------------------------------\n")

                print(text_F)

                p.text(text_F)

                p.text(" -------------------------------\n")

                p.set(

                        # underline=0,

                        align="right",

                     )

                p.text("     SUBTOTAL:  ")

                p.text(totalCostS)

                p.text("\n")         

                p.text("     DISCOUNT:  0\n")

                p.text("     VAT @ 0%: 0\n")

                p.text(" ===========================\n")

                p.set(align="center", 

                   )

                p.text("    BILL TOTAL: ")

                p.text(totalCostS)

                p.text("\n")

                p.text(" --------------------------\n")

                p.text("THANK YOU\n")   

                p.set(width=2,

                     height=2,

                     align="center",)

                p.text(" ===============\n")

                p.text("Please scan\nto Pay\n")

                p.text(" ===============\n")

                p.set(

                        align="center",

                        font="a",

                        width=1,

                        height=1,

                        density=2,

                        invert=0,

                        smooth=False,

                        flip=False,      

                    )

                p.qr("9509957951@ybl",native=True,size=12)

                p.text("\n")

                p.barcode('123456', 'CODE39')

                #if your printer has paper cutting facility, then you can use this function

                p.cut()

                print("printing done")

            With the Code above, we can quickly generate a method to output the total due. The invoice's format is also determined in the same procedure. A '123456' barcode can be printed using the p.barcode () method.

            Suppose the detected Barcode does not match the database sheet. In that case, a message will be displayed on the terminal's Liquid crystal display and in the terminal's memory reading "Unknown Barcode" or "Item Not Registered," respectively, using the try/except logic. You can view this under the following line of Code.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            lcd.cursor_pos = (0, 0)

            LCD.write_string('Please Scan...')

            while 1:

                try:

                    scode=input("Scan the barcode")      

                    if scode=="8906128542687": #Bill Printing Barcode pasted on the Thermal Printer

                        print("done shopping ")

                        LCD.clear()

                        print(*entryF)

                        print("in string")

                        print(len(entryF))

                        text_F=" "

                        for i in range(0,len(entryF)):

                            text_F=text_F+entryF[i]

                            i=i+1          

                        lcd.cursor_pos = (0, 0)

                        lcd.write_string("Thanks for Shopping")         

                        lcd.cursor_pos = (1, 7)

                        lcd.write_string("With Us")          

                        lcd.cursor_pos = (3, 0)

                        lcd.write_string("Printing Invoice...")

                        print_receipt()

                    else:

                        cell=worksheet.find(code)

                        print("found on R%sC%s"%(cell.row,cell.col))

                        item_cost = worksheet.cell(cell.row, cell.col+2).value

                        item_name = worksheet.cell(cell.row, cell.col+1).value

                        lcd.clear()

                        SNo=SNo+1   

                        entry = [SNo,item_name,qty,item_cost]

                        entryS=str(entry)+'\n'

                        print("New Item ",*entry)

                        lcd.cursor_pos = (0, 2)

                        LCD.write_string(str(SNo))

                        lcd.cursor_pos = (0, 5)

                        LCD.write_string("Item(s) added")          

                        lcd.cursor_pos = (1, 1)

                        LCD.write_string(item_name)          

                        lcd.cursor_pos = (2, 5)

                        LCD.write_string("of Rs.")

                        lcd.cursor_pos = (2, 11)

                        LCD.write_string(item_cost)           

                        item_cost=int(item_cost)

                        totalCost=item_cost+totalCost           

                        lcd.cursor_pos = (3, 4)

                        LCD.write_string("Cart Total")           

                        lcd.cursor_pos = (3, 15)

                        lcd.write_string(str(totalCost))           

                        entryF.append(entryS)   #adding entry in Final Buffer

                        sleep(2)           

                except:

                    print("Unknown Barcode or Item Not Registered")

                    LCD.clear()

                    lcd.cursor_pos = (0, 0)

                    LCD.write_string("Item Not Found...")

                    lcd.cursor_pos = (2, 0)

                    LCD.write_string("Scan Again...")

                    sleep(2)

            Cart Usage Guide

            1. First, you pick out the product you want and scan its Barcode.

            2. Verify the accuracy of the LCD.

            3. Scan something else and perform the same thing

            4. Once you have everything you need, scan the Barcode affixed to the thermal printer to initiate the billing process.

            5. Collect the bill and use the Q.R. code to pay using a U.P.I. account.

            When scanning, how do scanners deal with things in motion?

            This is made more difficult because the Barcode is frequently in motion during scanning s or may be so distant from the sensor that the Barcode is beyond the focus. Thus, the scanner's output is not a clean set of easily distinguishable black and white lines but a muddy smear composed of more nebulous grey tones. Edge detection is one type of computer method that may convert these fuzzy patterns into precise barcodes by looking for sharp contrasts in brightness to indicate the transition from zero to one or vice versa. Look into the technical references listed below if you're interested in learning more about the inner workings of these algorithms.

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Practical Uses in the Business World

            • Managing libraries is a specialty of library automation.

            Each book is equipped with a barcode that the system uses to keep track of its current availability. The barcode scanner provides the librarian with up-to-date information on the books that have been checked out. Books can be checked automatically, allowing for less workforce.

            • Maintaining a stock-taking system.

            Barcodes provide for more efficient product recognition and data deployment. Manually entering data at the front end raises the risk of human error, which can cause delays and financial losses. But the barcode scanner is highly accurate and rarely makes mistakes when processing product orders. Because the data is automatically recorded with each sale, this simplifies stock-taking by cutting down on time spent manually looking for items.

            • Reservations for travel

            The billing procedure can be lengthy and frustrating at movie theaters, motels, and other establishments. Bills generated through electronic billing systems include a barcode or Q.R. code that can be easily decoded using a scanner kept by the relevant authorities.

            • Billing office

            It lessens the likelihood of mistakes occurring during billing's manual data entry process. Barcode scanners have many applications in billing departments, including speedy data gathering and the ability to check pricing and promotions.

            • For Office Biometrics

            A company's employees are obligated daily to record their attendance and clock in/out times. Scan the Barcode on their I.D. cards instead of having them manually enter their information.

            Why Is It Useful for Businesses to Have Barcode Scanners?

            How to Interface USB Barcode Scanner with Raspberry Pi 4, USB Barcode Scanner with Raspberry Pi 4, barcode reader with RPi4, Rpi4 barcode reader, usb barcode reader RPi4

            Barcode scanners will be cost-effective because they may be set up with a smaller initial investment.

            The barcode reader is more straightforward to set up than the alternatives since its basic programming makes it more user-friendly. Barcodes save time by eliminating the need for humans to key in information.

            Human intervention will cause less of a shift in the value. As a result, it facilitates the transfer of funds more quickly and lessens the need to carry cash around physically. The majority of data sets are regularly updated. Innovation and technological progress guarantee progress.

            Applications of Barcode Readers in Manufacturing

            1. For use in the production and logistics sectors

            Using a barcode scanner, keeping tabs on company property is possible. A quick snapshot of the warehouse's inventory is provided. Raw materials utilized in production must also be sent to different markets. Consequently, there can be no mistakes in the labeling. As a result, it speeds up transactions and generates more money.

            Reducing the likelihood of making mistakes and responding quickly to consumer requests are critical to growing the business. Time constraints can be met with more efficiency when both incoming and leaving shipments are monitored regularly. As industrial processes become increasingly mechanized, the cost of human labor declines.

            1. On campus

            The main features include tracking fixed assets like computers, lab equipment, machinery, etc. Teachers or employees responsible for the safety of their assets, such as the craft, can keep tabs on them with this feature. Barcode scanning keeps track of books and supplies that have gone missing in a library. A student's entrance and exit from the library can be quickly and accurately recorded using barcode scanners.

            1. Industry of Health Care

            Surgical supplies, patient specimens, pharmaceuticals, etc., must be tracked. Barcodes on patients' wrists allow doctors to quickly and readily verify that their care is being administered properly. These barcodes make it simple to record and monitor the previous distribution of prescriptions.

            1. Governmental and Military Affairs

            They take great care to ensure that sensitive information about the country does not leak. Problems with data recording or disclosure could lead to legal trouble. Official data can be kept safe with the use of barcodes.

            1. Logistics

            A worker working in logistics could be accountable for juggling multiple products at once, which increases the likelihood of making mistakes and sending out the wrong items. A barcode scanner can be used to automate this process with little room for error.

            1. The Retail Industry

            Including a barcode on each item will speed up the billing process by eliminating the need to enter each purchase manually. It will also make it simpler to view stock levels. Theft can be prevented by installing a barcode-based sensor on the exit door. In addition, this technology makes it easy to track the discounts applied to each item and ensure that they are still valid, reducing the need for human labor.

            Conclusion

            Barcode scanners prove essential for managing a wide variety of administrative processes. It's a low-cost alternative to other technologies that can efficiently manage more formation. In addition, it facilitates reductions in inventory expenses. It appears that barcode scanning technology will continue to evolve into the future. Therefore, barcode scanning technology will continue to be used until a more adaptable or complex technology is developed. We have also seen how to construct our own "Smart Shopping Cart," complete with a barcode scanner to read the item's Barcode, retrieve the prices from the databases, show the information of the scanned object on an LCD for reference, and print the invoice using a thermal receipt printer. The same infrastructure might serve several purposes. In the following tutorial, we learn how to build a Wireless R.F. Communication using the nRF24L01 Module in pi 4