Monimoy Banerjeeshashank kumarDewashish GopeAtul Kashyap
Created August 8, 2020

Rekha 2.0

REKHA 2.0 will provide flexibility of controlling crowd as well as pass them through a sanitization process to avoid risk of COVID 19.

IntermediateFull instructions provided41
Rekha 2.0

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Generic D1286464 Rsi 0.96 Inch 4pin Iic, I2c Oled Display Module for Arduino, Blue
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
PyCharm

Story

Read more

Schematics

CIRCUIT CONNECTIONS

CIRCUIT IMAGE

Code

Main code

Arduino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include<Servo.h>
#include<DHT.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define servopin 8
Servo gate;

#define dhtPin 11
#define dhtType DHT11
DHT dht(dhtPin,dhtType);

#define trigRch1 10
#define trigRch2 9

#define handp 6

#define led 5

float tempe = 0;
float hum = 0;
float speedofSound = 0;
float speedofSoundCm = 0;

int insideCount = 0

float uin()
{
  float timein = 0;
  pinMode(trigRch1,OUTPUT);
  digitalWrite(trigRch1,LOW);
  delayMicroseconds(2);
  digitalWrite(trigRch1,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigRch1,LOW);
  pinMode(trigRch1,INPUT);
  timein = pulseIn(trigRch1,HIGH);
  return timein;
}

float uout()
{
  float timeout = 0;
  pinMode(trigRch2,OUTPUT);
  digitalWrite(trigRch2,LOW);
  delayMicroseconds(2);
  digitalWrite(trigRch2,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigRch2,LOW);
  pinMode(trigRch2,INPUT);
  timeout = pulseIn(trigRch2,HIGH);
  return timeout;
}

void setup()
{
  Serial.begin(115200);
  dht.begin();
  gate.attach(servopin);
  gate.write(70);
  pinMode(led,OUTPUT);
  pinMode(handp,INPUT);
  pinMode(led,OUTPUT);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("STARTING........");
  display.setCursor(0,10);
  display.print("PLEASE WAIT");
  display.display();
  delay(2000);
}
void loop()
{
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("PEOPLES INSIDE");
  display.setCursor(0,10);
  display.print(insideCount);
  display.display();
  
  float enterDist = 0;
  float exitDist = 0;
  float ldr = 0;
  int handDist = 0;
  float inTime = 0;
  float outTime = 0;
  
  tempe = dht.readTemperature();
  hum = dht.readHumidity();
  speedofSound = 331.4+(0.606*tempe)+(0.0124*hum);
  speedofSoundCm = speedofSound/10000;

  inTime = uin();
  outTime = uout();
  
  enterDist = (inTime/2)*speedofSoundCm;
  exitDist = (outTime/2)*speedofSoundCm;
  handDist = digitalRead(handp);
  
  if(enterDist <= 10 && insideCount<5)
  {
    insideCount = insideCount + 1;
    gate.write(180);
    Serial.println("GATE OPENED");
    Serial.println(insideCount);
    delay(2000);
    gate.write(70);
    Serial.println("PLEASE SANITIZE YOUR HAND");
    Serial.println(insideCount);
    
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setTextSize(1);
    display.setCursor(0,0);
    display.print("WARNING..........");
    display.setCursor(0,10);
    display.print("PLEASE SANITIZE HAND");
    display.display();
    while(handDist == 1)
    {
      handDist = digitalRead(handp);
    }
    digitalWrite(led,HIGH);
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setTextSize(1);
    display.setCursor(0,0);
    display.print("DONT REMOVE HAND");
    display.setCursor(0,10);
    display.print("WHILE SANITIZING");
    display.display();
    
    delay(2000);
    digitalWrite(led,LOW);
    Serial.println("SANITIZATION DONE");
    Serial.println(insideCount);
    
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setTextSize(1);
    display.setCursor(0,0);
    display.print("PROCESS COMPLETE");
    display.setCursor(0,10);
    display.print("THANKS FOR USING");
    display.display();
    
    delay(1000);
    
  }

  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("PEOPLES INSIDE");
  display.setCursor(0,10);
  display.print(insideCount);
  display.display();
  
  if(exitDist <= 10 && insideCount>0)
  {
    insideCount = insideCount - 1;
    gate.write(180);
    Serial.println("GATE OPENED");
    Serial.println(insideCount);
    delay(2000);
    gate.write(70);
    Serial.println("GATE CLOSED");
    Serial.println(insideCount);
  }
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("PEOPLES INSIDE");
  display.setCursor(0,10);
  display.print(insideCount);
  display.display();  
}

Python Code

Python
import serial
import time
import cv2

font = cv2.FONT_ITALIC
line = cv2.LINE_4

i = 1

arduino = serial.Serial("com9",115200)
time.sleep(1)
while(True):
    if i == 1:
        while(arduino.inWaiting()==0):
            img = cv2.imread("covv.jpg", -1)
            img = cv2.resize(img, (1366, 768))
            img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (0, 0, 0), 8, line)
            img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (255, 255, 255), 4, line)
            img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (0, 0, 0), 8, line)
            img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (255, 255, 255), 4, line)
            img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (0, 0, 0), 6, line)
            img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (255, 255, 255), 3, line)
            cv2.imshow("bab", img)
            if cv2.waitKey(1) == ord("q"):
                break
            pass
        i = i+1
    data = arduino.readline()
    data = str(data,"utf-8")
    print(data)
    img = cv2.imread("covv.jpg", -1)
    img = cv2.resize(img, (1366, 768))
    img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (0, 0, 0), 8, line)
    img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (255, 255, 255), 4, line)
    img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (0, 0, 0), 8, line)
    img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (255, 255, 255), 4, line)
    img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (0, 0, 0), 6, line)
    img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (255, 255, 255), 3, line)
    img = cv2.putText(img, data, (400, 500), font, 1, (0, 0, 0), 6, line)
    img = cv2.putText(img, data, (400, 500), font, 1, (255, 255, 255), 3, line)
    cv2.imshow("bab", img)
    if cv2.waitKey(1) == ord("q"):
        break
    pass
    while (arduino.inWaiting() == 0):
        pass
    val = arduino.readline()
    val = str(val, "utf-8")
    print(data)
    img = cv2.imread("covv.jpg", -1)
    img = cv2.resize(img, (1366, 768))
    img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (0, 0, 0), 8, line)
    img = cv2.putText(img, "REKHA 2.0 COVID PROTECTION", (200, 100), font, 2, (255, 255, 255), 4, line)
    img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (0, 0, 0), 8, line)
    img = cv2.putText(img, "PEOPLE INSIDE : ", (200, 300), font, 2, (255, 255, 255), 4, line)
    img = cv2.putText(img, val, (750, 300), font, 2, (0, 0, 0), 8, line)
    img = cv2.putText(img, val, (750, 300), font, 2, (255, 255, 255), 4, line)
    img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (0, 0, 0), 6, line)
    img = cv2.putText(img, "STATUS : ", (200, 500), font, 1, (255, 255, 255), 3, line)
    img = cv2.putText(img, data, (400, 500), font, 1, (0, 0, 0), 6, line)
    img = cv2.putText(img, data, (400, 500), font, 1, (255, 255, 255), 3, line)
    cv2.imshow("bab", img)
    if cv2.waitKey(1) == ord("q"):
        break
    pass

Credits

Monimoy Banerjee

Monimoy Banerjee

1 project • 1 follower
shashank kumar

shashank kumar

0 projects • 1 follower
Dewashish Gope

Dewashish Gope

0 projects • 1 follower
Atul Kashyap

Atul Kashyap

0 projects • 0 followers

Comments