What goes together better than the Internet and food? But there’s more to this delicious combination than just posting photos of last night’s meal on Instagram. Continuing our theme around the “Internet of Things,” we present another possibility from this game-changing technology. This time, it is a use case on IoT for inventory management. In this blog post, we’re going to use IBM Bluemix and PubNub to build an application that will transform any dumb kitchen by enabling automatic inventory tracking. You’ll never run out of bacon again!

Note: This post was originally published in IBM Bluemix Blog.

Also check out the concept design for smart jar to keep tab on your home kitchen stock. Courtesy, Artifact Design

Project Overview

This application relies on sensing the weight of a kitchen storage container to track food consumption. This data can provide valuable insights around consumption patterns and help chefs predict and replenish their inventory just in time. There are three components of this application:

  • Inventory Tracking Server (ITS): Monitors all the kitchen containers and records daily consumption and replenishment statistics
  • IoT hardware: Detects the weight changes in containers and connects them to ITS
  • Mobile app: Provides an easy interface to see the current state of inventory and also offers analytics to view inventory history for the last seven days.

The reference architecture of the entire application is shown below:


Communication between the components of this application is handled by PubNub’s real-time Data Stream Network.

ITS is a Python-based application server running on Bluemix. In order to keep track of the inventory records, this application provisions a dashDB instance, which is IBM’s in-house data warehousing service on the Bluemix cloud. The mobile interface is a Cordova & JavaScript-based Android app.

The hardware is powered by a combination of Arduino UNO and Mediatek Linkit ONE. For sensing the weight of kitchen storage containers, two piezoelectric load cells are used.

In order to produce the desired strain for determining the container’s weight, the load cell needs to be mounted between two flat surfaces (such as plywood) with the help of the two threaded holes on each side of it. Once mounted, the flat surface can act as a scale for measuring the weight of a storage container.


Application Use Case for Kitchen Inventory Tracking

For a restaurant or large hotel, tracking kitchen inventory is one of those tasks that are crucial to their business. It can be quite inefficient and error prone due to human intervention. In such cases, having such inventory tracking application makes perfect sense. There are three main use cases for this application:

  • Track inventory – Provide automatic, real-time updates about the current availability of inventory
  • Expiration Notification – Notify the user in case of expiration of food
  • Analytics – Access historical inventory usage data for better prediction and planning.

Now it’s time to discuss the detailed hardware, software setup and the complete functionality of this inventory management system.

Kitchen Inventory Management: Project Setup

If you would like to build this application yourself, then you can access the complete source code  on GitHub. All the steps for setting up and building the project’s components are listed in the README file.

Before building, you need to sign up with IBM Bluemix and PubNub. Visit the Bluemix registration page and PubNub service page to create your respective accounts. Both services offer a free tier account to play around with their offerings.

Server Setup

The Inventory Tracking Server (ITS) is written in Python and can be installed as an IBM Bluemix hosted app. IBM Bluemix provides the computing horsepower for the ITS to monitor hardware devices and manages automatic inventory tracking. Additionally, you will need to associate the PubNub service with your Bluemix account for the ITS to work with PubNub. Refer to these deployment steps to understand how to setup and host a Python application under Bluemix with PubNub. As noted earlier, the source code for ITS is located under the kitchen_tracker directory in the GitHub repository.

Hardware Setup

The hardware has two parts:

  • Sensor Controller – Driven by Arduino UNO, the sensor controller acts as a localized aggregator of all storage containers which are under this inventory tracking system. It interfaces with the load cells to sense their weight and is connected to an HM-10 BLE module to transmit the weight data over Bluetooth. By using this arrangement of local aggregation and BLE, there is an added advantage of bringing in new storage containers under this inventory tracking system with the minimal additional wiring.
  • Master Controller – Master controller acts as a gateway for the sensor controller. This is powered by Linkit ONE board. It has an inbuilt BLE module that probes the sensor controller every few seconds to get the current weight sensed by the load cells. It also has inbuilt WiFI interface for connecting with ITS over the internet to send the weight readings.

The master controller plays a crucial role in stabilizing the weight value of the containers. This is to avoid sending transient or spurious weight values while, for example, the container is being refilled gradually.

The schematic diagram of the sensor controller hardware is shown below:


Refer to these build and install steps for configuring the hardware. The source code for hardware setup is available under the hardware directory (for the sensor controller) and the linkitble/pubnub_linkit directory (for the master controller), under the GitHub repository.

Calibrate the load cells to avoid errors is weight measurement.

Mobile App Setup

The mobile app is a standard Apache Cordova based Android app. Cordova is an open source, cross-platform, mobile development framework based on standard web technologies, such as HTML5, CSS3 and JavaScript. Among other features, this app provides the user with a visual indication of the current container level.

Look at all that bacon!

The source code for the mobile app is under the mobileApp/kitchen directory in the GitHub repository. Steps for building the app are available here.


