Amaan Javed
Published

NodeMCU SMART GARAGE

Smart Garage that opens when your car comes and gives information on webserver about the car it's there or not

IntermediateFull instructions provided1 hour1,440
NodeMCU SMART GARAGE

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
SparkFun Qwiic Single Relay
SparkFun Qwiic Single Relay
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Code

AP( Access Points )

Arduino
#include <ESP8266WiFi.h>
const char* ssid = "BOOM";
const char* password = "12345678";
void setup()
{ 
  Serial.begin(115200)
  WiFi.softAP(ssid, password);
}
void loop() {
   Serial.println("LOVE YOU AJ")
}
/////////////////AMAAN JAVED//////////////

Webserver

Arduino
#include <ESP8266WiFi.h>
const char* SSID = "CAR";
int32_t getRSSI(const char* target_ssid) {
  byte available_networks = WiFi.scanNetworks();
  for (int network = 0; network < available_networks; network++) {
    if (WiFi.SSID(network).compareTo(target_ssid) == 0) {     
      return WiFi.RSSI(network);
    }
  }
  return 0;
}
const int trigPin = 4;
const int echoPin = 5;
long dur;
float dis;
WiFiServer server(80);
void setup() {
  Serial.begin(115200);
  pinMode(0, OUTPUT); 
   WiFi.begin("........", ".....");///please put your home wifi ssid and pasward
  server.begin();
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin, INPUT);
}
void loop() {
  Serial.println("LOVE YOU AJ")
   digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  dur = pulseIn(echoPin, HIGH);
  dis= dur*0.034/2;
  int32_t rssi = getRSSI(SSID);
  if (rssi > (-50) && rssi != 0) 
  {
    digitalWrite(0, LOW);
    
  }
  else 
  {
    digitalWrite(0,1);
    delay(10000);
    digitalWrite(0,0);
  }
WiFiClient client = server.available();
  if (!client) {
    return;
  }
  String request = client.readStringUntil('\r');
  client.flush();
  if (request.indexOf("/action_page.php?fname=1") != -1)  {
    digitalWrite(0, 1);
    delay(60000);
    digitalWrite(0,0);
  }
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); 
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.println("<center>");
  client.println("<h1 style=background-color:DodgerBlue;>SMART GARAGE</h1>");
  client.println("</center>");  
  client.println("<h3 style=color:Coral;>CAR STATUS:</h3>");
  if (dis >=1900){// tghis is for light that turn off in night and turn in day
    client.println("<h4 style=color:RED;>NOT THERE</h4>");
  }
  else{
    client.println("<h4 style=color:GREEN;>PARKED</h4>");
  }
  client.print("<form action=/action_page.php>");
  client.print("<label for=fname>Emergency Commands for Door:</label><br>");
  client.print("<input type=text id=fname name=fname><br><br>");
  client.print("<input type=submit value=Submit>");
  client.print("</form>");
  client.print("<center>");
  client.print("<h1 style=background-color:DodgerBlue;>BY AMAAN JAVED</h1>");
  client.print("</center>");
  client.println("</html>");
  delay(1); 
}
/////////////////////////////AMAAN JAVED//////////////////////////////////////

Credits

Amaan Javed

Amaan Javed

19 projects • 4 followers
Student

Comments