With just a few mods you could probably also set it up to look for say, open wifi nodes and probably even modify it to give you a number of beeps based on the strongest signal or something similar.
/*
This sketch demonstrates how to scan WiFi networks.
The API is almost the same as with the WiFi Shield library,
the most obvious difference being the different file you need to include:
*/
#include <ESP8266WiFi.h>
#define PIEZO 5
#define LED 16 // Led in NodeMCU at pin GPIO16 (D0).
String target = "NETGEAR60";
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT); // Initialize the LED_BUILTIN pin as an output
pinMode(PIEZO, OUTPUT);
Serial.println("Setup done");
}
void loop() {
boolean status = scanNetworks();
if (status == true) {
beep();
}
// Wait a bit before scanning again
delay(5000);
}
boolean scanNetworks() {
Serial.println("scan start");
boolean found = false;
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0)
Serial.println("no networks found");
else
{
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i)
{
if (target == WiFi.SSID(i)) {
found = true;
Serial.println("Target Found!");
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
}
}
}
Serial.println("");
return found;
}
void blinkLed(int td) {
digitalWrite(LED, LOW); // Turn the LED on (Note that LOW is the voltage level
delay(td); // Wait for a td milliseconds
digitalWrite(LED, HIGH); // Turn the LED off by making the voltage HIGH
delay(10);
}
void beep() {
int pitch = 150;
int duration = 250;
digitalWrite(LED, LOW); // Turn the LED on (Note that LOW is the voltage level
for (int i = 0; i < duration; i++) {
digitalWrite(PIEZO, HIGH);
delayMicroseconds(pitch);
digitalWrite(PIEZO, LOW);
delayMicroseconds(pitch);
}
digitalWrite(LED, HIGH); // Turn the LED off by making the voltage HIGH
}