Anmol S Bhosale
Published

Touchless Doorbell

To avoid the Germ infection The team has designed the "Touchless Doorbell"

IntermediateProtip824
Touchless Doorbell

Things used in this project

Story

Read more

Schematics

Circuit diagram

This diagram shows the connections of the sensors

Code

Code

Arduino
This code consist of Sending data to things speak and getting tweet
#define SECRET_SSID    "Anmol-4g"
#define SECRET_PASS    "sark@1968"
#define CHANNEL_ID     CID
#define WRITE_APIKEY   "KEY"
#define TRIGGER D7
#define ECHO  D8
#include <LiquidCrystal_I2C.h>
#include "ThingSpeak.h"

LiquidCrystal_I2C lcd(0x27, 16, 2);
unsigned long myChannelNumber =  1894990;
const char * myWriteAPIKey = "TIBX52T8E173RFDR";

#include <ESP8266WiFi.h>

char ssid[] = SECRET_SSID;   // your network SSID (name)
char pass[] = SECRET_PASS;   // your network password
int keyIndex = 0;            // your network key index number (needed only for WEP)
const int REF_VIN=3.3; 
int i=0;
int count=0;
const int buzzer = D3;
WiFiClient  client;

void setup() {
  Serial.begin(115200);
  pinMode(TRIGGER, OUTPUT);
  pinMode(ECHO, INPUT);
  pinMode(D0, OUTPUT);//red light
  pinMode(buzzer, OUTPUT);
    lcd.begin();
  lcd.backlight();
  delay(100);
Serial.println();
  WiFi.mode(WIFI_STA);

  ThingSpeak.begin(client);
}

float project()
{
 float voltage= analogRead(A0);
 float tmpVal= {(voltage/1023.0)*REF_VIN*100};
 long duration, distance;
 
 
  digitalWrite(TRIGGER, LOW);  
  delayMicroseconds(2);
  digitalWrite(TRIGGER, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGER, LOW);
  duration = pulseIn(ECHO, HIGH);
  distance = (duration/2) / 29.1;
  lcd.clear();
  if(distance <=20) // If the sensor detects an obstacle less than 20 cm in distance, the LED will start to blink.
  {   tone(buzzer, 2000); // Send 1KHz sound signal...
      delay(1000);        // ...for 1 sec
      noTone(buzzer);     // Stop sound...
      delay(1000); 
      
 
  if(tmpVal>54){
      digitalWrite (D0, HIGH);
     lcd.setCursor(4, 0);
    lcd.print("Red Alert: ");
    lcd.setCursor(0,1); //Next Line
    lcd.print("High Temperature");
       
    }
 else{
      digitalWrite (D0, LOW);
    for( i=0;i<=15;i++)
     {
      tone(buzzer, 800); // Send 1KHz sound signal...
      delay(100);        // ...for 1 sec
      noTone(buzzer);     // Stop sound...
      delay(100);
      }
    lcd.setCursor(0, 0);
    lcd.print("Alert:Open Door ");
    lcd.setCursor(5,1); //Next Line
    lcd.print("Normal Temperature");
      count++;
   }
   
   }
  delay(50);
   
  Serial.println(tmpVal);
  //Serial.println("Duration is:  " + String(duration));
  //Serial.print("Distance is:  ");
  //Serial.print(distance);
  //Serial.println("  Centimeter:");
  Serial.print("No of People in Room are : ");
  Serial.println(count);
  return count;
  
  delay(1000);

}

void loop() {
int tempVal;
  // Connect or reconnect to WiFi
  if (WiFi.status() != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(SECRET_SSID);
    while (WiFi.status() != WL_CONNECTED) {
      WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
      Serial.print(".");
      delay(5000);
    }
    Serial.println("\nConnected.");
  }

  // Get temperature value from sensor
  tempVal =  project();

  // Write value to Field 1 of a ThingSpeak Channel
  int httpCode = 
  httpCode = ThingSpeak.writeField(myChannelNumber, 1,  tempVal, myWriteAPIKey);


  if (httpCode == 200) {
    Serial.println("Channel write successful.");
  }
  else {
    Serial.println("Problem writing to channel. HTTP error code " + String(httpCode));
  }

  // Wait 20 seconds to update the channel again
  delay(20000);
}

Credits

Anmol S Bhosale

Anmol S Bhosale

1 project • 0 followers
Thanks to Chirag Bankapur, Pruthviraj Yarikoppa, and Spoorti Revankar.

Comments