Wemos Lolin ESP32 OLED Module For Arduino ESP32 OLED WiFi + Bluetooth

Below sketch might be useful as starter for both, Wifi processing as well as OLED display output. I learned from several sketches out there and combined what I needed. Multiple .addAP() calls allow the Lolin32 to work with several access points without recompile. And display.setLogBuffer(5,30) seems to be a nice alternative to Serial output. Sketch connects to Wifi AP, reports its IP address and then logs RSSI (Received Signal Strength Indicator) in a new line every second.

I had problems to take a focused photo of OLED with my Android cameras, only fuzzy photos. So I used PS3 Eye as webcam. Same problem with that in both settings of its adjustable fixed focus zoom lens. Then I learned that I can manually set focus continuously and so I got this photo I wanted:

Hermann.

#include <WiFi.h>
#include <WiFiMulti.h>

WiFiMulti wifiMulti;

#include "SSD1306.h"

SSD1306  display(0x3c, 5, 4);

void setup() {
  display.init();

  display.flipScreenVertically();

  display.setContrast(255);

  display.clear();

  wifiMulti.addAP("FRITZ!Box ... 1", "verySecret");
  wifiMulti.addAP("FRITZ!Box ... 2", "foobar");

  display.setLogBuffer(5, 30);
  display.println("Connecting Wifi...");
  display.drawLogBuffer(0, 0);
  display.display();
  
  if(wifiMulti.run() == WL_CONNECTED) {
    display.println("WiFi connected");
    display.println("IP address: ");
    display.println(WiFi.localIP());
    display.drawLogBuffer(0, 0);
    display.display();
  }
}

void loop() {
  if(wifiMulti.run() != WL_CONNECTED) {
    display.println("WiFi not connected!");
    display.clear();
    display.drawLogBuffer(0, 0);
    display.display();
    delay(1000);
  }
  
  long rssi = WiFi.RSSI();
  display.clear();
  display.print("RSSI:");
  display.println(rssi);
  display.drawLogBuffer(0, 0);
  display.display();
  delay(1000);
}

P.S:
This diff gives a more compact display:

$ diff sketch_oct06e/sketch_oct06e.ino sketch_oct06f/sketch_oct06f.ino 
9a10,11
> int i=0;
> 
29c31
<     display.println("IP address: ");
---
>     display.print("IP ");
47,48c49,51
<   display.print("RSSI:");
<   display.println(rssi);
---
>   display.print(rssi);
>   display.print(" ");
>   if (i++%7==6) display.println();
$