Wemos d1 mini wifi scan

Hi

New on the forum.

i have a wifi scan program with wemos d1 mini and a lcd.
i have attached a button to D5.

now i want to show the first ssid and stop until i press the button and then show second ssid etc.

but i can´t figure it out.

anyone has any ideas?

Robert

code:

#include "ESP8266WiFi.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
WiFiClient client;

LiquidCrystal_I2C lcd(0x27,16,2);
const int RSSI_MAX =-50;// define maximum strength of signal in dBm
const int RSSI_MIN =-100;// define minimum strength of signal in dBm
int i=1;
void setup() {
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
pinMode(D5, INPUT_PULLUP);
Serial.begin(115200);
}

void loop() {
SSID_scan();
delay(10000);
}

void SSID_scan() {
lcd.clear();
Serial.println("");
Serial.println("scan start");
lcd.setCursor(0,0);
lcd.print("Scan started");
WiFi.disconnect();
delay(100);
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
if (n == 0) {
Serial.println("no networks found");
lcd.setCursor(3,0);
lcd.print("No networks found");
}
else
{
Serial.print(n);

Serial.println(" networks found");
 lcd.setCursor(0,1);
   lcd.print(n);
   lcd.setCursor(2,1);

lcd.print("Networks found...");
delay(3000);

for (int i = 0; i < n; ++i)
{
   
  // Print SSID and RSSI for each network found
  Serial.print(i + 1);
  Serial.print(": ");
  Serial.print(WiFi.SSID(i));
  Serial.print(WiFi.RSSI(i));
  Serial.print(" (");
  lcd.clear();
  lcd.print(WiFi.SSID(i));
  lcd.setCursor(0,1);
  lcd.print("dBm:");
  lcd.print(WiFi.RSSI(i));
  lcd.setCursor(10,1);
  lcd.print(dBmtoPercentage(WiFi.RSSI(i)));//Signal strength in %  
  lcd.print("%");
  
  int button=digitalRead(D5);
  if (button==HIGH){
          }
 }
                 
 }

Serial.println("scan done");
lcd.print("Scan Done.");

Serial.println("");
}

String encryptionTypeStr(uint8_t authmode) {
switch (authmode) {
case ENC_TYPE_NONE:
return "NONE";
case ENC_TYPE_WEP:
return "WEP";
case ENC_TYPE_TKIP:
return "TKIP";
case ENC_TYPE_CCMP:
return "CCMP";
case ENC_TYPE_AUTO:
return "AUTO";
default:
return "?";;
}
}

int dBmtoPercentage(int dBm)
{
int quality;
if(dBm <= RSSI_MIN)
{
quality = 0;
}
else if(dBm >= RSSI_MAX)
{
quality = 100;
}
else
{
quality = 2 * (dBm + 100);
}

 return quality;

}//dBmtoPercentage

Welcome to the forum

Why did you start a topic in the Uncategorised category of the forum when its description is

:warning: DO NOT CREATE TOPICS IN THIS CATEGORY :warning:

Your topic has been moved to the Programming category

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

1 Like

Sounds interesting, but I cannot read your code nor your schematic showing how it is connected.

@robban75 Hi Robban and welcome to the forum, I realy don´t understand why you´re surching ssid´s when you want to connect to WiFi? You want to use it as a WiFi scanner and use it on the field? You want to display all the WiFi connections available? Right? But how to connect to them is something else, you might need a password.
Greetings dingsken.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.