Mini Project

MINI PROJECT - ELECTRONIC INSTRUMENTATION

Matrix No.  : 192020033

Program      : R2404 Computer Engineering

Project Title: Temperature, Humidity and Distance Sensor for Smart Mirror. 

In this post, I will be showcasing my mini project that I made as an additional component for my final year project which is a Smart Mirror. 


 Introduction 

This mini project consist of 2 sensors, which is temperature & humidity sensor and an ultrasonic sensor. Since the Smart Mirror will get hot after several hours of usage, it is better to monitor the temperature of the smart mirror to prevent the component of the Smart Mirror overheat. Besides that, since the Smart Mirror use a monitor to display features, the monitor could fall down from the frame of the Smart Mirror anytime. Because of that, an ultrasonic sensor is use to measure the distance between the monitor behind the back of the monitor to the wall behind the frame. With this sensor, when the monitor move slightly backward of the frame, the ultrasonic sensor will tell the distance. If the distance is too close to the wall. I will immediately take action to reposition the monitor so that it won't fall. 


 Objectives 

1. To build a project that can measure temperature, humidity and distance. 

2. To implement two sensors.  


 Component 

1. ESP32

  • ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth.














2. DHT11 Sensor

  • DHT11 is a low-cost digital sensor for sensing temperature and humidity. This sensor can be easily interfaced with any micro-controller such as ESP32 to mreasure humidity and temperature instantaneously. 














3. Ultrasonic Sensor

  • An ultrasonic sensor is 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. 














4. LCD 16x2 with l2C

  • This type of LCD is ideal for displaying text and numbers. The l2C LCD that I am using in this mini project comes with a small add-on circuit mounted on the back of the module. 
  • This module features a PCF8574 chup (for l2C communication) and a potentiometer to adjust the LED backlight. 
  • The advantage of an l2C LCD is that the wiring is very simple. 















5. Jumper Wires 














6. Breadboard














  Schematic Diagram 


 Coding 

 #define BLYNK_TEMPLATE_ID "T123LKx-1ZdiG"  
 #define BLYNK_DEVICE_NAME "ESP32"  
 #define BLYNK_AUTH_TOKEN "VT123uXHA-Z85-2DmmxK3pT8akO-0YP3"  
   
   
 //#define BLYNK_PRINT Serial  
   
 #include <WiFiClient.h>  
 #include <BlynkSimpleEsp32.h>  
 #include <DHT.h>  
 #include <Wire.h>   
 #include <LiquidCrystal_I2C.h>  
 #define DHT11PIN 16  
   
 #define TRIGGERPIN D1  
 #define ECHOPIN  D2  
   
 //define sound speed in cm/uS  
 #define SOUND_SPEED 0.034  
 #define CM_TO_INCH 0.393701  
   
   
 char auth[] = BLYNK_AUTH_TOKEN;  
   
 char ssid[] = "--";  
 char pass[] = "--";  
   
 const int trigPin = 5;  
 const int echoPin = 18;  
   
 long duration;  
 float distanceCm;  
 float distanceInch;  
   
   
 DHT dht(DHT11PIN, DHT11);  
   
 // set the LCD number of columns and rows  
 int lcdColumns = 16;  
 int lcdRows = 2;  
   
 // set LCD address, number of columns and rows  
 // if you don't know your display address, run an I2C scanner sketch  
 LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);   
   
   
 byte degree_symbol[8] =   
        {  
         0b00111,  
         0b00101,  
         0b00111,  
         0b00000,  
         0b00000,  
         0b00000,  
         0b00000,  
         0b00000  
        };  
   
 void setup()  
 {  
  Serial.begin(115200);  
  Blynk.begin(auth, ssid, pass);  
   
    
  /* Start the DHT11 Sensor */  
  dht.begin();  
  lcd.init();  
  lcd.backlight();  
  lcd.createChar(0, degree_symbol);  
  lcd.setCursor(0,0);  
  lcd.print(" DHT11  with ");  
  lcd.setCursor(0,1);  
  lcd.print(" ESP32 DevKit ");  
  delay(2000);  
  lcd.clear();  
   
 //Ultrasonic  
  Serial.begin(115200); // Starts the serial communication  
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output  
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input  
 }  
   
 void loop()  
 {  
   
  int humi = dht.readHumidity();  
  float temp = dht.readTemperature();  
  lcd.setCursor(0,0);  
  lcd.print("Temp = ");  
  lcd.print(temp);  
  lcd.write(0);  
  lcd.print("C");  
  lcd.setCursor(0,1);  
  lcd.print("Humidity = ");  
  lcd.print(humi);  
  lcd.print("%");  
  delay(1000);  
   
   
  Blynk.virtualWrite(V5, humi);  
  Blynk.virtualWrite(V6, temp);  
   
   
   
  //Ultrasonic  
  // Clears the trigPin  
   
  digitalWrite(trigPin, LOW);  
  delayMicroseconds(2);  
  // Sets the trigPin on HIGH state for 10 micro seconds  
  digitalWrite(trigPin, HIGH);  
  delayMicroseconds(10);  
  digitalWrite(trigPin, LOW);  
    
  // Reads the echoPin, returns the sound wave travel time in microseconds  
  duration = pulseIn(echoPin, HIGH);  
    
  // Calculate the distance  
  distanceCm = duration * SOUND_SPEED/2;  
    
  // Convert to inches  
  distanceInch = distanceCm * CM_TO_INCH;  
    
  // Prints the distance in the Serial Monitor  
  Serial.print("Distance (cm): ");  
  Serial.println(distanceCm);  
  Serial.print("Distance (inch): ");  
  Serial.println(distanceInch);  
   
  Blynk.virtualWrite(V1, distanceCm);  
    
  Blynk.run();  
    
  delay(1000);   
 }  


 Blynk Application 

















 Result 















 Video Presentation 



 Combining Mini Project & Final Year Project 

The video below shows how I combine both of the mini project as well as my final year project which is a Smart Mirror. 

























 Conclusion 

In conclusion, this mini project is built to monitor the temperature and humidity of the smart mirror. Besides that, the ultrasonic sensor is used to determine the distance between the mirror and the wall behind the mirror to ensure the mirror is staying in place. This mini project helps in ensuring the smart mirror is in good condition and can use for longer period.