Project tutorial

Foodie © GPL3+

Foodie is an IoT Home automation project intended to track the usage of your food.

  • 8 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
Teensy was used in my example, but I have also included code that could be used with an Arduino Uno. Main difference is emulating a UART connection using the SoftwareSerial library
Teensy 3.2
Teensy was used in my example, but I have also included code that could be used with an Arduino Uno. Main difference is emulating a UART connection using the SoftwareSerial library
JY-MCU Arduino Bluetooth Wireless Serial Port Module
Adafruit USB LiIon/LiPoly charger
2000 mAh, 3.7v LiPo Battery
R8326274 01
Raspberry Pi 2 Model B
Orico USB Bluetooth Dongle
Adafruit Force Sensitive Resistor

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

Microsoft azure logo 7qghkhuibq
Microsoft Azure
Azure Virtual Machine running Ubuntu Server 14.04
Microsoft azure logo 7qghkhuibq
Microsoft Azure
Azure Event Hub that receives data from the Raspberry Pi Hub
Microsoft azure logo 7qghkhuibq
Microsoft Azure
Datastax Enterprise Cassandra/Spark
Microsoft Visual Studio 2015
IntelliJ Idea
Microsoft Windows 10 IoT Core

About this project

Foodie is meant to be a modular end to end weight sensor network that allows you to track food usage, provide statistics, recommend shopping lists and even more. Combining a Raspberry Pi 2 running the Windows 10 IoT Core, a Teensy, Spark, Cassandra, and Azure we get an end to end sensor consumption service that is capable of tracking food usage and tying it to individual barcodes.

What Does Foodie Do?

  • Live tracking of weight sensors
  • Web Interface to view sensor data and upload barcodes
  • Upload barcode images and tie a product to the sensor
  • Integrates a barcode API to get product information


  • 1 Fish - Getting Started

  • 2 Fish - Hardware

  • Red Fish - Setting up the Backend

  • Blue Fish - Linking It All Together

1 Fish - Getting Started:

This project relies on various different pieces that range from running on the Raspberry Pi 2 to running in the Cloud. In the following sections you will learn everything from how the project interacts, to where and how to buy the pieces, as well as how to get everything up and running.

First off, some general notes about this project.

  1. I opted to use a Teensy instead of an Arduino to make sure I could make the form factor I wanted. However I have included code that will run on an Arduino Uno which takes advantage of the SoftwareSerial Library to emulate a UART connection on pins 10 and 11.
  2. The project was designed to be fairly modular in the sense that, the backend could be stripped to support a wide array of different sensors and modules that need streaming support. By all means break apart the code base and use it, the Event Hub and Spark streaming pieces are great for just about any sensor network.

Initial tools to get ready

  1. Visual Studio - You will need at least the Community edition to compile and deploy the C# Raspberry Pi Hub to the Raspberry Pi
  2. Arduino IDE - This will be needed to deploy the weight sensor firmware to the Arduino. OPTIONAL: If you opt to for the Teensy you will also need to download the Teensy plugin for the Arduino IDE.
  3. Azure Account - This project relies on an Event Hub hosted in Azure and my example takes advantage of an Azure VM as well as an additional Azure SQL Database.
  4. Soldering Iron - This is optional however if you want to package it all up inside the case you will want to solder the connections directly.
  5. Outpan API Key - You will need this a little later on, it is the Barcode API Key.
  6. 3D Printer or Something Similar - If you are interested in printing out the housing, you can find the STL files in Foodie/STL

2 Fish - Hardware:

A few things worth noting about this circuit.

  • When connecting the JY-MCU unit to the Arduino remember that the TX port on the Arduino connects to the RX port on the Bluetooth module and vice versa.
  • Use one GND pin for the Force Sensor and the other GND pin for the Bluetooth Module and USB Battery Charger.
  • On an Arduino Uno, simply connect the TX and RX pins to pins 10 and 11.

Red Fish - Setting up the Backend

The backend to this project relies on 4 major parts.

  1. Bluetooth Connected Arduino
  2. Raspberry Pi 2
  3. Azure Event Hub/Spark Streaming Job/Cassandra
  4. Website

