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:
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:
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!
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.
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.
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.
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.
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.
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!
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.
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."