The Fridge Calculator: Refrigulator



The Fridge Calculator: Refrigulator

Michael Gerstein

Jesse Farfan

Juan Antialon

Karen Flores

Rutgers University, School of Engineering

Department of Electrical and Computer Engineering

Capstone Design Proposal

Professor Christopher Rose

May 2nd, 2012

Table of Contents

Abstract 3

Design 4

The Breakdown

Scanning 5-7

Weighing 7-9

Communication 10-15

Databases 15-19

Future 19-21

Appendix 22-33

References 34

Abstract

In today’s society all kitchen appliances are digital, “smart”, and futuristic, except the refrigerator. Coffee machines are designed to start brewing the second it’s owner hops out of bed, toasters can predict the 5-day weather forecast, and ovens can display top news stories for each day. The purpose of our project is to propel the modern day kitchen even further into the future. The Refrigulator serves to take a digital inventory of the refrigerator and determine which recipes are available to cook-up based on the user’s diet. The breakdown of our system can be separated into four portions; scanning, weighing, weireless transmission, and data analysis. The product’s UPC code is scanned, and then placed on the weighing device. The scanner transmits the UPC code information to the user interface via USB, and the scale wirelessly transmits the weight information to the user interface via single-board microcontroller. As the user interface accumulates the refrigerator inventory data, our system calculates recipes involving the products in the user’s refrigerator.

Design

The components of the Refrigerlator are a charged coupled device (scanning), a strain gage (weighing), an arduino (wireless transmission), and a user interface (data accumulation and analysis). The scanner is programmed to acquire any product’s UPC information, send it directly to the user interface, and accumulate an inventory of refrigerator products. After scanning, the product is placed on the strain gage scale. The strain gage scales are reverse engineered, coupled with an arduino, and designed to read an amplified voltage change. The arduino converts the amplified voltage change into a force applied (weight in ounces), and sends this information wirelessly to a user interface. The user interface couples the information, product name and weight, and stores it in the four tablet Microsoft Excel sheet. The first tab stores the refrigeratory inventory (accumulated through the scanning and weighing process), the second tab contains a list of recipes (that we had to input ourselves), the third tab displays the list of recipes available for concoction (based on the first and second tab), and the fourth tab instructs the user how to cook-up the recipes currently available.

The Breakdown

As previously stated, our project is divided into four sections: the scanner, the strain gage scales, the communication, and the databases.

The Scanner we have chosen for our project is a Charged Couple Device (CCD). The CCD converts optical images to electrical signals. In terms of our refrigulator system, the CCD scanner converts the Universal Product Code (UPC) on each product into a digital signal. The digital signal is sent to a computer where the information pertaining to the UPC is stored in a Microsoft Excel file.

Scanning Process

The basic function of a Charged Couple Device Scanner (CCD) is to convert optical images to electrical signals. In terms of our refrigulator system, the CCD scanner converts the bar code on each product into digital signal. The process at which it does this is as follows:

1. The scanner inside the CCD shines a light at the bar code and the reflection is captured in the form of an image via the CCD for reading.

2. The image of the bar code reflection is converted into an analog waveform.

3. This analog waveform is then converted into a digital signal using a sampling method of the given analog signal, digitization.

4. The digital signal is decoded and sent to a computer where it stores the data.

There is a linear photo-diode within the scanner head. This photo-diode can read the reflected light off the lines on the bar-code. This reflection is a digital image that is then scanned electronically within the device. When the image is scanned electronically, each bar on the bar-code is converted to the corresponding number or letter. The bar-code scanner is connected to a PC or Mac and the CCD scanner then sends the sequence of numbers and/or letters to the PC or Mac to populate the field of entry. This connection can be made in a number of ways. One way is with a keyboard wedge. This is a Y connection where one end of the Y connects to the keyboard and the other end of the Y connects to the scanner with the bottom of the Y plugging into the PC where the keyboard would normally connect. This method is used many times when the PC does not have enough interfaces. Serial is another connection method and works with just a straight serial cable from the bar-code scanner directly to the PC serial connection. USB is now about the most popular method, because most PC's and Mac's today have many USB ports.