Bluetooth Connected Arduino

  1. Navigate to the root of the project
  2. Open the "WeightSensorFirmware - Uno" or "WeightSensorFirmware - Teensy" folder and open up this file up in the Arduino IDE
  3. Side Note: If you are using a Teensy, ensure you have the following package installed.
  4. Click on the sideways arrow in the upper left of the IDE to begin the upload process.
  5. That's a wrap folks! That's all it takes to get the Arduino ready to talk to the Raspberry Pi 2.

Raspberry Pi 2

  • Follow Microsoft's setup guide to get the Windows IoT Core image running on the Raspberry Pi 2
  • Open up the Windows IoT Core Watcher program and determine the IP Address of your RPi 2.
  • Side Note: Normally we would be able to navigate to the onboard website and pair our Bluetooth devices there. However I have not had much luck getting a device with a passkey to correctly pair via the website.
  • Download and Install Putty or your favorite SSH Program
  • Open up Putty and enter your Raspberry Pi's IP Address into the following box, then hit enter.
  • Once you reach the login screen via the SSH terminal enter your credentials. (Default User: Administrator, Pass: p@ssw0rd)
  • Follow these steps next to pair your RPi to you Bluetooth module.
  • Side Note: If you are using the JY-MCU Bluetooth module or any variant of the HC-06 chip, the default passkey is "1234"
  • Navigate to Foodie/RaspPiHub and open up the solution in Visual Studio
  • Fill in the information at /AppConfiguration/app.json
  • Deploy the app to the Raspberry Pi 2!

Azure Event Hub/Spark Streaming Job

  • Begin by creating an Azure Event Hub by following this guide up until it begins creating a C# app.
  • Create an Azure VM with the following specs and make sure to give it a unique name!
  • Navigate to the Endpoints tab of your VM and add TCP rules for all of the following.
  • Here is where the fun really begins! The setup commands are numerous and are too much to attach in the body here, so I have attached a text file with the commands to run via SSH on the VM.
  • There is a lot to setup and quite a bit of information to digest, so take your time and walk try to understand it all. 
  • CONGRATULATIONS! If you have made it this far you only have one piece left to setup.


  • Navigate to /Foodie/FoodieWeb and ensure that line 14 of "" is listening on port 80
  • In /Foodie/FoodieWeb make the "run" file executable via chmod +x ./run
  • Execute "nohup ./run &" to start the website in the background

Blue Fish - Linking It All Together

If all went well you should now have the entire project up and running and ready to go. That means we get to start the fun part, playing with the system we just setup.

  • Assuming the Raspberry Pi is paired with the HC-06 correctly, load up RaspPiHub on the Raspberry Pi and connect it to HDMI. This will give you a UI to begin tracking paired Bluetooth devices. Click on the HC-06 Entry and hit add. 
  • The Raspberry Pi will now begin polling that sensor for weight sensor data every minute, and sending it to the Azure Event Hub we have set up.
  • The Spark Streaming job we set up will consume the Event Hub data in 5 second intervals and inserting the new readings into the Cassandra DB
  • Navigate in your web browser to and you can view a graph of the last 30 readings that refreshes every 5 seconds and upload an image of a Barcode to attach to the sensor.


Drag and drop images or click to select some from your file system


Foodie Github Repo
Included is all the software that runs on all the devices.

Custom parts and enclosures

Weight Sensor Housing
STL File for the Weight Sensor Housing, for use with a 3D printer or something similar
Weight Sensor Housing 123d File
This is the editable Weight Sensor Housing


Weight Sensor Circuit
Circuit Diagram of the Weight Sensor


Similar projects you might like


Project showcase by 3 developers

  • 29 respects

Windows IOT - Automate your power outlets

Project tutorial by Syed Sanoor

  • 56 respects

Solar Tracker with Live Data Feed - Windows IoT

Project tutorial by Jed Hodson

  • 1 comment
  • 33 respects

Where is my thing?

Project tutorial by Tan See Youu

  • 30 respects

Pool Controller

Project tutorial by Mike Mackes

  • 141 respects


by Dennis Mwanza

  • 55 respects
Add projectSign up / Login