SMART FOOD CONTAINER MONITORING SYSTEM (SFCMS)

by divwianaidu in Circuits > Arduino

1847 Views, 3 Favorites, 0 Comments

SMART FOOD CONTAINER MONITORING SYSTEM (SFCMS)

WhatsApp Image 2022-06-29 at 1.24.16 PM.jpeg
WhatsApp Image 2022-06-29 at 1.24.16 PM.jpeg
project iot-Smart Food Cointainer Monitoring System

Introduction of (SFCMS)


Technology largely refers to the application of information for the development of devices and equipment which will be utilized in various ways. These technologies are making everyone’s life easier even than anyone can think. At the same time, people of this generation are busy in their day-to-day life until they do not get enough time to maintain the food storage facilities in their respective homes, restaurants, hotels, and so on. Because of their busy life schedule, they need to buy the food commodities like rice, grains, fruits, and more in bulk quantity to be maintained and used over a period. So, this kind of action can make those people consume spoiled foods because there is no significantly visible sign of food spoilage. Due to a lack of technology and ignorance about methane gas, humidity, and temperature, people fail to maintain their food storage well enough. The quality of the food needs to be monitored and it must be prevented from rotting and decaying by the atmospheric factors like temperature, humidity, and dark. 

To overcome this matter, we came out with a dynamic idea, which is a smart Food Container Monitoring System (SFCMS) that will keep watch on environmental factors like temperature, humidity, methane gas content, and expose the factors' readings. This system can be an internet of Things (IoT) based system as IoT conceptualizes the concept of connecting and remotely monitoring real objects using the internet. Therefore, this system will help to monitor the food storage and maintain it to lead a tension-free healthy life for people.


How does The System work?


This system is built with Arduino UNO which is a popular prototyping board. The Arduino board is connected with two sensors like Ultrasonic which helps to detect people when they get closer to the food container and try to open it. The food container door will open automatically for some second with the help of a servo motor. After a few seconds, the container door will close again. So, this action will help those people to insert their food items easily without wasting their time. Another sensor is an infrared sensor (IR Sensor) to alert users that the door is still open with the help of LED lights. This system is also connected with a piezo buzzer to make a sound by beeping when the door is still open and it will stop once the food container door is closed.

This system is also interfaced with another two sensors without connecting to the Arduino UNO board such as DHT 11 sensor which is to detect the food item's temperature and humidity in food containers and the MQ4 sensor to detect methane gas from foods to read the gas emitted and detect the food condition whether is good or not. The two listed sensors are interfaced with NodeMCU to connect with the internet via a Wi-Fi router. The IoT platform that is used for logging and monitoring the sensor data like humidity, temperature, and methane gas readings is the Thinger.io platform. With the help of the Internet of Things, the environmental factors that affect food storage can be monitored anytime, anywhere from any device.

If the MQ4 sensor senses the methane gas less than 250F, the green led will blink and the red led won't blink. It means the food that we detect is in a good condition and not spoiled yet. If the same MQ4 sensor detects the methane gas equal to and greater than 250F, then the red led will blink and the green led will not blink. This action indicates that the food we detect is spoiled and not in good condition. Not only that, because of the DHT 11 sensor, we also can monitor the temperature and humidity factors of the food too.


Supplies

redlednew.png
greenlednew.png
resistornew.png
buzzernew.png
jumpernew.png
breadboardnew.png
unonew.png
sensor1.png
sensor2.png
sensor3.png
sensor4.png
servomotornew.png
NODEMCUnew.png

Function Components

1) LED Red and Green

  • It's a semiconductor device that emits light when an electric current is passed through it.

2) Resistor

  • To oppose the flow of current through it and the strength of this opposition is termed as its resistance

3) Piezo Buzzer

  • A type of electronic device that's used to produce a tone, alarm, or sound.

4) Jumper Wire

  • Electrical wires with connector pins at each end. They are used to connect two points in a circuit without soldering. For this system, we have used male-to-male and male-to-female jumper wires.

5) Breadboard

  • A solderless construction base is used for developing an electronic circuit and wiring for projects with microcontroller boards like Arduino, LED, and other components.

6) Arduino Uno

  • To read input like light on a sensor, a finger on a button, or a Twitter message and to turn it into an output like activating a motor, turning on an LED, or publishing something online.

7) DHT 11 Sensor

  • An ultra-low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on the data pin (no analog input pins are needed).