The communication design concepts behind this are retrieving an analog signal, converting an analog signal to a digital signal, decoding the digital signal, and sending the decoded information to a computer for storage.

The Strain Gauge Scales we have designed for our senior capstone entails a unique story of reverse engineering. Firstly, a strain gauge system consists of multiple strain gauges and these individual strain gauges are designed to measure stress and strain, hence the name strain gauge. A strain gauge is a sensor whose resistance varies with applied force. It converts force, pressure, tension, weight, etc., into a change in electrical resistance that can then be measured as a voltage difference. For our project purposes, the voltage difference measured by the strain gauge will be sent to the arduino, the arduino converts the voltage difference to weight in ounces, sends the information (weight in ounces) to the computer and pairs it with the appropriate UPC information. The paired information is stored in the Microsoft Excel file (via arduino) and accumulates for each product (forming the refrigerator inventory). In order to retrieve these strain gauges our group took apart a simple weight watchers bathroom scale. We used power tools, saws and drills, to “get under the hood” and evaluate the circuit layout. We discovered a four strain gauge system that helped us understand how a strain gauge works when heavy weight is applied. In order to fulfill the project goal, we purchased three kitchen weight scales whose strain gauges were more sensitive to an ounce.

The strain gauge shown above was used for measuring the weight in this project. When the excite cables are connected to a DC voltage, there is a change in voltage in the sense cables. The more weight applied, the higher the change in voltage. As you can see above, the weight is applied on the left side of the strain gauge which gives a negative change in voltage. Unfortunately, the change in voltage from the strain gauge is too low and cannot be read by the arduino. Therefore, an AD620 low drift low power instrumentation amplifier was used to amplify its signal. A battery of approximately 5.7Vdc was connected to the excite cables and the amplifier to power it. The schematic shown below displays the circuit used to measure the change in voltage.

[pic]

Wire wrapping was used to build the circuit above. The output voltage is about 2.2V and it decreases as weight’s applied to the strain gauge. This is demonstrated in the picture of the integrated circuit shown below.

[pic]

Weighing Process

We want to divide the refrigerator by placing several weight scale “pads” in allotted positions. This will limit the amount of products the refrigerator can store; however, it will supply the refrigerator database with information such as the amount of product being stored. Our idea is to build a scale that varies in size, lays flat on the refrigerator draws/side-door, and is resistant to cold temperatures. For this project, we have created a prototype that consists of three scales that demonstrates what would happen when products are added to the fridge. However, these scales are not temperature resistant and will change its output weight when it’s exposed to cold temperatures. This is a pristine design that would complement the project if anyone ever continued to build off of this concept.

Wireless Communication

In order to send the data to the database to match the scanned items, we used UNO arduinos and ZigBee series 2 antennas. Arduinos are useful micro controllers that can be programmed to read analog data and send it to another device. The UNO arduino is usually connected via USB in order to transfer data but since the system needed signals to be transmitted wirelessly, we chose to use ZigBee technology. ZigBee is a low-cost and low-power wireless networking standard. Due to its low-cost, it is widely used in different wireless control applications. It has a edge on Bluetooth technology because of its low-power usage which allows longer life with smaller batteries and provides a larger range of communication, without compromising its rate and reliability.

Figure 1-Uno Arduino Figure 2- ZigBee series 2 antenna

In order to connect these two together and be able to send the information wirelessly, the ZigBee antenna needs to be mounted to the UNO arduino. To accomplish this task, we used an arduino ZigBee shield. The ZigBee shield allows the antenna (series 2) to send the information from the UNO arduino to another ZigBee antenna (series 2).

Figure 3- ZigBee Shield Figure 4- Arduino with ZigBee set-up

