Barcode Scanners Are Awesome

How I Made a Pantry Inventory with a Barcode Scanner and Google Sheets


Like usual,


My My dream is to write technical blogs the way food bloggers share recipes. This is more of a adventure than a practical learning experience (like LinkedIn!)


prepare for yapping (but sometimes its funny!)


My hoarding problem

I pick up a lot of shit that I don't need. I'm like a middle-aged dad with a trunk full of 2x4s, except mine are tech parts. I just can't not do it.


Instead of the hardware store being the source for me, it's typically goodwill and used electronic stores.


This sometimes works out in my friends' favor though, as I often already have the part they're looking for.


Anyways, today's metaphorical 2x4 was a receipt printer.


The (user) problem

Since I don't pay rent, I do a lot of problem-solving for my parents. In exchange, I'm the favorite (and only) child. (And I don't get kicked out, win-win!)


One of the most boring jobs is taking inventory of a food pantry. Nobody wants to count cans with a clipboard. so why not make it more engaging with a barcode scanner?


problem: There isn't that much great inventory software for (smaller) pantries. This closet doesn't need industrial warehouse managment software for cans. And I most definitely didn't want to write my own. (I have three days until I move to my college dorm and I've barely packed)


You know whats easy? Google Sheets.


Googling Sheets

I made a sheet. Maybe I should write a LinkedIn skills endorsment for myself after this, but for now I'll speedrun my tour


Enter sheet page You enter barcodes scanned here. There are no cool formulas on this page


Summary Sheet page The page that shows Sums for what you've scanned. There are two cool formulas.


Cool Formula #1

=IF(COUNTA(Enter!A:A)=0, 
   {"Barcode","Count"}, 
   QUERY(Enter!A:A, "select A, count(A) where A is not null group by A order by count(A) desc label A 'Barcode', count(A) 'Count'", 1)
)

We query the Enter sheet page for counts of each unique barcode. The outer IF fixes a display quirk when the sheet is empty


Cool Formula #2

=ARRAYFORMULA(IF(A2:A="",,VLOOKUP(A2:A, Lookup!A:B, 2, FALSE)))

This looks up the barcode in the third table. I love VLOOKUP, its my second favorite function after QUERY, but still a close second. The third table is just key-value pair mapping barcode -> text (write what the barcode corresponds to in that text)


Lookup Page Lookup table! Not thrilling, but it works.


This was all way better than writing bespoke software to solve a very specific problem (again... https://github.com/cghs-hackclub/ClassCall ).


The barcode scanner

Great. now we have a inventory system that can rival exel documents with user logins and passwords.1


The only problem: My barcode scanner was pressing tab after each scan.


For those who don’t know, barcode scanners are glorified keyboards. They just type the barcode after scanning it. Pretty neat.


Of course I did what any slightly-questionable developer would do: I asked ChatGPT. It responded with an abundance of em-dashes:


You’ll need to reconfigure the scanner: Check the manual for your model (every scanner has a programming guide with special barcodes you scan to change settings).


There is no way I can represent the awe I was in when I read these words, but lets just say my jaw was on the floor.


THERE ARE SPECIAL BARCODES TO PROGRAM THE BARCODE SCANNERS


It actually makes a ton of sense intuitively. its a input tool, you program it with input. I'm just so used to using jumpers and dip switches to program stuff, So this just felt next level 2


Anyways, back to secret barcodes.


The first documentation I found was this Datalogic sheet describing F-key barcodes.


FKeys barcode documentation


Special barcodes that did things like,


  • Press ✨Tab✨
  • Or other lame FN Keys
  • and other stuff too

This is just neat by itself, that special barcodes to do special things.


Then I found better docs.


Scanner prefixes and suffixes

Scanners have prefixes and suffixes. Think prefix/base/suffix like words (if this still doesn't make sense heres a worksheet). You can set them with special barcodes.


WARNING: NERD SHIT AHEAD! SKIP IF YOU DON'T CARE

changing prefix/suffix happens something like this


  1. Scan to enter programming mode
  2. Scan set suffix command barcode
  3. look at awesome hex table to figure out the hex value of the suffix you want
  4. scan the corresponding barcodes to enter the hex values barcode for each hex charater
  5. scan end to terminate string
  6. scan save and exit

Cable length (Thanks past Codaea!)

Problem: cable too short. need long cable.


You might say, "Go back to goodwill and buy one of the 30 wireless ones that they have lying around" and I would reply,


"Past stockpile me to the rescue!"


USB extension cable over Cat5. up to 150 feet! extension cable img


I'm honestly suprised that it can do power over such a long distance, color me suprised.


F*ck you cole. (Epologue)

I call my freind exitedly, after all of my cool puzzle solving with the scanner, (that includes pretty much all the stuff I discovered above) and he just says,


"Thats how coupons work. I already knew that."


Okay Cole, Fuck you. I'm glad that pickle leaked over your burger the yesterday. That shit was cool. You're just mad you didn't get to do it. 3


Moral of the story

  1. Don’t tell friends about your cool configuration trick if they don’t think it’s cool.
  2. Email me instead, I don't have anything better to do. tell me about your projects.

Footnotes

  1. Sorry, didn’t mean to send stray shade at some of you.
  2. Actually thats not true, my thermal printer prints out its settings "configuration page" as you change settings. It's pretty fucking awesome.
  3. Unfortunately we are still friends so don't go canceling me on twitter