Yes, i have found the Arduino examples for WiFi.localIP(), WiFi.subnetMask(), WiFi.gatewayIP(), and Wifi.dnsIP(), and they all print fine on my ILI9341 TFT-screen with Adafruit ILI9341.h library, but I dont know how to "convert this" into a u8g2 string format for my OLED display.....
.....
These are the arduino examples.
Find & Print local IP WiFi.localIP():
#include <WiFi.h>
char ssid[] = "yourNetwork"; //SSID of your network
int status = WL_IDLE_STATUS; // the Wifi radio's status
IPAddress ip; // the IP address of your shield
void setup()
{
// initialize serial:
Serial.begin(9600);
WiFi.begin(ssid);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// if you are connected, print out info about the connection:
else {
//print the local IP address
ip = WiFi.localIP();
Serial.println(ip);
}
}
void loop () {}
Find & Print WiFi Subnet mask WiFi.subnetMask():
:
#include <WiFi.h>
int status = WL_IDLE_STATUS; // the Wifi radio's status
//SSID of your network
char ssid[] = "yourNetwork";
//password of your WPA Network
char pass[] = "secretPassword";
IPAddress ip;
IPAddress subnet;
IPAddress gateway;
void setup()
{
WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// if you are connected, print out info about the connection:
else {
// print your subnet mask:
subnet = WiFi.subnetMask();
Serial.print("NETMASK: ");
Serial.println(subnet);
}
}
void loop () {
}
Find & Print Gateway : WiFi.gatewayIP():
#include <SPI.h>
#include <WiFi.h>
int status = WL_IDLE_STATUS; // the Wifi radio's status
//SSID of your network
char ssid[] = "yourNetwork";
//password of your WPA Network
char pass[] = "secretPassword";
IPAddress gateway;
void setup()
{
Serial.begin(9600);
WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// if you are connected, print out info about the connection:
else {
// print your gateway address:
gateway = WiFi.gatewayIP();
Serial.print("GATEWAY: ");
Serial.println(gateway);
}
}
void loop () {}
Find & Print DNS : WiFi.dnsIP():
#include <SPI.h>
#include <WiFi.h>
// the IP address for the shield:
IPAddress dns(8, 8, 8, 8); //Google dns
char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
void setup()
{
// Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while(true); // don't continue
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// print your WiFi shield's IP address:
WiFi.setDNS(dns);
Serial.print("Dns configured.");
}
void loop () {
}
How do I find out how to convert this info into the type of string that u8g2.drawString understands ??
I would be more than happy if I there was an easy way to use oled u8g2.drawString routine something like this :
u8g2.drawStr(1,10,WiFi.localIP());
u8g2.drawStr(1,20,WiFi.subnetMask());
u8g2.drawStr(1,30,WiFi.gatewayIP());
u8g2.drawStr(1,40,WiFi.dnsIP());
(I know that the Arduino example in my text is for WiFi.set(dns), not for "getDNS", (cant recall where I saw the "getDNS example), but the command WiFi.dnsIP() works fine on my "reference euipement" :
Wemos /ILI9341TFT display/Adafruit_ILI9346.h library,
so the WiFi.dnsIP() routine is ok.....)
This is what u8g2 expects :
drawStr(u8g2_uint_t x, u8g2_uint_t y, const char *s)