Initially, the project began using a Bluetooth Arduino but it was proven to be unreliable and had many connectivity issues. The UNO arduino provided stability and was a lot easier to program using the arduino programming language. In order to read the signal from the scale, we connected the output of the scale circuit to one of the analog pins of the arduino. After doing so, we set the baud rate to be 9600 which is the default for UNO arduino boards and programmed the arduino to read the analog pin. The result obtained was not in volts but in a range of 0 to 1024. In order to convert this number to a number between 0 to 5V, we used a simple conversion: value x 5/1024 to figure out the voltage transmitted.

Once the value represented the voltage from the scale, there was the need to convert this voltage to weight. Using a 1 ounce object, we determined how much the voltage from the scaled varied and called that variable y. Now, assume z= voltage reading of the scale (once an object has been placed on top) and x= voltage reading when there is nothing on the scale or the “zero” voltage. Then we can find weight by following a simple formula: (z-x)/ y and this will give the result in pounds. The entire code used to program the UNO arduino can be found in the Appendix.

The next part of the system is to program the ZigBee antennas to communicate with one another and create a network. In order to accomplish this task, the X-CTU software was used. The X-CTU software is designed to read COM ports and to configure them. To have effective communication in this network, one ZigBee antenna was designed to be the receiver and was connected directly to the computer containing the database. After adjusting the other ZigBee antennas to the same PANID and assigning the same baud rate for the network and the address in which they will send the information, the network communication was established.

Figure 5- X-CTU set up Figure 6- Receiver Connection

After creating a network of ZigBee antennas, the last part of the wireless communication aspect was to save the data that the receiver antenna was outputting to the COM port. This task was the most challenging part because of the inability of the arduino programming language to do so. Since the arduino language (which is based on C) is not capable to save data into a file, we explored into the option of using a software language called Processing, which enables the user to save the data coming from the arduino but it required the user to keep pressing the “Run” option which will not work in the real world application. Since the database chosen for this project was built in Microsoft Excel, there were two options to save the data, either a text file or a csv file (which is compatible with the .xlsm format). Upon encountering the issue with Processing, we turned to Java to read the COM port and save the data but it created different issues and turned to be a complex task. We wanted to save the different data from the different arduinos as weight 1 (representing scale 1), weight 2 and so forth but rewriting the data over and over. Essentially, we did not want to just add data to a file but instead keep re-writing over the value for scale 1 (for example), every time the arduino read a signal for scale one.

Figure 7- Wrong Saving Data Format Figure 8- Successful Data Saving Format

In order to obtain the desired output, we used Python27 to read the COM port and save the data to a text file named “data.txt”. The code for this file called final.py can be found in the Appendix. The user can run the Python program from the command prompt window and the program will run continuously until the user decides to stop the data from being written on the text file. The picture below shows the command and the output from the command window and though it looks like the data keeps showing on the screen, in the text file, only the last values for weight1 and weight 2 are being kept.

[pic]

Figure 9- Command Window Prompt

Once the data is saved into the “data.txt” file then the Microsoft Excel database grabs the value for scale 1 and 2 and aligns it with the corresponding scanned item. The last part of this aspect of the system is being able to work wirelessly. Originally, we had the arduinos either connected to a power supply or to a USB cable in order to turn them on, but since this will be ineffective in the real world, we obtained 5V batteries and connected the output from the scale to the pin so that no unnecessary cables were used in the system. The outcome of this combination is shown below.

[pic]

Figure 10- Scale and Arduino set-up

Database

As products are scanned into the refrigerator, the database is populated with inventory (as well as in multiples, i.e. 2 apples). The database, in Microsoft Excel, consists of multiple excel sheets. The first excel sheet has four main columns which display the product’s UPC code, scale associated with it, actual weight, and information associated with it from . This Excel workbook has VBA coding along with built in Excel functions that help gather all the information we need for our products. If you look at Figure 1, you’ll see how the columns are set up. We have built-in Excel functions such as “vlookup”, which searches for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify in the table.

Figure 1

When the UPC code is entered into column A (simply done automatically by the scanner), column D automatically updates the cell with information that pertains to that specific UPC code. We created a public function within Visual Basic which allowed us to gather information over the web and connect to ’s database. The latter is what helped display the product’s information. This code can be found in the Appendix section.