PubNub acts as the communication middleware for the entire system. It provides a cloud-based realtime Data Stream Network that supports over 70 SDKs, such that it can enable any device to communicate with any other device on the Internet. This application uses three of PubNub’s SDKs for all components to seamlessly communicate with each other. They are:

PubNub uses the ubiquitous publish/subscribe mechanism to stream data in real-time, from one device to another. This is achieved by the use of channels which provide a secure bidirectional messaging layer between the devices. This application uses several PubNub channels for enabling communication between the hardware, ITS and mobile app. Refer to this tutorial to learn more about how to build a small publish/subscribe demo using PubNub.

Note: In this application, we have used PubNub Python SDK version 3.x and Javascript version 3.x , both of which are being retired on 1st July, 2017. You can continue to use the source code as long as you install the older 3.x version of the libraries. The newer version is 4.x and it is not compatible with 3.x.


Application Use Cases

There are three main use cases for this application:

  • Track the current status of inventory
  • Expiration Notification
  • Access historical inventory usage data

Before we can start using the mobile app for tracking inventory, we need to perform some container specific settings and register them with the server. Those setting are:

  • Label – A user-defined identifier for the container for easy identification.
  • Threshold Value – A threshold value (in kilograms) to indicate a critical level for container weight.
  • Expiry – Since most of the kitchen inventory is consumable food items which have an expiry date, we can set an expiration value (in months) for the container. This way, the server can track the expiration date and send a notification to the app when those contents have expired.

These parameters can be set for every container.

Once submitted, these settings are sent to the ITS application server via a PubNub channel.

Use Case 1: Track current status of inventory

Once the container settings are registered with the ITS, the app can receive current weight measurements of the containers. Every time a container weight changes, either due to consumption or replenishment, the application performs the following steps:

  • Step 1: The hardware detects the change in weight and publishes a new weight value on PubNub channel ‘kitchenDevice-resp.’
  • Step 2: ITS receives the new weight and daily consumption for the current day.
  • Step 3: ITS updates the database to record the daily consumption data.
  • Step 4: ITS publishes the new weight on PubNub channel ‘kitchenApp-resp.’
  • Step 5: The app receives the new weight value and updates the screen display to reflect the new weight value and updates the visual level indicator for the container.


Alternate Flow

Step 2 – If the server detects that there has been an increase in the weight, then this means that the inventory has been replenished on the container. In this case, the ITS performs the following steps

  • Step 2a : ITS resets the expiry calculation to start from the current date.
  • Step 2b : ITS stores the start of expiry date in its internal memory.
  • Step 2c : Use case continues from step 3.

Use Case 2: Expiration Notifications

This use case is also an alternative flow of the previous use case. If a container has not been refilled before the expiry date, then the ITS can sense this during step 2 and alert the user whenever it detects a consumption to warn against expired food.

In this case the sequence of steps from step 2 will be as follows:

  • Step 2a: ITS receives the new weight and calculates the expiry validity of the container and finds that the expiry period has been crossed.
  • Step 2b: ITS updates the database to record of the daily consumption data.
  • Step 2c: ITS publishes the new weight on PubNub channel kitchenApp-resp and sets the expiry parameter as zero.
  • Step 2d: Use case jumps to step 5.


When the mobile app receives the notification for consumption with the expiry set to zero, it updates the container icon in a way to alert the user that the inventory being consumed has expired.


Use Case 3: Access historical inventory usage data

The ITS is supported by a backend data warehousing service powered by IBM DashDB. Daily inventory data for consumption and replenishment is updated on dashDB database which can provide some basic analytics on historical inventory usage for the last 7 days.

To display the historical inventory usage, the user has the option to either display a graph or a table by tapping on the “Graph” or “History” button.

The request is honoured by ITS by sending the consumption and replenishment data in two separate PubNub channels. The flow of information is as follows:


The mobile analytics look something like this:



This application demonstrates how easily one can leverage IoT to eliminate human intervention and automate manual processes. For a restaurant or large hotel, this can make a big difference.

A further enhancement of this app would be to automatically place an order with suppliers when inventory falls below a critical level. The possibilities are endless, and with IBM Bluemix’s state of the art data warehousing and the 99.999% reliable messaging infrastructure of PubNub, building such solutions is fast, secure, and highly scalable.

Stay tuned for more demos and application use cases using IBM Bluemix & PubNub Data Stream Network!

About the author 

Shyam Purkayastha

Shyam is the Creator-in-Chief at RadioStudio. He is a technology buff and is passionate about bringing forth emerging technologies to showcase their true potential to the world. Shyam guides the team at RadioStudio, a bunch of technoholiks, to imagine, conceptualize and build ideas around emerging trends in information and communication technologies.

  • A nice conceptual design and development of smartkitchen for grocery item identification,inventory management of grocery items at homes.It would make create a huge positive sign when implemented in large restaurants or hotels.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    TechForCXO Weekly Newsletter
    TechForCXO Weekly Newsletter

    TechForCXO - Our Newsletter Delivering Technology Use Case Insights Every Two Weeks