Read from barcode scanner, generate shopping list?


19 posts
by jonasbegood » Sun Jan 26, 2014 1:43 am
I am working om an idea to use the RaspPi as a mealplanner/shopping list generator.

Basically the idea is to have a barcode scanner set up at the kitchen (either wireless or directly to USB). We would use this to read barcodes from grocery when they are empty.

The Pi would have to have a active script to listen for HID inputs. When the Pi receives a input it would post this to a file or database.

Once a week (on the shopping day) the Pi would then use this file to look up a database and post a quantity (+1) for each of the barcodes scanned into the same database.

This database would contain all your barcodes and connected products (which you would have set up manually and be able to edit/add items, either through web, phpadmin etc).

Then a script should count all values (greater than 1) and generate a shopping list with the connected products, and use this to send an email to your inbox or to Evernote. The clear all the values, the file on Pi and prepare for next weeks shopping.

To use this as a meal planner you could generate and print your own barcodes, make a shopping list for a specific meal and connect each ingredient to the barcode in the database. Then you make a fancy book with your favorite meals and barcodes, scan them and have your whole weeks shopping list sent to mail.

I have done some smaller projects with the Pi before, but this goes out of my knowledge so I would really love some input.
Posts: 2
Joined: Sun Jan 26, 2014 1:05 am
by scruss » Sun Jan 26, 2014 2:59 am
If you can still find a USB CueCat scanner — and a couple of surplus stores near me still have them — they work as USB keyboards. You will have to “declaw” it, or it outputs encrypted data.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
User avatar
Posts: 284
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
by Richard-TX » Sun Jan 26, 2014 3:03 am
Cue-Cat. Yikes. What a disaster that was. It is best described as a dot-bomb.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 936
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by ame » Sun Jan 26, 2014 3:13 am
jonasbegood wrote:I have done some smaller projects with the Pi before, but this goes out of my knowledge so I would really love some input.


It sounds like a very interesting project, and very do-able on the Pi.

Your message is like reading a design document. You have already identified what you want to do, and how you want to do it, and some potential problems to overcome. If you have already done some small projects on the Pi, then you should be able to do this. Treat it as several small projects.

If you are worried about HID input from the barcode reader, then don't be. The barcode readers look like keyboards to the OS. When you scan a barcode it appears as if it was being typed on a keyboard. So, you can test this part with a regular keyboard- just type in the barcode and see if the rest of the software does as it is supposed to.
Posts: 541
Joined: Sat Aug 18, 2012 1:21 am
Location: Japan
by Richard-TX » Sun Jan 26, 2014 4:40 am
The biggest hurtle is the barcode to product database. It is pretty hard to find a bottle of 017892137
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 936
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by ame » Sun Jan 26, 2014 4:58 am
Richard-TX wrote:The biggest hurtle is the barcode to product database. It is pretty hard to find a bottle of 017892137


Not really. You probably buy the same things regularly, so you can make your own database of barcodes.

Or you could try this:
http://www.product-open-data.com/

Or this:
http://www.upcdatabase.com/

Or this:
http://eandata.com/
Posts: 541
Joined: Sat Aug 18, 2012 1:21 am
Location: Japan
by jonasbegood » Sun Jan 26, 2014 12:25 pm
Thank you guys for the answers. My earlier project has been a rasppi media center, and a raspi torrent seedbox conncted to a NAS. On both of this project I had great resources. I am very confident that this project is doable, but I still need some tips for specific tasks. I've listed the workflow of this project, with specific questions to each and hope some of you can point me in the right direction.

Scanner to PI - decode the HID:
I've already checked that most barcode scanners will sendt it directly to the pi as keyboard.
The HID input can then be changed to the correct number by doing something like this.

http://www.raspberrypi.org/forums/viewt ... 45&t=55100

Database
I've been reading about SQLite, do you guys think this database is suitable for this project? SQLite can be runned locally on the rasppi. I am open to other suggestions so please feel free.

Save the inputs to the end of a specific textfile or directly to the database
The input received should always be saved to a specific local text file or directly to the database. I think the best thing would have a script that runs in the background at all times, and when it receives input it would search the database to match the input, then post a +1 in the right table. How would you go forward to create a listen-script like this?

Generate shopping list
I think this task is rather easy in theory. We would have to create a script which runs on a specific time on a specific day of the week. The script would search the database for all quantity changes and post the connected product to a file/or generate a email with all changes. Again, scripts are my biggest problem for this tasks.

E-mail the list to Evernote
To send the lists to a specific notebook, It can be done very easy with the subject. If the subject is in example: @Shopping-list.
Then the list from the database would be posted in the right notebook each time.
Posts: 2
Joined: Sun Jan 26, 2014 1:05 am
by Richard-TX » Sun Jan 26, 2014 2:25 pm
When it comes to databases there are a few choices.

For simple key-data pairs like a lookup table (UPC -> description), there is nothing faster than gdbm. A single record retrieval in a billion block database takes at most 3 file system accesses. Usually it gets done in two. Originally written at AT&T for a chess program, I have found nothing faster. The downside is that it is a c library and all of your routines like "load database", "dump database", "retrieve record", and "add record" have to be written. A good programmer can bang that out in a hour. I can usually do that in an evening.

If you want a relational database with a plurality of fields per record, then my choice would be mysql.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 936
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by DougieLawson » Sun Jan 26, 2014 2:38 pm
SQLite3 is less of a monster than MySQL.
Hacker on ZX80 and Microtan65
Unemployed mainframe database specialist.
Linux hacker since 1995.
RPi owner since 2012.
Twitter: @DougieLawson

Gaffer tape is "The Force", it has a dark side and a light side and it holds the Universe together.
User avatar
Posts: 3603
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by scruss » Sun Jan 26, 2014 5:41 pm
DougieLawson wrote:SQLite3 is less of a monster than MySQL.