The second excel sheet entails four tabs; “Ingredients Currently Available”, “Ingredients Needed”, and “Recipes Currently Available”, and “Recipes Available” which will facilitate the tracking of inventory along with characteristics that are associated with them (weight, name, quantity, etc.). Ingredients Currently Available shows the information of products scanned into the refrigerator. Ingredients Needed displays all of the user’s recipes and which ingredients are needed to cook these recipes. Recipes Currently Available shows all of the user’s recipes in the database and a simple yes or no, regarding if there are sufficient ingredients to produce each recipe. Recipes Available displays all the recipes that the user is able to produce, and the directions in order to cook. The database will be programmed to initiate queries through keywords (i.e. “chicken.”) by an option programmed in the touch screen menu, labeled “Possible recipes” for example. The queries within the database will be programmed in order to display possible recipes that can be created based on the current levels of inventory within the refrigerator. Along with querying recipes, the database will also be able to export information detailing what’s in the fridge as well as how much of it. This feature will allow users to remotely “look” into their refrigerator and take any necessary action, such as picking up a gallon of milk on the way home since the old one is running out.

Figure 2

In order to accomplish these goals, we will use the C++ programing language. First, the database will contain all the recipes acquired from These recipes will be inserted into a text file and the program will extract the data from these text files and import them into the database. The entire process will be implemented through the usage of Binary Search Trees. The recipes will be sorted by different types of dishes: main courses, entrees, desserts and drinks. In order to organize all of these recipes the Binary Search Tree will be implementing a sorting algorithm such that it will aid the user find the recipe faster. This algorithm will sort each type of recipe alphabetically using a recursive loop that checks the title of the recipes and arranges them in order.

The second main objective of the database is to search for the recipes according to the inventory in the refrigerator. The binary search tree (BST) has a built in algorithm that does the searching that is needed to find the specific recipe that the user wants. Not only that, the BST will have an inserting and deleting algorithm so that it will be easier to organize and to get rid of any unwanted recipes. This program will recognize what the data that scanner sends and will show whether it goes with a specific recipe or not by using the search algorithm. Once the database finds recipes that matches what is on the fridge, it will display a list to the user in alphabetical order.

After the user has taken out the products from the fridge, the weight sensors will check the amount of the products left and will inform the database, who will update the amount of products stored and will recalculate the recipes that match what is left inside. The reason why we feel that it is necessary to use BST to implement this database is because linked lists consists of one pointer pointing at an object but the way this seems to be set up it will consist of multiple pointers pointing at an object. Binary Search Trees are known for having multiple pointers pointing at a particular object. It will make it more organized and will help us navigate better through the entire database.

Future

The database will be programmed to initiate queries through keywords (i.e. “chicken.”) by an option programmed in the touch screen menu, labeled “Possible recipes” for example. Along with querying recipes, the database will also be able to export information detailing what’s in the fridge as well as how much of it. This feature will allow users to remotely “look” into their refrigerator and take any necessary action, such as picking up a gallon of milk on the way home since the old one is running out.

The second main objective of the database was to search for the recipes according to the inventory in the refrigerator. The binary search tree (BST) has a built in algorithm that does the searching that is needed to find the specific recipe that the user wants. Not only that, the BST will have an inserting and deleting algorithm so that it will be easier to organize and to get rid of any unwanted recipes. This program will recognize what the data that scanner sends and will show whether it goes with a specific recipe or not by using the search algorithm. Once the database finds recipes that matches what is on the fridge, it will display a list to the user in alphabetical order.

After the user has taken out the products from the fridge, the weight sensors will check the amount of the products left and will inform the database, who will update the amount of products stored and will recalculate the recipes that match what is left inside. The reason why we feel that it is necessary to use BST to implement this database is because linked lists consists of one pointer pointing at an object but the way this seems to be set up it will consist of multiple pointers pointing at an object. Binary Search Trees are known for having multiple pointers pointing at a particular object. It will make it more organized and will help us navigate better through the entire database.

