T³: IoT Smart Pantry (Part 1)

Let's use IoT to improve our diets!

Favorited Favorite 5

Counting calories sucks. And while it is important for weight loss, it's not the only thing that's important to nutrition. But if just keeping track of your calories is hard, keeping track of your total nutrition is next to impossible. This sure seems like the kind of problem that we could solve with a smart device, but first, let's outline what the problem actually is:

  • Nutrition facts are available but only on the food packaging, which isn't always handy.
  • Nutrition facts are given per suggested serving size, which may be too small or too large for a given meal.
  • Keeping track of all your macronutrient intake would require you to keep a journal, which you could do on your smartphone, but it's likely to take as much time as eating.
  • No system currently available can make suggestions from your pantry based on rounding out your daily nutrition.

What we need is some way of organizing foodstuffs that keeps track of how much has been consumed, not only by weight or volume, but by nutrient content. It would also be helpful to provide nutrition facts by weight instead of by serving. Some way of retrieving those facts without having to manually enter every nutrition facts label would also be ideal. So what we need is a food storage and retrieval system with a scale to weigh the foods and tell how much has been consumed. It would also be helpful if the system had access to a database of nutrition info.

So here's what I've come up with so far:

a picture of the complete smart pantry system in development

Okay, it looks like a piece of laboratory equipment mocked up in foamboard, but let me walk you through some of my decisions and maybe you can make some suggestions!

Plastic Jars

Almost every physical storage and retrieval problem is instantly simplified by the use of uniform containers. These plastic peanut butter jars are inexpensive, food safe, dishwasher-safe and... did I mention inexpensive? They also have a foam seal in the lid, which is a good place for hiding RFID tags, making the jars machine-sortable.

the plastic jar in question, as seen on the Amazon seller's product page.

Image courtesy of Amazon.com user J&S

Having the jars tagged with RFID also allows the carousel to keep track of jars that are removed and replaced, which would be helpful for using this as the front end of a larger storage and retrieval system.

Scale

closeup of the scale platform

To keep track of the weight of each jar in the system, I removed the load cell and platform from an inexpensive digital milligram scale. The load cell is connected to an OpenScale board that will translate the load cell values to real-world weight. I opted to take apart a digital scale instead of using a bare load cell because the scale already had a framework for mounting the cell and the platform together.

Barcode Reader

the shield from the front of the barcode scanner

I decided to take advantage of the Universal Product Code on food labels to identify the foodstuffs and retrieve the nutrition facts for them. The idea being that when a new food is registered into the system, the user will scan the barcode and then fill a jar with that food. The barcode reader will pass the UPC to a Raspberry Pi, which will make a call to the Nutritionix API to retrieve the food info. This info will be adjusted to match the amount of food measured on the scale.

Raspberry Pi

The brains of the operation will be a Raspberry Pi that drives an LCD, makes API calls and coordinates the other parts of the system using USB. I decided to connect everything using USB because all the parts I planned on using already speak serial.

devices connected using USB

The other advantage of using USB is that you can very quickly extend the system by adding USB hubs like I did in the photo above!

Theory of Operation

The idea is that a user can register a new food item into the system by scanning the UPC and placing a jar on the scale. The system will retrieve the nutrition info, and if that info is given by weight, it will begin scaling the values. If the info is given by volume, the entry will have to be calibrated by filling the jar completely with the food in question so the density can be calculated from a known volume (the jar) and used to scale the nutrition values. Once the system has scalable nutrition values, it will update the LCD in real time with the number of calories, fats, etc., that are in the jar as you fill it. When you've decided the serving is ready for storage, the system will store those values to the database entry for that jar's RFID and turn the carousel to usher the jar into storage. Later, a user can scroll through a selection of stored food servings filtered by calories, fats, vitamins, etc., using the LCD on the front of the device, and the system will retrieve the selected food serving from storage. If you remove a jar and only eat part of the contents, the system will weigh the jar, log how much was consumed and update the jar's database entry.

Tune in next time!

This covers the basic construction of my Smart Pantry, but for my next blog post I'll be tackling the problem of software! Tune in for the second part of this three-part series to see how (...if) I make all of these parts play nice. If you have any suggestions, fire away; I'd love to hear them. Since the project isn't finished, it isn't too late for a good "What you should've done is..." or "If I were you, I would have."


