Storing data with a barcode scanner

Bibeto
4 min readMay 16, 2021

Github repository: https://github.com/Bibeto/small_version

Today, I m going to present to you a project that I worked on last summer.

The problem I was trying to solve was keeping a database of the components existent in a SMD chariot. The latter can be seen in the image below :

The regular employees that put those disks of SMD components in the manufacturing machines sometimes make mistakes that could miss up with the factory’s logistics in work (putting a disk in the wrong place, not putting enough disks, etc…).

My approach to solve this issue was this idea. Those SMD disks, they have unique barcode references for each component. So every time they put or take a disk from the chariot they scan it.

Thus we can keep track of the disks’ places.

The final product looks somewhat like this :

Expected something fancy 😅 ? These are my baby footsteps that I m proud of 😤

Anyways let’s go deeper into the technical side

In this project I had :

1 - an excel/csv file as input for the list of components

2 - a barcode reference for the components

Decoding data from the barcode reader

The barcode scanner was a complete ambiguity. I had no idea what the USB was, I have an idea about UART, I2C , SPI… and all those fancy name protocols but the USB was a complete mystery .

The USB (Universal Serial Bus) is so “UNIVERSAL” but I was an utter Noobie in it (see what I did there 😅)

That’s the best joke I could muster, give me a break 😗

Anyways, I did my research and found out it’s very COMPLEX to say the least. I don’t mean the hard way in which you spend many nights then you finally crack that hard puzzle. I mean the kind of hard where it’s a BIG ocean that encompasses MANY devices. Every device that has USB has a “device class”. You can see it in detail here https://www.yumpu.com/en/document/read/41825071/usb-in-a-nutshell-pdf

And lucky me 🙄 my barcode scanner was a device class 0x00 (I figured it out with WireShark).

This is just an example (not the barcode scanner).

In a nutshell, there’s no module that magically converts USB to serial for these kind of devices.

To solve this issue I chose to use Raspberry PI since it already has a preinstalled driver that understands these devices and this was the main reason why I opted to use this kind of development board despite its high power consumption compared to other boards like Arduino, STM32 boards…

UI implementation using Tkinter

One of my first options were to use Tkinter since it’s already cross-platform and it’s based on Python that I already had experience working with.

Another advantage was the ability to develop and test the application directly on my windows machine before deploying it to the Raspberry Pi.

You can see in the image below the final result:

And maybe an important detail to share was the dynamic positioning. An example of dynamic positioning here :

A little bit of code to demonstrate how it works :

All lies within that “relx” and “rely” that expands or shrinks proportionally to the Main_Frame’s size

I hope this article came to be of some help to someone out there and I’m open to all criticism for I am still and will always be learning 🧐

--

--