Skip to content

Instantly share code, notes, and snippets.

@dwblair
Created September 25, 2020 15:13
Show Gist options
  • Save dwblair/d74bb01fbd3514ffd6b5eb5d9b66ab88 to your computer and use it in GitHub Desktop.
Save dwblair/d74bb01fbd3514ffd6b5eb5d9b66ab88 to your computer and use it in GitHub Desktop.
#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