Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "WiFi.h"
#include <U8x8lib.h>
// the OLED used
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 15, /* data=*/ 4, /* reset=*/ 16);
void setup()
{
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r);
}
static void doSomeWork()
{
int n = WiFi.scanNetworks();
if (n == 0) {
u8x8.drawString(0, 0, "Searching networks.");
} else {
u8x8.drawString(0, 0, "Networks found: ");
for (int i = 0; i < n; ++i) {
// Print SSID for each network found
char currentSSID[64];
WiFi.SSID(i).toCharArray(currentSSID, 64);
u8x8.drawString(0, i + 1, currentSSID);
}
}
// Wait a bit before scanning again
delay(5000);
}
void loop()
{
doSomeWork();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.