Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created October 20, 2021 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/86d1a34839e4bb93ba3ef1e382bf92d6 to your computer and use it in GitHub Desktop.
Save elbruno/86d1a34839e4bb93ba3ef1e382bf92d6 to your computer and use it in GitHub Desktop.
WioTerminalWifiConnect.cpp
#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