You can find your Network Settings and assign the values to variables.
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "test 2";
char pass[] = "";
int status = WL_IDLE_STATUS;
void setup() {
Serial.begin(9600);
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(10000);
}
String ssid = WiFi.SSID();
IPAddress ip = WiFi.localIP();
IPAddress subnet = WiFi.subnetMask();
IPAddress gateway = WiFi.gatewayIP();
byte mac[6];
WiFi.macAddress(mac);
String macAddress = String(mac[5], HEX) + (":") +
String(mac[4], HEX) + (":") + String(mac[3], HEX) + (":") +
String(mac[2], HEX) + (":") + String(mac[2], HEX) + (":") +
String(mac[1], HEX) + (":") + String(mac[0], HEX);
Serial.print("SSID: ");
Serial.println(ssid);
Serial.print("IP: ");
Serial.println(ip);
Serial.print("Subnet: ");
Serial.println(subnet);
Serial.print("Gateway: ");
Serial.println(gateway);
Serial.print("MAC: ");
Serial.println(macAddress);
}
void loop() {
}
Be the first to comment