Created
October 20, 2021 13:44
-
-
Save elbruno/86d1a34839e4bb93ba3ef1e382bf92d6 to your computer and use it in GitHub Desktop.
WioTerminalWifiConnect.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rpcWiFi.h" | |
#include <WiFiClientSecure.h> | |
#include"TFT_eSPI.h" | |
TFT_eSPI tft; | |
const char* ssid = "yourNetworkName"; | |
const char* password = "yourNetworkPassword"; | |
int connectingSeconds = 0; | |
WiFiClientSecure client; | |
void setup() { | |
tft.begin(); | |
tft.setRotation(3); | |
tft.fillScreen(TFT_BLACK); | |
tft.setTextSize(2); | |
tft.setCursor(40, 50); | |
tft.print("El Bruno - @elbruno"); | |
tft.setCursor(40, 75); | |
tft.print("Connecting to Wi-Fi.."); | |
// Set WiFi to station mode and disconnect from an AP if it was previously connected | |
WiFi.mode(WIFI_STA); | |
WiFi.disconnect(); | |
WiFi.begin(ssid, password); | |
// attempt to connect to Wifi network: | |
while (WiFi.status() != WL_CONNECTED) { | |
connectingSeconds++; | |
tft.setCursor(40, 100); | |
tft.print("Seconds waiting: "); | |
tft.setCursor((40 + tft.textWidth("Seconds waiting: ")), 100); | |
tft.print(connectingSeconds); | |
// wait 1 second for re-trying | |
delay(1000); | |
WiFi.begin(ssid, password); | |
} | |
tft.setCursor(40, 125); | |
tft.print("Connected!"); | |
tft.setCursor(40, 150); | |
tft.print("IP: "); | |
tft.setCursor((40 + tft.textWidth("IP: ")), 150); | |
tft.print(WiFi.localIP()); | |
} | |
void loop() { | |
// do nothing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment