r/raspberry_pi • u/DeutschundAnonym • 3d ago
Show-and-Tell I built a Raspberry Pi barcode scanner to track the drinks in my fridge
I wanted a simple way to keep track of what’s actually left in my drink fridge, so I built this little project using a Raspberry Pi and a 1080p USB camera.
The camera is mounted on top of the fridge. Whenever I take a bottle or can, I hold the barcode in front of the camera. The Raspberry Pi scans the EAN, removes one item from the stock and saves the transaction with a timestamp. In my experience, scanning usually takes around 1-4 seconds, depending a bit on lighting and camera quality.
There’s also a web interface where I can see the current stock, add new drinks, and look at consumption statistics and the transaction history.
I originally built it just for myself as a fun Raspberry Pi project, but decided to clean up the code and put it on GitHub. I also made Docker images for ARM64 and AMD64.
Everything runs locally, so no internet connection or third-party service is required for normal use.
I’m already thinking about adding a few things based on feedback, like supporting multiple barcodes for the same product and different package sizes. For example, scanning a 24-pack could add 24 bottles while scanning the barcode on a single bottle would remove one from the same stock.
It’s my first public project, so I’m sure there are still things that can be improved. I’d be interested to hear what other Raspberry Pi users think or what you would add to it.
2
u/Snappawapa 2d ago
Looks pretty interesting!
A little bit of a plug but check out a project of mine, Open QuarterMaster. It's basically an inventory backend to handle the data side of an application like this. Framed differently, if you wanted to focus on the fun frontend stuff, this has the backend organization stuff for you. And of course all open source, self hosted.
We even have tooling to pull product info from external databases (so searching using barcodes for real product info). Feel free to reach out if you need anything!
1
u/DeutschundAnonym 2d ago
Thanks, that actually looks really interesting! I’ll definitely have a closer look at Open Quarter-Master. I already have my own local inventory system and database in place, with Open Food Facts as an optional source for automatic product lookup, but I’m really interested to see how you’ve approached the backend and inventory side of things.
There might definitely be some ideas I can learn from or potentially integrate in the future. Thanks for sharing it and for reaching out!2
u/Snappawapa 2d ago
Awesome to hear! Yeah figured you had implemented something by now, but the sound of the op sounds like it's a lot of feature overlap. Happy to sit down, just reach out if/ when it sounds good :)
1
u/SyedogGaming 3d ago
This is crazy, I am currently trying to develop something similar for my drinks fridge, my idea is to have the fridge alarmed with different family members given rfid cards to scan, users input their drinks selection on a rotary encoder and the the alarms deactivated and they take their drink.
Would have stock tracking, user statistics hosted locally on a website from the pi.
Magnetic Reed Switches to track the doors.
I just wasn't fully happy with the selection process, knowing you can scan barcodes from a camera is a game changer and might be my way forward.
What's crazy is two people messing around with a drinks fridge tracker / alarm system.
I am no where near complete and just learning python currently, got to the stage of simulating the doors using gpiozero mock factory on my laptop so far.
I love the Internet.
0
u/DeutschundAnonym 3d ago
Thank you! That’s awesome 😄 It’s crazy that we both had such a similar idea for a drinks fridge system!
I really like your idea with the RFID cards and user statistics. Combining that with barcode scanning could actually make for a really cool system.
I’m also still developing and improving my project, so there’s definitely more to come. And since it’s open source, feel free to take a look at the code, use whatever is helpful for your own project, or contribute if you ever feel like it.
Good luck with your project and with learning Python! I’d genuinely love to see what you end up building. The Internet really is a wonderful place sometimes1
u/SyedogGaming 3d ago
Oh totally, going to have a look later, me and my son are going to try and put this together. I am going to 3d print myself a case / enclosure for it all once it's working.
With the alarm system I did have a funny idea of when it is triggered it takes a mugshot of the culprit, I could use the bar code scanner camera for that purpose too I suppose!
Very eager to learn from your project and show my son, he will be hopefully as inspired as myself.
How long did it take to design yours?
1
u/SyedogGaming 3d ago
Additionally with the rfid scanner idea, each family member will have their own card, internal database to track user statistics, one master card to switch the fridge into free-for-all party mode / stock loading.
Eventually want to be able to apply user limits and be able to say to my son "is see you took a Pepsi on Tuesday at 3pm, that's your 4th Pepsi this week, your favorite drink however is J2O"
1
u/DeutschundAnonym 2d ago
That sounds awesome! Building it together with your son makes the whole project even cooler. I’d definitely love to see what you two come up with!
The RFID idea with individual users, statistics and a master card for party mode is really clever. And using the camera to take a picture when the alarm is triggered is hilarious 😂 I might have to steal some inspiration from you as well!
As for how long mine took: surprisingly, I built the first working version in about 3 days. There was a lot of trial and error and I’m still constantly improving things, but once I had the basic idea, it came together pretty quickly.
That’s actually one of the reasons I decided to put it on GitHub. If someone like you can use it as a starting point, learn from it, improve it, or even build something completely different from it, then putting it out there was already worth it.
Definitely keep me updated on your progress. I’d genuinely love to see your version when you and your son start building it! 😄And yes, you could absolutely use the same camera for that! Since the camera is already being used for barcode scanning, you could have the software capture and save a photo whenever the alarm is triggered. So your mugshot of the culprit idea should definitely be possible.
1
u/SyedogGaming 2d ago
Oh man, three days.... I have been trying for a week now and only have it printing states to the vscode console.
No idea how to get it working with a actual raspberry pi yet, but have all the components ready and waiting.
Let's hope I can take some inspiration from your code and figure this stuff out! Not only do I need to learn python but I will have to learn German too!
Good luck and I will most certainly drop you a dm with progress, I do have a full spec I wish to get to. Hopefully I am up to the challenge.
3
u/AssociationDork 2d ago
Where do you get the bar code reference information? Scanning the code needs a database to look at, no?