The idea of a user interface on a refrigerator, that tracks the every-day data of your fridge is unique and brings for future potential. With a more advanced data analysis, a futuristic version of this system can communicate a multitude of information to the user; expiration dates, purchase trends, shopping lists, expenses by day/week/month/year, budgeting, savings, etc. In addition, incorporating an RFID system to eliminate the constant scanning of items would be user friendly and efficient. RFID combined with refrigeratorshelf-scales would increase the user-friendliness. This technology would require the shelf to measure the perimeter of the product’s bottom, and calculate the force applied absed off the area of that perimeter.

Unfortunately, we were unable to move along fast enough to implement our system into a refrigerator. This implementation would obviously need to happen in order to complete our system. For this implementation we would need to test components at cooler temperatures which would bring forth some complications that would need to be solved.

Also, we were unable to set up the recipe data base function like we did with the UPC process. In the future we will have to coordinate our system to perform the same function as the UPC (hooking up to a recipe data base and pulling in recipes based on our refrigerator inventory.

The scales we built were too small to insert the arduino piece inside of them. For the future we would have to design scales that could hold the arduinos inside and hide them from view of the user. In order to make the user interface complete, we will need to set up a touch screen micro-controller and place it on the door of the refrigerator. Right now our user interface was a laptop.

Appendix

Arduino Code

double sesorValue=0;

void setup() 

{

  Serial.begin(9600);

}

void loop() 

{

  double sensorValue = analogRead(A5);

  double value = sensorValue * 5.0/1023.0;

  if (value < 1.5000) // anything lower than this is assumed to have nothing on the scale

  { //char* a= "weight= ";

    Serial.print("weight1 = ");

   // Serial.print(",");

    Serial.println(value,4);

    Serial.flush();

    delay (3000);

   

  }

  if (value > 1.5000)

  {//char* a= "weight= ";

    // if value is less than 1 V then it assumes there is no object in scale

   Serial.println("weight1 = 0.0000");

   //Serial.print (",");

   //Serial.println(value,4);

   Serial.flush();

   delay (3000);

  }

}

Python 27 Code

import serial

ser=serial.Serial('COM4', 9600, timeout=.8)

ser.flushInput()

ser.flushOutput();

weight1 = "";

weight2 = "";

while True:

msg=ser.readline();

if msg.isspace()==False and len(msg)>0:

print msg

x = msg.split(" ");

if(x[0]) == "weight1": weight1 = x[2]

if(x[0]) == "weight2": weight2 = x[2]

f = open('data.txt','w')

f.write("weight1 = " + weight1)

f.write("weight2 = " + weight2)

f.flush()

f.close()

ser.close()

Excel VBA Coding

' Excel VBA Function wrapper to call currency conversion Web Service on the web!

Public Function upcConvert(ByVal upc As String) As String

Dim objSClient As MSSOAPLib30.SoapClient30 ' Remove the 30 if using an earlier version of SOAP

Dim fResult As String

' Point the SOAP API to the web service that we want to call...

Set objSClient = New SoapClient30

Call objSClient.MSSoapInit(par_WSDLFile:="")

' Call the web service

fResult = objSClient.GetProduct(upc, "0DE2D3E6-90A0-4169-8EE8-16CEFB6FD342")

Set objSClient = Nothing

upcConvert = fResult

End Function

Public Sub refresh()

Application.CalculateFull

ThisWorkbook.RefreshAll

End Sub

'Code I can use to delete product entries if weight is 0

Sub Delete()

For i = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1

If Left(Cells(i, 2), 1) = 0 Then Cells(i, 15).EntireRow.Delete

Next i

End Sub

Access Code to “”

POST /supc/service/UPCSearch.asmx HTTP/1.1

Host:

Content-Type: application/soap+xml; charset=utf-8

Content-Length: length

string

string

HTTP/1.1 200 OK

Content-Type: application/soap+xml; charset=utf-8

Content-Length: length

string

WSDL Code





































































































































































































................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download