arduinocc
Published © GPL3+

Wifi Debugging for WifiNINA Arduino Boards

If you need to debug your Arduino WifiNINA project remotely, plot charts of monitoring data, and more, this is the project for you...

BeginnerFull instructions provided4,182
Wifi Debugging for WifiNINA Arduino Boards

Things used in this project

Hardware components

Arduino Nano 33 IoT
Arduino Nano 33 IoT
Or other WifiNINA Compatible Board
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Or relevant cable to connect your board to the PC
×1

Software apps and online services

Arduino IDE
Arduino IDE
Visual Studio 2017
Microsoft Visual Studio 2017
Visual Micro

Story

Read more

Schematics

Board

Just connect the board to your PC via the USB Lead, no additional wiring required for the debugging.

Code

WifiNINA_UDPVMDebugger.ino

Arduino
Mainh Sketch to use with Debugging Example
#include <SPI.h>
#include <WiFiNINA.h>
#include "Secrets.h"

char ssid[] = WIFI_SSID;        // your network SSID (name)
char pass[] = WIFI_PASS;    // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;     // the WiFi radio's status

int pingResult;
// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin 13 as an output.
    pinMode(LED_BUILTIN, OUTPUT);

    while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to WPA SSID: ");
        Serial.println(ssid);
        // Connect to WPA/WPA2 network:
        status = WiFi.begin(ssid, pass);
        // Wait for connection:
        while (WiFi.status() != WL_CONNECTED) {
            delay(1);
            Serial.print(".");
        }
        // you're connected now, so print out the data:
        Serial.println("You're connected to the network");
        // Print out the Wifi Info
        printCurrentNet();
        printWiFiData();
    }
}


// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second

  // Print out the Wifi Info
  printCurrentNet();
  printWiFiData();
}

NetworkDisplay.ino

Arduino
Networking Helper Functions from WiFi NINA Examples on Arduino Website
void printWiFiData() {

    // print your board's IP address:

    IPAddress ip = WiFi.localIP();

    Serial.print("IP address : ");

    Serial.println(ip);

    Serial.print("Subnet mask: ");

    Serial.println((IPAddress)WiFi.subnetMask());

    Serial.print("Gateway IP : ");

    Serial.println((IPAddress)WiFi.gatewayIP());

    // print your MAC address:

    byte mac[6];

    WiFi.macAddress(mac);

    Serial.print("MAC address: ");

    printMacAddress(mac);
}

void printCurrentNet() {

    // print the SSID of the network you're attached to:

    Serial.print("SSID: ");

    Serial.println(WiFi.SSID());

    // print the MAC address of the router you're attached to:

    byte bssid[6];

    WiFi.BSSID(bssid);

    Serial.print("BSSID: ");

    printMacAddress(bssid);

    // print the received signal strength:

    long rssi = WiFi.RSSI();

    Serial.print("signal strength (RSSI): ");

    Serial.println(rssi);

    // print the encryption type:

    byte encryption = WiFi.encryptionType();

    Serial.print("Encryption Type: ");

    Serial.println(encryption, HEX);

    Serial.println();
}

void printMacAddress(byte mac[]) {

    for (int i = 5; i >= 0; i--) {

        if (mac[i] < 16) {

            Serial.print("0");

        }

        Serial.print(mac[i], HEX);

        if (i > 0) {

            Serial.print(":");

        }

    }

    Serial.println();
}

Secrets.h

Arduino
Somewhere to store your wifi credentials outside of main sketch
#pragma once
#define WIFI_SSID "******"
#define WIFI_PASS "******"

Credits

arduinocc
5 projects • 13 followers
Arduino compatible IDE for Microsoft Visual Studio and Atmel Studio 7 with unique USB Debugger, Trace, Pin Viewer and Plotter, GDB Debugging
Contact

Comments

Please log in or sign up to comment.