LAB 4 - MINI PROJECT - TEMPERATURE SCANNING SYSTEM

 LAB 4 - MINI PROJECT 


TEMPERATURE SCANNING SYSTEM

Introduction

The main idea of this project is to develop an automatic temperature scanning system. The system is targeted to be set up at the front of a premise or business establishment. When a customer come, they have to measure their own body temperature using the system before stepping inside of the premise. If their temperature is below threshold, they may be given the permission to enter the premise without any restriction. However, if their body temperature exceeds the threshold, they may not enter the premise. The device is connected to a dashboard device on a smartphone via Wi-Fi connection to enable us to monitor the temperature reading. 

Methodology

Components :

1 x ESP32 DEVKIT V1

1 x MLX90614 IR Temperature Sensor

1 x HC-SRO4 Ultrasonic Sensor

2 x LEDs (Green & Red)

1 x Piezoelectric Buzzer

2 x 220Ω Resistor

1 x 200Ω Resistor

1 x Breadboard

Software :

Blynk


Schematic 


Figure 1: Temperature Scanning System Schematic

The figure above shows the connection between each components and ESP32 board. First and foremost, the HC-SR04's Trigger and Echo pin are connected to ESP32's GPIO 5 and GPIO18 respectively. Next, the MLX90614's SCL and SDA pin are connected to ESP32's GPIO 22 and GPIO 21 respectively. Both sensors are being put together near each other as to accurately measure the distance and temperature of the object at one place. The green LED is connected to GPIO 17 while the red LED is connected to GPIO 16. Two 220Ω resistors each are placed together with each green and red LED to eliminate the risk of damage to the LED. Last but not least, the piezoelectric buzzer is connected to GPIO4. A 200Ω resistor is placed together with the buzzer to reduce the sound of the buzzer. The whole circuit is powered by connecting them to the ESP32's GND and 3V3 pin.


Figure 2 : Temperature Scanning System Circuit

The above figure shows the circuitry made by referencing the schematic shown in Figure 1.

System Overview

Both the MLX90614 and HC-SR04 sensor operate immediately once the ESP32 is powered. Both the reading of distance and temperature are displayed on the Serial Monitor at the rate of 750ms or 0.75s. The figure below shows how both readings are displayed on the Serial Monitor.


Figure 3: Serial Monitor

When a hand or any part of the human body is placed in front of both sensors at the distance of 8cm or closer, either red or green LED will be triggered. If the temperature recorded is below the threshold (38°C), the green LED will blinks synchronously with the buzzer pitch at the frequency of 3 times in 1 second. However, if the temperature recorded exceeds the threshold, the red LED will blinks synchronously with the buzzer pitch at the frequency of 7 times in 1.3 second.  The video below shows exactly how these works.



The system also has the feature of monitoring—to monitor the recorded temperature provided on the software application Blynk. The Blynk application is connected to the circuit via local Wi-Fi network. To allows this, the called function of displaying the temperature is addressed to the virtual pins V1 on the Blynk software. The virtual pins are used for enabling the Blynk software to communicate with the circuit to read data or to control the components. The figure below shows the interface of the Blynk software displaying the temperature recorded by MLX90614 sensor.


Figure 4: Blynk interface


Demonstration



Code


#include <Wire.h>
#include <Adafruit_MLX90614.h>
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

const int triggerPin=5;
const int echoPin=18;
const int greenLED=17;
const int redLED=16;
const int buzzer=4;

double temperature;
long duration;
int distance=0;

char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";
 
BlynkTimer timer;

void PushTime() {
  Blynk.virtualWrite(V1, temperature);
}

void setup() {
  pinMode(triggerPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(115200);
  mlx.begin(); 

  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(750L, PushTime);
}

void loop() {
  Blynk.run();
  timer.run();
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance=duration*0.034/2;
  
  Serial.print("Temperature: "); 
  Serial.print(mlx.readObjectTempC()+4); 
  Serial.println("*C");
  Serial.print("Distance: ");
  Serial.println(distance);
  
  temperature=mlx.readObjectTempC()+4;
  if(distance <= 8) {
     if(temperature > 38) {
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(100);
       digitalWrite(redLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(100);
       digitalWrite(redLED, LOW);
       digitalWrite(buzzer, LOW);
     }
     else {
       digitalWrite(greenLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(200);
       digitalWrite(greenLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(200);
       digitalWrite(greenLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(200);
       digitalWrite(greenLED, LOW);
       digitalWrite(buzzer, LOW);
       delay(200);
       digitalWrite(greenLED, HIGH);
       digitalWrite(buzzer,HIGH);
       delay(200);
       digitalWrite(greenLED, LOW);
       digitalWrite(buzzer, LOW);
     }
  }
delay(750);
}


Note

The line of code that program the MLX90614 to read object temperature, 'mlx.readObjectTempC()' is incremented by 4°C to average out the reading around normal human body temperature which is not before the increment due to inaccuracy of the sensor.




Comments

Popular posts from this blog

LAB 1 - D’ARSONVAL GALVANOMETER