Yes, seconding SQLite. It's robust, fast, easy to use. I can't think of a project you could host on a Raspberry Pi that would overwhelm it. It's supported by every language you will ever use. The whole database lives in a single file: no server, no messing about with sockets. It's used as the data store by iOS, Android and Mozilla. I've been using it (well, SQLite) for more than 10 years. Purists will decry its lack of data types, but they get in the way of getting stuff done.

Richard-TX wrote:Cue-Cat. Yikes. What a disaster that was. It is best described as a dot-bomb.


Maybe for the company and its vulture venture capitalists, but the surplus CueCats have brought cheap bar-code handling to community libraries and individuals worldwide. So, yay failure!

Note to the OP: if you use a CueCat, I think they draw a fairly high current. You may need to use a USB hub.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
User avatar
Posts: 284
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
by marked » Tue Jan 28, 2014 1:56 pm
how about using a webcam and zxing to obtain the barcode, lookup the price, then re-shoot to get a pic of the product. Take a walk down the supermarket and match aisle to products, then print the walking order. If you include previous prices and some products have separate price codes (such as fresh meats by weight).

Bonus points for matching instore positioning to product :-)

Mega bonus for creating meal recipes on the fly using your phone, ie. as you wander the aisles it can suggest meals if you get friends dropping by, redo a meal plan because there is a better cut of meat is 1/2 price but would take an extra half-hour to cook, they have completely run out of a particular fresh veg, etc.
Posts: 54
Joined: Fri Jul 29, 2011 4:25 pm
by Richard-TX » Tue Jan 28, 2014 2:59 pm
scruss wrote:Maybe for the company and its vulture venture capitalists, but the surplus CueCats have brought cheap bar-code handling to community libraries and individuals worldwide. So, yay failure!

Note to the OP: if you use a CueCat, I think they draw a fairly high current. You may need to use a USB hub.


I have not seen a cuecat in years. I haven't even heard of anyone seeing one. Not in a library or anywhere else for that matter.

Have you tried to use one? The error rates compared to a real barcode scanner are horrible. The output is lamely encrypted too but what do you want for free?

I threw all of the ones I had in the trash long before the company went belly-up because of the error rate. I suspect that many others did the same thing.

I have worked with many different types of barcode scanners but the Cuecat was the worst.

I would not waste any time locating one. Find a cordless scanner that has memory. That would be far better than any cuecat.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 936
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by Richard-TX » Tue Jan 28, 2014 3:10 pm
One more thing.

If you are out of chicken soup, what are you going to use to scan the bar code? All of the empty cans/packets are in the trash. So that leaves sheets of paper with the barcodes all printed out as a solution. By the time the item is found on the multiple sheets of paper and scanned, I could have written down "Chick. soup" as well as the next 3+ items.

What is needed is an automatic touchless scanner. Remove the item from the pantry shelf and the computer knows it.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 936
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by scruss » Wed Jan 29, 2014 12:45 am
Richard-TX wrote:Have you tried to use one? The error rates compared to a real barcode scanner are horrible.


Yup. I've had a couple; the old PS/2 one, and the slightly later USB one. Both weren't as fast or as accurate as a commercial scanning laser, but they worked, say 8 times out of 10. Many surplus stores have them; Active Surplus, for one.

The output is lamely encrypted too but what do you want for free?


That's what the “declawing” bit I mentioned was about. It removes the encryption, turning them into an HID keyboard.

Find a cordless scanner that has memory. That would be far better than any cuecat.


Yes, but that's $$$, probably too much for a home project.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
User avatar
Posts: 284
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
by FLYFISH TECHNOLOGIES » Wed Jan 29, 2014 12:55 am
Hi,
scruss wrote:
Richard-TX wrote:Find a cordless scanner that has memory. That would be far better than any cuecat.

Yes, but that's $$$, probably too much for a home project.

Use your smart phone as a barcode reader & data storage device.


Best wishes, Ivan Zilic.
Running out of GPIO pins?
Solution:
http://www.flyfish-tech.com/FF32
User avatar
Posts: 936
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
by cindy313 » Mon Feb 24, 2014 4:07 am
but where to find the barcode scanning app for the smartphones ? i found some but never used , how do you think ?
http://dottech.org/131684/android-review-neoreader-app/
Posts: 7
Joined: Thu Dec 05, 2013 2:12 am
by FLYFISH TECHNOLOGIES » Mon Feb 24, 2014 10:38 am
Hi,
cindy313 wrote:but where to find the barcode scanning app for the smartphones?

Google: "zxing android" or "zxing iOS app"


Best wishes, Ivan Zilic.
Running out of GPIO pins?
Solution:
http://www.flyfish-tech.com/FF32
User avatar
Posts: 936
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
by PiGraham » Mon Feb 24, 2014 12:37 pm
marked wrote:how about using a webcam and zxing to obtain the barcode, lookup the price, then re-shoot to get a pic of the product. Take a walk down the supermarket and match aisle to products, then print the walking order. If you include previous prices and some products have separate price codes (such as fresh meats by weight).

Bonus points for matching instore positioning to product :-)

Mega bonus for creating meal recipes on the fly using your phone, ie. as you wander the aisles it can suggest meals if you get friends dropping by, redo a meal plan because there is a better cut of meat is 1/2 price but would take an extra half-hour to cook, they have completely run out of a particular fresh veg, etc.


A camera-based barcode reader is a good option.

There is also http://zbar.sourceforge.net/ and others.
Why not use the PiCam?
Posts: 733
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville
by mnr_alfarsi » Wed Mar 12, 2014 4:38 pm
good idea ;)
Posts: 1
Joined: Sat Mar 08, 2014 4:51 pm