PROMOTIONAL VIDEO: https://www.youtube.com/watch?v=evA31orGV3g

THE PROBLEM: Humans are inherently lazy, so lazy that some don’t even want to take that trip to the fridge in vain. Take for example, a busy student studying for finals. They’re hungry but they don’t want to waste time going to the fridge unless there was something cool to eat. So unless this very busy Penn student had time, on top of her 6 classes, to keep a list of things in their fridge and keep updating it too, chances are that she probably has no idea if there is something chill to eat. Our solution is a way to remotely access contents in your fridge.

Speaking of very busy people. They’re never organised. They forget to buy new groceries, like forgetting to buy more eggs once they’re out. Our solution was to send the user reminders on an accessible interface whenever they had to go out and buy more groceries.

APPROACH TO SOLVING THE PROBLEM: What if there was a way to know what’s in your fridge without having to actually go to it? We approached this problem by creating a remote that lets you know what’s in your fridge. Our approach to tracking the contents of the fridge was to use RFID. All the user has to do is attach a tag to each item in the fridge and scan it against a sensor when putting it in or removing it from the fridge. To send information about the contents of the fridge to the remote, we decided to use Bluetooth. This, we believed, would solve the problem of lazy, busy students knowing what’s in the fridge without having to go to it, as they can remotely access the contents of their fridge. To solve the problem of people forgetting to buy new groceries, IMF also sends reminders via text to the user when they exhaust an item, telling them to buy more.

TECHNICAL DESCRIPTION

RFID: The current location of each item in the fridge is kept track of using radio-frequency identification. The items in the fridge each have a unique RFID tag. The tag is scanned by the RFID sensor every time an item is removed or put in the fridge. The device is programmed so that the location of each item is stored in an array with ‘1’ meaning it is currently in the fridge, and ‘0’ meaning it is outside the fridge. The names of the items and the tag numbers corresponding to each item are also stored in arrays. These 3 arrays are parallel, so the index number of the array is used to link the name, tag and location of each item. When an RFID tag is scanned, the sensor reads the tag number, and the location is changed to ‘1’ if the current location is ‘0’ and vice versa.

Bluetooth: Our code for the Bluetooth communication was written so that the array index numbers of all the items that are currently in the fridge are sent from the master module to the slave. This Bluetooth communication sends an updated list of what’s in the fridge every time an item is taken out or put in the fridge. Every time the button that is on the remote is pushed, the LCD screen displays the names of the items in the fridge. The Bluetooth receiver code contains the array of names of items in the fridge, so the array index numbers it reads from the master module are used to find the names of the items.

Arduino serial communication: The arduino that contains the RFID sensor and Bluetooth receiver is connected by wire to a second arduino. When an item is removed from or put in the fridge, the array index of the item and its location are sent via wire to the second arduino. The location is updated in the code for the second arduino. The code for the second arduino contains the array of item names in the fridge, as well as an array with the locations. The array index number it reads from the first arduino is used to identify the name of the item.

Ethernet: An Ethernet shield is coupled to the second arduino. Every time an item is taken out of the fridge and is not put back after a period of time (e.g. 12 hours) IMF considers the item exhausted. When an item is removed from the fridge, the code delays for a certain amount of time and checks to see whether the item is still out of the fridge, or has been returned to the fridge after the delay. If the item is still out of the fridge after this amount of time, an SMS is sent to the user as a reminder to buy more of the item.


CODE

Code for RFID, Bluetooth Master and Serial Communication

#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3);
SoftwareSerial  BTSerial(5, 6); //RX TX

// 3 parallel arrays
String names[5] = {"chips", "mint", "nuts", "apple", "juice"};
String items[5] = {"6A0049C6D8","6A0049C655", "6A0049EFC4", "6F007F61BC", "6A003E3389"};
int location[5] = {1, 1, 1, 1, 0};

boolean notSent;
int notFirst = 0;

void setup() {
  BTSerial.begin(9600); // bluetooth communication
  RFID.begin(9600); // rfid sensor
  Wire.begin(); // serial communication between arduinos
  Serial.begin(9600);
}

byte x = 0;

