Devices & Components
Arduino Nano 33 IoT
USB-A to Micro-USB Cable
Software & Tools
Arduino IDE
Visual Studio 2017
Visual Micro
Project description
Code
NetworkDisplay.ino
arduino
Networking Helper Functions from WiFi NINA Examples on Arduino Website
1 2void printWiFiData() { 3 4 // print your board's IP address: 5 6 IPAddress ip = WiFi.localIP(); 7 8 Serial.print("IP address : "); 9 10 Serial.println(ip); 11 12 Serial.print("Subnet mask: "); 13 14 Serial.println((IPAddress)WiFi.subnetMask()); 15 16 Serial.print("Gateway IP : "); 17 18 Serial.println((IPAddress)WiFi.gatewayIP()); 19 20 // print your MAC address: 21 22 byte mac[6]; 23 24 WiFi.macAddress(mac); 25 26 Serial.print("MAC address: "); 27 28 printMacAddress(mac); 29} 30 31void printCurrentNet() { 32 33 // print the SSID of the network you're attached to: 34 35 Serial.print("SSID: "); 36 37 Serial.println(WiFi.SSID()); 38 39 // print the MAC address of the router you're attached to: 40 41 byte bssid[6]; 42 43 WiFi.BSSID(bssid); 44 45 Serial.print("BSSID: "); 46 47 printMacAddress(bssid); 48 49 // print the received signal strength: 50 51 long rssi = WiFi.RSSI(); 52 53 Serial.print("signal strength (RSSI): "); 54 55 Serial.println(rssi); 56 57 // print the encryption type: 58 59 byte encryption = WiFi.encryptionType(); 60 61 Serial.print("Encryption Type: "); 62 63 Serial.println(encryption, HEX); 64 65 Serial.println(); 66} 67 68void printMacAddress(byte mac[]) { 69 70 for (int i = 5; i >= 0; i--) { 71 72 if (mac[i] < 16) { 73 74 Serial.print("0"); 75 76 } 77 78 Serial.print(mac[i], HEX); 79 80 if (i > 0) { 81 82 Serial.print(":"); 83 84 } 85 86 } 87 88 Serial.println(); 89} 90
Secrets.h
arduino
Somewhere to store your wifi credentials outside of main sketch
1#pragma once 2#define WIFI_SSID "******" 3#define WIFI_PASS "******"
Secrets.h
arduino
Somewhere to store your wifi credentials outside of main sketch
1#pragma once 2#define WIFI_SSID "******" 3#define WIFI_PASS "******"
WifiNINA_UDPVMDebugger.ino
arduino
Mainh Sketch to use with Debugging Example
1#include <SPI.h> 2#include <WiFiNINA.h> 3#include "Secrets.h" 4 5char ssid[] = WIFI_SSID; // your network SSID (name) 6char pass[] = WIFI_PASS; // your network password (use for WPA, or use as key for WEP) 7int status = WL_IDLE_STATUS; // the WiFi radio's status 8 9int pingResult; 10// the setup function runs once when you press reset or power the board 11void setup() { 12 // initialize digital pin 13 as an output. 13 pinMode(LED_BUILTIN, OUTPUT); 14 15 while (status != WL_CONNECTED) { 16 Serial.print("Attempting to connect to WPA SSID: "); 17 Serial.println(ssid); 18 // Connect to WPA/WPA2 network: 19 status = WiFi.begin(ssid, pass); 20 // Wait for connection: 21 while (WiFi.status() != WL_CONNECTED) { 22 delay(1); 23 Serial.print("."); 24 } 25 // you're connected now, so print out the data: 26 Serial.println("You're connected to the network"); 27 // Print out the Wifi Info 28 printCurrentNet(); 29 printWiFiData(); 30 } 31} 32 33 34// the loop function runs over and over again forever 35void loop() { 36 digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 37 delay(1000); // wait for a second 38 digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 39 delay(1000); // wait for a second 40 41 // Print out the Wifi Info 42 printCurrentNet(); 43 printWiFiData(); 44} 45
NetworkDisplay.ino
arduino
Networking Helper Functions from WiFi NINA Examples on Arduino Website
1 2void printWiFiData() { 3 4 // print your board's IP address: 5 6 7 IPAddress ip = WiFi.localIP(); 8 9 Serial.print("IP address : "); 10 11 12 Serial.println(ip); 13 14 Serial.print("Subnet mask: "); 15 16 Serial.println((IPAddress)WiFi.subnetMask()); 17 18 19 Serial.print("Gateway IP : "); 20 21 Serial.println((IPAddress)WiFi.gatewayIP()); 22 23 24 // print your MAC address: 25 26 byte mac[6]; 27 28 WiFi.macAddress(mac); 29 30 31 Serial.print("MAC address: "); 32 33 printMacAddress(mac); 34} 35 36void 37 printCurrentNet() { 38 39 // print the SSID of the network you're attached 40 to: 41 42 Serial.print("SSID: "); 43 44 Serial.println(WiFi.SSID()); 45 46 47 // print the MAC address of the router you're attached to: 48 49 byte bssid[6]; 50 51 52 WiFi.BSSID(bssid); 53 54 Serial.print("BSSID: "); 55 56 printMacAddress(bssid); 57 58 59 // print the received signal strength: 60 61 long rssi = WiFi.RSSI(); 62 63 64 Serial.print("signal strength (RSSI): "); 65 66 Serial.println(rssi); 67 68 69 // print the encryption type: 70 71 byte encryption = WiFi.encryptionType(); 72 73 74 Serial.print("Encryption Type: "); 75 76 Serial.println(encryption, HEX); 77 78 79 Serial.println(); 80} 81 82void printMacAddress(byte mac[]) { 83 84 for 85 (int i = 5; i >= 0; i--) { 86 87 if (mac[i] < 16) { 88 89 Serial.print("0"); 90 91 92 } 93 94 Serial.print(mac[i], HEX); 95 96 if (i > 0) { 97 98 99 Serial.print(":"); 100 101 } 102 103 } 104 105 Serial.println(); 106} 107
Downloadable files
Board
Just connect the board to your PC via the USB Lead, no additional wiring required for the debugging.
Board
Board
Just connect the board to your PC via the USB Lead, no additional wiring required for the debugging.
Board
Comments
Only logged in users can leave comments