Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Rohan Barnwal
Published

AutoTag: Vehicle Proximity Identifier using ESP8266

Build AutoTag, a Vehicle Proximity Identifier using ESP8266, Locate your vehicle effortlessly with a loud beep, making parking lots a breeze

BeginnerFull instructions provided140
AutoTag: Vehicle Proximity Identifier using ESP8266

Things used in this project

Story

Read more

Code

ESP8266 Code

Arduino
#include <ESP8266WiFi.h>
#define BUZZER_PIN D1 // Pin connected to the buzzer

const char* ssid = "Your WiFi SSID";
const char* password = "Your WiFi Password";

bool wasConnected = false;

void startBeeping() {
  for (int i = 0; i < 5; i++) {
    tone(BUZZER_PIN, 2000); // Start beeping at 2 kHz
    delay(200); // Beep for 200 milliseconds
    noTone(BUZZER_PIN); // Stop beeping
    delay(200); // Delay between beeps
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(BUZZER_PIN, OUTPUT);

  WiFi.begin(ssid, password);
  Serial.println("Connecting to WiFi");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());

  wasConnected = true; // Set initial connection status to true

  // Start beeping
  startBeeping();
}

void loop() {
  // Check Wi-Fi connection status
  if (WiFi.status() == WL_CONNECTED) {
    if (!wasConnected) {
      Serial.println("Reconnected to Wi-Fi");
      // Start beeping
      startBeeping();
      wasConnected = true; // Update connection status
    }
  } else {
    wasConnected = false; // Update connection status
    Serial.println("Lost Wi-Fi connection");
  }

  // Other tasks or code in the loop
}

Credits

Rohan Barnwal
27 projects • 35 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!
Contact

Comments

Please log in or sign up to comment.