void loop() {

  // send fridges contents right away
  while (notFirst == 0) {
    firstBluetooth();
    }

  // read RFID tag
  char tagString[11];
  int index = 0;
  String tagnum = "";
  String tagnum2 = "";

  while (RFID.available() > 0) {

    int readByte = RFID.read(); //read next available byte

    if (index <= 10) {
      tagString[index] = readByte;
      index ++;
    }

  }

  tagnum = tagString;
  tagnum2 = tagnum.substring(1, 11);
  if (tagnum2 != "") {
    Serial.print(tagnum2 + " ");
    changeLocation(tagnum2); // update location of item
    resetReader();
  }

  clearTag(tagString); //Clear the char of all value
  resetReader();

  bluetooth(); // start Bluetooth communication

  search(); // check if item is in fridge via serial monitor

}

void resetReader() {
  delay(150);
}

void clearTag(char one[]) {
  // clear the char array by filling with null 
  // Will think same tag has been read otherwise
  for (int i = 0; i <= strlen(one); i++) {
    one[i] = 0;
  }
}

// updates location of fridge
void changeLocation(String tag) {
  for (int j = 0; j < sizeof(location); j++) {
    if (items[j] == tag) {
      if (location[j] == 1) {
        location[j] = 0;
        Serial.println(names[j] + " out of fridge " + "(" + location[j] + ")");
        notSent = true;

        // Serial communication
        Wire.beginTransmission(8); // transmit to other arduino
        Wire.write(j);
        Wire.write(0);// sends one byte
        Serial.println("sent success");
        delay(500);
        Wire.endTransmission(); // stop transmitting
        delay(500);
      }
      else {
        location[j] = 1;
        Serial.println(names[j] + " in fridge " + "(" + location[j] + ")");
        notSent = true;
        // Serial communication - if item is put back into fridge 
        Wire.beginTransmission(8); // transmit to device #8
        Wire.write(j); 
        Wire.write(1); // sends one byte
        Serial.println("sent success");
        delay(500);
        Wire.endTransmission();    // stop transmitting
        delay(500);
      }
    }
  }
}

void bluetooth() {
  if (notSent) {
    for (int j = 0; j < sizeof(names); j++) {
      if (location[j] == 1) {
        BTSerial.print(j);
        Serial.println(j);
      }
    }
    notSent = false;
  }
}

// display contents of fridge without location change
void firstBluetooth() {
  delay(1000);
  if (notFirst == 0) {
    for (int j = 0; j < sizeof(names); j++) {
      if (location[j] == 1) {
        BTSerial.print(j);
        Serial.println(j);
      }
    }
    notFirst = 1;
  }
}

// search for item to see if it's in the fridge 
// via serial monitor
void search() {
  String item;
  if (Serial.available()) {
    item = Serial.readString();

    for (int j = 0; j < sizeof(names); j++) {
      if (item == names[j]) {
        if (location[j] == 1) {
          Serial.println(item + " is in fridge");
        }
        else Serial.println(item + " is not in fridge");
      }
    }
  }
}



Code for Serial Communication and Ethernet

#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <Temboo.h>
#include "TembooAccount.h" // File containing Temboo account information
// used to send SMS
#include <Wire.h> // For serial communication with another arduino

byte ethernetMACAddress[] = ETHERNET_SHIELD_MAC;
EthernetClient client;

int numRuns = 1;   // Execution count, so this doesn't run forever
int maxRuns = 1;   // Maximum number of times the Choreo should be executed
int x;

// parallel arrays with names and locations
String names[5] = {"chips", "mint", "nuts", "apple", "juice"};
int location[5] = {1, 1, 1, 1, 1};


void setup() {
  Wire.begin(8);                
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output

  while (!Serial);

  if (Ethernet.begin(ethernetMACAddress) == 0) {
    //Serial.println("FAIL");
    while (true);
  }
  //Serial.println("OK");
  //delay(1000);

  //Serial.println("Setup complete.\n");
}