Comments 19 comments

  • Maxim / about 7 years ago / 2

    My eyesight probably isn't so great so I was pleasantly surprised when I discovered it was a Smart PANTRY project and not some kinky fetish project!

  • When I count calories, the sauces are the hardest to figure out, so this machine would be great for them. Also, BBQ sauce from a peanut butter jar is less desirable than a squeeze bottle. It should be possible to leave food in the original containers.

    The Nutritionix API reference can return the fields nf_serving_weight_grams and nf_servings_per_container. If the manufacturer can be trusted to include the actual weight of food they mark on the container, the Smart Pantry could deduce the unknown container weight like this

    Measured_weight - ( nf_serving_weight_grams * nf_servings_per_container ) = Container_Weight

    Alternately, if you add a number pad to the device, the user could enter the weight printed on the container since that will probably be more precise.

    Since I never saw a bottle of Sweet Baby Ray's without a UPC, maybe item tracking could be done with the bar code reader. If the weight of a particular UPC increases, the user would be asked if this is a replacement.

  • rzr_lzr / about 7 years ago / 1

    As some other comments have said, the storage aspect of the project feels impractical for general use (the office coffee supplies sounded good though).

    (A.) I do really like the scale-and-scan portion since it wouldn't take up much space to have just that component on a kitchen counter. Then you could have a workflow like: scan+tare -> use product -> scan+weigh. As a bonus, since the products are in their original packaging you can save a lot of time repacking and money on other containers and RFID tags.

    (B.) Having some sort of "session" marker would be great as an auto-input for different recipes and tracking incremental differences in a recipe (hate it when you get a recipe perfect and cant' remember the ingredient mix?). Improving eventually to simultaneous session/recipes for cooking multiple dishes (e.g. making pasta and a salad at the same time).

    (C.) You could also eventually include an inventory management system where you only need to have an "Add to shopping list" button to press during scan operation. (possible integrations into google keep, evernote, email, etc.)

  • Member #848873 / about 7 years ago / 1

    Just a note about SKU/BarCodes.

    There is a large bottler of beverages out there. This bottler had an inspired employee helping to optimize there ingredient management system. One of the steps in that system is to make sure that can gets filled with the right product. All of the cans have a printed barcode on them. This industrious and smart employee went to the data gods and asked for a simple list. "I need a list of all the Barcodes tied to the product that is in them"

    He searched high and low. He had a simple concept.. Connect the barcode and product and force the check at the mixing equipment. Such an easy idea. Such a simple table that should be readily available...

    It didn't exist.

    It still does not exist.

    It should exist in some form unofficially. It does not exist in a master form officially.

    I managed to bring over my itunes folder. Most of the meta data is gone.

    Do not be surprised if you spend a lot of time manually entering the information in.

  • Member #848873 / about 7 years ago / 1

    Prepare for the complement [sic] sandwich...

    I like the initial idea. It attempts to tackle a problem that is perceived to exist. The people at sparkfun who have managed to control their workshops are the ones that are likely to make this system work. I am doomed to make it fail. I am trying to control my kitchen, but I am in a battle between my knife and my cuisinart. I need to fix my roundabout in the corner cupboard. It needs fixing because it is plastic and I store 1 gallon containers of Sugar, Flour, Bisquick (why do I have bisquick and flour and baking soda and baking powder... DO NOT ASK.. Please... ), Chocolate Chips, more chips, more nuts, more .... All of which are stacked in a haphazard way that allows me to almost not find them when I am looking for them, but somehow I always find them.

    YOU DO NOT WANT TO LOOK AT MY SHOP...

    There are 4 heat sources in my kitchen ... Microwave, Toaster Oven, Gas Stove Stop, Gas Oven, ... Wait, there is also a waffle iron, a pseudo heated panini press, and then the barbecue outside... But there is also a fire pit over on the other side of the yard.

    There is the Freezer, the Fridge, the Pantry, the rollout pantry, the baking cupboard, the condiments cupboard, the spice cupboard, the spice rack and the big freezer outside.

    Starting with this little project is a nice little step... It is a great step. Getting all the pieces to work will provide lessons in how to make other stuff. The containers are what cause me to cringe. The part is "Standardized Size". That word causes my brain to scream...

    "Standardized" is why standard tool systems never quite work. To make the system work it has to be configured to you. The best you can do is create a system customize easily.

    I am cheering you on as a means of making your life better, more efficient. Individual project are what make SparkFun so awesome. You can make this work for you, that is all that matters.

  • Member #444720 / about 7 years ago / 1

    what about different sized containers too?
    that way you could grab a "cup" of raisins for a snack, just as easily as grabbing a cup of pineapple or almonds for a recipe. The need to quickly prepare a healthy recipe needs some automated help too, or, at least you don't want this system to unnecessarily add time to that task.

    • Member #444720 / about 7 years ago / 1

      maybe add a sticker printer that prints out labels that will last in refrigeration and be easily removed (they exist)

  • Member #444720 / about 7 years ago * / 1

    Terrific idea. Refrigeration, fresh foods (fruits and vegetables) and using existing containers do seem like necessary, and challenging issues to be addressed to engage the majority of the users and to make a tool that will allow for long-term and frequent use daily.
    You have already identified and tackled the issue of making something that helps people with the difficult job of tracking all those nit-picking details of their nutritional habits and helping them with a tool to improve them, however, the hard reality about getting something like this to be broadly adopted by the masses will be to successfully address those issues (cheaply and simply of course). Having jammed that down your throat, it is worth saying that the work done so far is stellar, well thought out and is almost a product on its own. A couple of quick ideas you might be interested in : 1. find a way to offer a "branded" container the user can purchase directly from eBay, Amazon or the like dirt cheap (not necessarily your product) 2. solicit product name/features from your enthusiastic readers on sparkfun and other sites as a contest 3. read up on "how to... successful kickstarter..." and do that after you figure out all the details 4. ask several nutritionists & doctors for their ideas on how to organize, collect and summarize data so the "information out" is useful for the user and can be used for other purposes you have not yet considered (e.g. a report or data the doctor can use for people that "need" to have a system like yours help them with nutrition /weight to solve health problems over long periods of time)

  • jdh2550 / about 7 years ago / 1

    This is a very cool idea. But reading the comments (which match my own initial reservations) is that the retrieval and dispensing system while undoubtedly kick-ass and way-cool is probably a limiting factor to the less sexy attribute of usefulness.

    So, how could you change that?

    I think I'd make the whole pantry cupboard smart: You could either make the whole shelf a weigh platform or just have the user place the container on it as part of the "add stuff to pantry". Have a barcode scanner which is quick and easy to operate but which you reach in and grab the contents from the pantry yourself.

    As far as initial weight goes - if the weight from that online DB is unreliable then how about image recognition? All food products have to list their weight or volume. And if you take the suggestion of using the RPi camera for bar code scanning then you could also maybe adapt it for image recognition as well (using OpenCV?).

    Just my 2 cents worth.

    Whatever you do - it's an awesome idea. Good luck!

    You'd still get all the benefits without having to keep track of jars with RFID tags nor limiting the amount of storage. It would also be cool to productize this.

  • Tex_Lawrence / about 7 years ago / 1

    All comments, so far :D, have been positive, but this thing will never work.

    You must not have real people living in your house for this to work, or you live alone (there's another whole story.) Possibly you have a very understanding partner. :D

    Besides, there are as many ways to reach a desired weight as there are people. One can track "nutrition" forever, but that still won't solve a weight problem.

    However, the main reason there is a problem is that nutritional "guidelines" on packages are highly suspect and can't be trusted to be correct or even accurate.

    Sorry to spoil the parade. :D

    • jdh2550 / about 7 years ago / 2

      Let me be the first to blow a big fat raspberry your way (no offense intended).

      A couple of slightly more useful rejoinders (rather than the raspberry):

      • This is the first iteration of an invention. "This won't work for real people" would probably have stopped most of the worlds truly life-altering inventions from being developed into useful products. Sure, this won't actually change the world - but the spirit is there.

      • There are two problems being tackled here: (1) the tracking of food intake; (2) the nutritional and calorific impact of that intake. The quality of both solutions can be developed independently of one another. The author is tackling #1 and will be able to take advantage of improvements in #2 as they become available.

      Just my 2 cents worth to keep the parade on track... ;-)

      • Tex_Lawrence / about 7 years ago / 1

        "fat raspberry" Pun intended? :D

        "first iteration of an invention" Inventory management isn't really an invention is it?

        Anyway, perhaps do this for your pet food, but people don't eat or cook this way. When you're really cooking food for people, you hear/say things like "a little more of ..." Put that in your pantry management system.

        Besides, there's been no mention of tracking for individuals at all unless this is for the single person.

        The worst thing for a design is to not have a valid problem to solve. That's where the disappointment comes. Hardware built with no solution provided.

        PS. I think this is really just to sell Sparkfun products. No one hurt in the process, but I don't think it rises to the level of an "invention."

  • Nice one Nick! What a cool project. I'm excited to see how it progresses. I'm already wondering how this could scale to store a larger inventory. Maybe a portal on the back position that can exchange each tub from a larger storage array? Now I'm envisioning a train track around my kitchen with a ton of peanut butter jars cruising along :)

  • ME heat o nator / about 7 years ago / 1

    sounds like a great idea for an office space break room, not to track nutrition content as much as who is eating all the hot chocolate or creamer. It would work very well with dry goods like that. It could also work well in a production environment with things like bolts, wire nuts and other items that are used often, but need constant stocking.

  • DrPhibes / about 7 years ago / 1

    Very nice, pursuant to improved nutrition, it would be great if recipes could be queried based on your available inventory.

  • REDACTED-GDPR / about 7 years ago / 1

    For about the last 5 years, I've been planning to build a pantry specifically designed to track canned goods using barcodes to keep an inventory. The theory being when you get to the grocery store you have an app which polls your server and retrieves a database informing you what supplies you need to buy. The database would be automatically updated as you insert or remove food to save time. I haven't designed it yet, but your system looks like a great complement to my plans. Looking forward to hearing more!

    • Canned food inventory is a great application for a project like this. Maybe I'll touch on that in my next update!

Related Posts

Recent Posts

Open-Source HVAC?

What is L-Band?

Tags


All Tags