8) MQ4 Sensor

  • Methane Gas Sensor detects the concentration of methane gas in the air and outputs its reading as an analog voltage. 

9) Ultrasonic Sensor

  • An electronic device that measures the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal.

10) IR Sensor

  • To emit light in order to sense some object in the surroundings.

11) Servo Motor

  • A closed-loop servomechanism that uses position feedback to control its motion and final position.

12) NodeMCU

  • To connect objects and let data transfer using the Wi-Fi protocol

Designed the Circuits Using Tinkercad

Screenshot 2022-06-28 164013.png
Screenshot 2022-06-28 164244.png

The first circuit shows the connection between Arduino UNO and Breadboard. In this circuit, we have inserted the Ultrasonic Sensor to detect and sense the person or object which helps to send the message to Servo Motor using Arduino Uno. The pins that we used to connect the Ultrasonic Sensor are:-

  • From Vcc of Ultrasonic to Vin of Arduino.
  • From Trig to pin 8 in Arduino Uno
  • From Echo to pin 9 in Arduino Uno
  • From GND to GND of Arduino.

Secondly, in the same circuit, we added the IR Sensor to measure and detect infrared radiation in its surrounding environment from:-

  • OUT pin to pin 2 of Arduino Uno
  • GND pin of IR to GND of Arduino.
  • Vcc pin of lR with Vin of Arduino.

The next component is Piezo Buzzer to makes a sound when the person gets closer to the Smart Food Container. The pins we used are:-

  • Pin the buzzer to pin 7 of Arduino.
  • GND pin to GND of Arduino.

Then, We connected LEDs to pins on Arduino Uno using a resistor.

  • Resistor to cathode pin on LED to GND of Arduino for led.
  • Connect Anode pin on led to pin 13 of Arduino for led.

For the connection of servo motor:-

  • Connected Orange wired of servo motor with pin 11 of Arduino
  • Connected Brown wired of servo motor with GND pin of Arduino
  • Connected Red wired of servo motor with Vcc pin of Arduino Uno


The second circuit is connected to NodeMCU. We inserted an MQ4 Sensor to detect the methane gas in the air and output. The pins we used are:-

  • A0 of MQ4 with Analog channel 0 pin (A0) of NodeMCU.
  • D0 of MQ4 with Digital pin 16 (D1) of NodeMCU
  • GND of MQ4 with GND of NodeMCU
  • Vcc of MQ4 with Vin of NodeMCU

The second component that connects to NodeMCU is DHT 11 Sensor. With the pins:-

  • Vcc to the power of NodeMCU
  • GND of DHT 11 to GND in the board that has a connection to NodeMCU.
  • Pin DATA to pin D4 on NodeMCU

We also added 2 LEDs:-

  • Connected resistor to cathode pin on led to GND of NodeMCU for red led.
  • Connected Anode pin on LED to D8 of NodeMCU for red led.
  • Repeated first and second step to connect green led and connected to pin D7 of NodeMCU.

Build Electronic Circuit

WhatsApp Image 2022-06-28 at 6.34.55 PM.jpeg
WhatsApp Image 2022-06-28 at 6.35.20 PM.jpeg
  • As we all can see, the first image shows the components and connections between the Arduino UNO board and breadboard. This connection was done following the first circuit that was designed using the Tinkercad platform above.
  • And the second image shows the connection to NodeMCU as the second circuit that mentioned above.

Load Sketch to Arduino

After we connected all the components properly and correctly, we need to upload coding based on our project in Arduino Sketch.

Coding for the first circuit

#include<Servo.h>

int trig=8;

int echo=9;

int dt=10;

Servo servo;

int distance;


// ir sensor

int IRSensor = 2; // connect ir sensor to arduino pin 2

int LED = 13; // conect Led to arduino pin 13


//buzzer

const int buzzer = 7; 

void setup() {

pinMode(trig,OUTPUT);

pinMode(echo,INPUT);

Serial.begin(9600);

servo.attach(11);


//Ir sensors

 pinMode (IRSensor, INPUT); // sensor pin INPUT

 pinMode (LED, OUTPUT); // Led pin OUTPUT


 //buzzer

  pinMode(buzzer, OUTPUT);

}