// function that executes whenever data is received from master
// this function is registered as an event in setup()
void receiveEvent(int howMany) {

  // Serial communication
  while (1 < Wire.available()) { 
  }

  // read in index and location
  x = Wire.read();    
  Serial.println(x);
  // y = Wire.read();
  // location[x] = y; 
  // Serial.println(y);

  // check location
  if (numRuns <= maxRuns) {
    // delay(60000);
    // if (location[x] == 0) {
    TembooChoreo SendSMSChoreo(client);

    // Invoke the Temboo client
    SendSMSChoreo.begin();

    // Set Temboo account credentials
    SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
    SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    SendSMSChoreo.setAppKey(TEMBOO_APP_KEY);

    // Set Choreo inputs
    String AuthTokenValue = "d558044c31f041db628941ac481d838c";
    SendSMSChoreo.addInput("AuthToken", AuthTokenValue);
    String BodyValue = "Reminder: Buy more " + names[x] + "!";
    SendSMSChoreo.addInput("Body", BodyValue);
    String ToValue = "+12153754459";
    SendSMSChoreo.addInput("To", ToValue);
    String AccountSIDValue = "ACfd625c80670237064ee9dae1fc445844";
    SendSMSChoreo.addInput("AccountSID", AccountSIDValue);
    String FromValue = "+13158025038";
    SendSMSChoreo.addInput("From", FromValue);

    // Identify the Choreo to run
    SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");

    // Run the Choreo; when results are available, print them to serial
    SendSMSChoreo.run();

    while (SendSMSChoreo.available()) {
      char c = SendSMSChoreo.read();
      //Serial.print(c);
    }
    SendSMSChoreo.close();
  //}
  }
}

void loop() {
}



Code for Remote [Bluetooth receiver with LCD Screen & Button]
NB: Serial.print statements included for debugging purposes are commented out 

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
SoftwareSerial  BTSerial(2, 3); //RX TX
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int button = 13; //define button pin
int val = 0;
int oldVal = 0;
int backlight = 10; // define the backlight pin of LCD
//define item's nameLength and row number for printing purposes on the LCD screen
int nameLength = 0;
int row = 0;

// parallel arrays containing names of items and locations
String names[5] = {"chips", "mint", "nuts", "apple", "juice"};
int location[5] = {0, 0, 0, 0, 0}; //0 = out of fridge; 1 = in fridge
// array to translate ascii value, obtained via bluetooth, to decimal value 
int ascii[5] = {48, 49, 50, 51, 52};
int sensorValue;
boolean avail = BTSerial.available();

void setup() {
  BTSerial.begin(9600);
  pinMode(button, OUTPUT);
  pinMode(backlight, OUTPUT); // define the backlight pin as OUTPUT
  digitalWrite(backlight, HIGH); // set the backlight high
  lcd.begin(16, 2); // Print a message to the LCD.
  //printing welcome message to screen
  lcd.print("Welcome to IMF!");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Press me to see");
  delay(2000);
  lcd.setCursor(0, 1); //move cursor to next line
  lcd.println("what's in yo          ");
  delay(2000);
  lcd.clear();
  lcd.setCursor(5,1.5); //move cursor to middle of bottom line in screen
  lcd.print("FRIDGE!");
  delay(2000);
  lcd.clear();
  Serial.begin(9600); //begin serial communication
}

void loop() {
  val = digitalRead(button); //check if button pressed or not
  //Serial.println(val);
  //if button was just pressed right now
  if (val == HIGH && oldVal == LOW) {
//    Serial.println("in here");
    lcd.clear();
    // read information sent by master
    while (BTSerial.available()) {
      char index = BTSerial.read(); //reads index of items currently in fridge from master
      // iterate through array to match ascii value with index
      for (int i = 0; i < sizeof(names); i++) {
        if (ascii[i] == index) {
          // print name of item to LCD screen along the width of the screen.
          //if the list doesn't fit on one line, reset nameLength to 0 and set row = 1
          if (nameLength + names[i].length() > 15) {
            nameLength = 0;
            row = 1;
          }
          //move cursor to next line after the last print word
          lcd.setCursor(nameLength, row);
          //print item name followed by a space
          lcd.print(names[i] + " ");
          //update nameLength everytime an item's name is printed on the screen. the '+1' refers to the gap followed  by an item's name
          nameLength += names[i].length() + 1;
//          Serial.println(names[i]);
          location[i] = 1; //this means that the items getting printed is in the fridge
          // lcd.setCursor(0, 1);
          delay(500);
        }
      }
    }
    //reset row and nameLength
    row = 0;
    nameLength = 0;
//    Serial.println("setting old val to val");
  }
  oldVal = val; //update oldVal
  delay(500);
}

Built With

Share this project:
×

Updates