-
Notifications
You must be signed in to change notification settings - Fork 0
/
MULTI-WiFi-IP_OLED.ino
61 lines (54 loc) · 1.8 KB
/
MULTI-WiFi-IP_OLED.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* This sketch trys to Connect to the best AP based on a given list
*
*/
//#include "ESP8266WiFi.h"
#include <WiFi.h>
#include <WiFiMulti.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
WiFiMulti wifiMulti;
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
WiFi.disconnect();
wifiMulti.addAP("Arduino Wifi", "xxxxxxx");
wifiMulti.addAP("ultimate expansion@unifi", "xxxxxxxx");
display.println("Connecting Wifi...");
if(wifiMulti.run() == WL_CONNECTED) {
display.clearDisplay();
display.setCursor(0,18);
display.println("WiFi connected");
display.setCursor(0,36);
display.println("IP address: ");
display.setCursor(0,54);
display.println(WiFi.localIP());
Serial.println("");
display.display();
display.startscrollleft(0x00, 0x0F);
delay(20000);
}
}
void loop()
{
display.clearDisplay(); //clear display @ beginning of each loop
if(wifiMulti.run() != WL_CONNECTED) {
display.println("WiFi not connected!");
Serial.println("");
display.display();
display.startscrollleft(0x00, 0x0F);
delay(2*5000);
}
}