void loop() {

 if (calc_dis()<10)

{

 for (int i=0;i<=100;i++)

 {

  servo.write(i);

  delay(1);

 }

 delay(4000);

 for (int i=100;i>=0;i--)

 {

  servo.write(i);

  delay(1);

 } 

 }

 //IR sensors

 int statusSensor = digitalRead (IRSensor);

  

 if (statusSensor == 1){

  digitalWrite(LED, LOW); // LED LOW

}

 else

 {

  digitalWrite(LED, HIGH); // LED High

  tone(buzzer, 1500); // Send 1KHz sound signal...

  delay(1000);  

  noTone(buzzer);   // Stop sound...

  delay(1000);   // ...for 1 sec

  } 

}

//This code is written to calculate the DISTANCE using ULTRASONIC SENSOR

int calc_dis()

{

 int duration,distance;

 digitalWrite(trig,HIGH);

 delay(dt); 

 digitalWrite(trig,LOW); 

 duration=pulseIn(echo,HIGH);

 distance = (duration/2) / 29.1;

 Serial.print(distance);

 Serial.println("Cm");

 return distance;

}


Coding for the second circuit


// REQUIRES the following Arduino libraries:

// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library

// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor


#define THINGER_SERIAL_DEBUG

#include <ThingerESP8266.h>

#define USERNAME "Najwa02"

#define DEVICE_ID "csw33703_060104"

#define DEVICE_CREDENTIAL "csw33703_060104"

#define SSID "UniSZA-WiFi"

#define SSID_PASSWORD "unisza2016"


ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);


#include "DHT.h"//lib dht


#define DHTPIN 2   // Digital pin connected to the DHT sensor

#define DHTTYPE DHT11  // DHT 11


DHT dht(DHTPIN, DHTTYPE);//dht


//mq4 sensor

const int AO_Pin=0; // Connect AO of MQ4 with Analog channel 0 pin (A0) of Arduino

const int DO_Pin=16; // Connect DO of MQ4 with Digital pin 8 (D8) of Arduino

const int Led_Pin= D7; // Connect an LED with D6 pin of Arduino

int threshold_value; // A variable to store digital output of MQ4

int AO_Out; // stores analog output of MQ4 sensor


void setup() {

 Serial.begin(9600);

 Serial.println(F("DHT11 test!"));

 dht.begin();


  // add WiFi credentials

 thing.add_wifi(SSID, SSID_PASSWORD);


 //connection thinger to dht11

  

 thing["dht11"] >> [](pson& out){

  // Add the values and the corresponding code

  out["humidity"] = dht.readHumidity();

  out["celsius"] = dht.readTemperature();

  };


  //connection mq4 to thinger

  

  thing["Gas_Methane"] >> outputValue(analogRead(A0));

  

//mq4 sensor

Serial.begin(9600); // Initialize serial communictation with a baud rate of 115200

pinMode(DO_Pin, INPUT); // Configure D8 pin as a digital input pin

pinMode(Led_Pin, OUTPUT); //Configure D6 pin as a digital output pin

digitalWrite(Led_Pin, HIGH);

}


void loop() {

  // Wait a few seconds between measurements.

 delay(2000);


 // Reading temperature or humidity takes about 250 milliseconds!

 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

 float h = dht.readHumidity();

 // Read temperature as Celsius (the default)

 float t = dht.readTemperature();

 // Read temperature as Fahrenheit (isFahrenheit = true)

 float f = dht.readTemperature(true);


 // Check if any reads failed and exit early (to try again).

 if (isnan(h) || isnan(t) || isnan(f)) {

  Serial.println(F("Failed to read from DHT sensor!"));

  return;

 }


 // Compute heat index in Fahrenheit (the default)

 float hif = dht.computeHeatIndex(f, h);

 // Compute heat index in Celsius (isFahreheit = false)

 float hic = dht.computeHeatIndex(t, h, false);


 Serial.print(F(" Humidity: "));

 Serial.print(h);

 Serial.print(F("% Temperature: "));

 Serial.print(t);

 Serial.print(F("C "));

 Serial.print(f);

 Serial.print(F("F Heat index: "));

 Serial.print(hic);

 Serial.print(F("C "));

 Serial.print(hif);

 Serial.println(F("F"));


 //mq4

AO_Out= analogRead(AO_Pin); // Take Analog output measurement sample from AO pin of MQ4 sensor

threshold_value= digitalRead(DO_Pin); //Read digital output of MQ4 sensor

Serial.print("Methane Conentration: ");

Serial.println(AO_Out);//prints the methane value

Serial.print("threshold_value: ");

Serial.print(threshold_value);//prints the threshold_value reached as either LOW or HIGH (above or underneath)

delay(1000);

if (AO_Out >= 250){

digitalWrite(Led_Pin, HIGH);//if threshold_value has been reached, LED turns on as status indicator


}

else{

digitalWrite(Led_Pin, LOW);//if threshold not reached, LED remains off

}

 thing.handle();

}


