Md. Khairul Alam
Published © MIT

IoT Egg Tray with Humidity & Temperature Monitoring

The IoT egg tray lets you know how many eggs you have left in the fridge and also shows temperature & humidity of your fridge.

IntermediateWork in progress2 hours851
IoT Egg Tray with Humidity & Temperature Monitoring

Things used in this project

Hardware components

SparkFun Blynk Board - ESP8266
SparkFun Blynk Board - ESP8266
×1
Micro Limit Switch
OpenBuilds Micro Limit Switch
×1
Resistor 10k ohm
Resistor 10k ohm
×5
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Designed in Eagle
Schemetic iot

Source_schematic

Connection with Blynk Board

Image iot

Code

Source Code

C/C++
Developed using Arduino IDE
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include "SparkFunHTU21D.h"
#include <SparkFunTSL2561.h>

HTU21D thSense;

#define TEMPERATURE_F_VIRTUAL     V5 
#define TEMPERATURE_C_VIRTUAL     V6 
#define HUMIDITY_VIRTUAL          V7 
#define EGG_NUMBER_READ           V8

////////////////////
// Blynk Settings //
////////////////////
char BlynkAuth[] = "your auth token here"; //replace
char WiFiNetwork[] = "wifi network name here";
char WiFiPassword[] = "password here";

///////////////////////
// Hardware Settings //
///////////////////////

#define EGG_SENSOR_PIN A0

float tempCOffset = 0; //-8.33;
BLYNK_READ(TEMPERATURE_F_VIRTUAL)
{
  float tempC = thSense.readTemperature(); // Read from the temperature sensor
  tempC += tempCOffset; // Add any offset
  float tempF = tempC * 9.0 / 5.0 + 32.0; // Convert to farenheit
  // Create a formatted string with 1 decimal point:
  Blynk.virtualWrite(TEMPERATURE_F_VIRTUAL, tempF); // Update Blynk virtual value
  //BB_DEBUG("Blynk Read TempF: " + String(tempF));
}

BLYNK_READ(TEMPERATURE_C_VIRTUAL)
{
  float tempC = thSense.readTemperature(); // Read from the temperature sensor
  tempC += tempCOffset; // Add any offset
  Blynk.virtualWrite(TEMPERATURE_C_VIRTUAL, tempC); // Update Blynk virtual value
  //BB_DEBUG("Blynk Read TempC: " + String(tempC));
}

BLYNK_READ(HUMIDITY_VIRTUAL)
{
  float humidity = thSense.readHumidity(); // Read from humidity sensor
  Blynk.virtualWrite(HUMIDITY_VIRTUAL, humidity); // Update Blynk virtual value
  //BB_DEBUG("Blynk Read Humidity: " + String(humidity));
}


BLYNK_READ(EGG_NUMBER_READ)
{
  uint8_t eggCount = analogRead(EGG_SENSOR_PIN);
  Serial.println(eggCount);
  //Blynk.virtualWrite(EGG_NUMBER_READ, "You have 2 EGG");
  
  if(eggCount>200){
    Blynk.virtualWrite(EGG_NUMBER_READ, "YOU HAVE 4 EGGs");
    } 
  else if(eggCount<120 && eggCount>100){
    Blynk.virtualWrite(EGG_NUMBER_READ, "You have 2 EGGs");
    }
  else if(eggCount<100 && eggCount>30){
    Blynk.virtualWrite(EGG_NUMBER_READ, "You have 1 EGG");
    //Blynk.notify("You have no Egg");
    }
  else if(eggCount<200 && eggCount>120){
    Blynk.virtualWrite(EGG_NUMBER_READ, "You have 0 EGG");
    Blynk.notify("You have no Egg");
    }
  else if(eggCount>0 && eggCount<30){
    Blynk.virtualWrite(EGG_NUMBER_READ, "You have 3 EGGs");
    }
  
}


void setup()
{
  // Initialize hardware
  Serial.begin(9600); // Serial
  thSense.begin();
  delay(500);  
  // Initialize Blynk
  Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);
}

void loop()
{
  // Execute Blynk.run() as often as possible during the loop
  Blynk.run(); 
}

Credits

Md. Khairul Alam

Md. Khairul Alam

25 projects • 221 followers
Engineer, developer, maker, and hacker.

Comments