To have a clear view of coding can download the following Arduino Sketch Files

Linked to Thinger

After we uploaded the coding in the Arduino Sketch, make a link to the Thinger.io Platform using an internet connection. To make a connection to Thinger.io, there are two things to have a look which are the setup of NodeMCU and the platform of Thinger.io.

1) NodeMCU Setup

  • Firstly, set up the NodeMCU in Arduino Sketch by adding Arduino compatibility and type http://arduino.esp8266.com/stable/package_esp8266com_index.json at additional boards manager URLs.
  • Secondly, set up the Board Manager by clicking Setup Board Manager and installing ESP8266.
  • Thirdly, select the NodeMCU 1.0 (ESP-12E Module) and check the port number through Device Manager.

2) Platform Thinger.io setup

  • First of all, sign up to the Thinger.io platform by verifying the email.
  • There will be a console Dashboard after, we successfully log in and can see some options like:-
  1. Devices to manage connected devices.
  2. Dashboard to manage dashboard of connected device
  3. Data Buckets to keep historical information
  4. Endpoints to make HTTP requests, send emails, etc
  • Set up the device by clicking Add Device button, and filling up all the information needed. Device Id and Device Credentials should be the same in both Thinger.io and project declaration.
  • To set up the dashboard, click add a dashboard and set the widget.
  • Thirdly, set up the Thinger.io library at Arduino Sketch by clicking the include library option. After that, type in thinger.io. Then, select the latest version and click install.

To make a view in our mobile app, we also can set up the mobile app by adding a device token. Then, set a token name and install the Thinger.io app on a mobile phone to scan the QR code generated from Device Token. Next, check the connected device to view or control the devices from the mobile app. That's all.

Test the Project

WhatsApp Image 2022-06-25 at 2.15.37 PM.jpeg

After we successfully set up the NodeMCU and Thinger.io platform as in step 4, we can see the readings of temperature, Methane Gas, and humidity from the sensors as picture above once the coding is uploaded.

Designed Probes for Modal

WhatsApp Image 2022-06-29 at 1.24.16 PM (1).jpeg

To measure food spoilage over time, both two electronic circuits were assembled and placed inside that pink container. A hole was drilled into the corner of the box and the wire to connect to the computer for data collection was run through it.

Finale Output

WhatsApp Image 2022-06-29 at 1.30.18 PM.jpeg
WhatsApp Image 2022-06-29 at 1.31.12 PM.jpeg

We placed a grapefruit into a medium-sized food container to test the fruit's condition. The levels of methane gas, humidity and temperature of the grapefruit at the appropriate time points were recorded. As the output, we can conclude that the methane gas of the grapefruit is higher than 250F which is 357.0F, and it is considered spoiled and not in good condition. The red led also blink when we test the grapefruit's condition. Not only that, but because of the DHT 11 sensor, we also could monitor the temperature and humidity of the grapefruit as well.


Conclusion:-

In a conclusion, we can see that detecting naturally emitted gases such as Methane, Humidity, and Temperature as food decay can be used to detect food spoilage. This (SFCMS) system is able to detect gas that is released from food items even before the presence of any visible signs of spoilage using the Thinger.io platform. Using those sensors can help detect food spoilage early and prevent the consumption of spoiled food. Moreover, it also can help to maintain the safety and hygiene of the food to keep it fresh and edible which helps in decreasing the food wastage.


Video link:- https://youtu.be/3KstPZjjy3c


References:-

  • https://www.engineersgarage.com/arduino-based-smart-iot-food-quality-monitoring-system/
  • https://www.ijert.org/freshbox-iot-based-pantry-system-with-store-management
  • https://create.arduino.cc/projecthub/nosleep/smart-plastic-container-2b0641
  • https://create.arduino.cc/projecthub/samT/cuisine-assistant-f25118
  • https://www.instructables.com/circuits/projects/