Project tutorial
Wifi Debugging for WifiNINA Arduino Boards

Wifi Debugging for WifiNINA Arduino Boards © GPL3+

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

  • 2,242 views
  • 2 comments
  • 1 respect

Components and supplies

Screenshot 2019 06 14 15 39 45 h3it1wigl4
Arduino Nano 33 IoT
Or other WifiNINA Compatible Board
×1
Adafruit industries ada592 image 75px
USB-A to Micro-USB Cable
Or relevant cable to connect your board to the PC
×1

Apps and online services

About this project

If you have an Arduino board with a WifiNINA compatible chip, you can take advantage of wireless debugging, data plotting and tracing, and conditional breakpoints in your code, with no additional hardware!

Often you need to trace real world sensor data with your board in its true environment instead of on your desk, and it can be frustrating to constantly have to manually add code to track the data you are interested in. The Visual Micro debugger allows you to do all this in a few clicks....

Supported Boards

Currently the below boards are supported, and we will expand this list as more compatible boards become available.

  • Arduino UNO WiFi Rev.2
  • Arduino NANO 33 IoT
  • Arduino MKR 1010
  • Arduino MKR VIDOR 4000 WiFi

Software Setup

The example sketch used in this tutorial is available in the links at the bottom/

  • Set the Wifi Credentials for your network.
  • Build & Upload the Sketch to obtain the IP address of the board from the serial monitor

NOTE - Visual Micro will need updating to at least 2021.01.06.1 (available here) to use with WiFiNINA Boards

Enable Debugging

Now we have the IP address of the board, we can enable the debugging features before detaching it from our USB lead.

  • Select vMicro > Debugging > Debug: Serial
  • Open the Project Properties from vMicro > Project Properties
  • Set the "Remote Transport" option to Udp
  • Enter the IP address into "Local Address" and press ENTER to set it
  • Now add break / trace points into your code as needed (Don't forget the @Plot Commands and Editable Variables are also available)
  • Now Upload your code to the board, the debugger will automatically start

NOTE: If you want to change break/trace points or conditions the code will need to be rebuilt and uploaded to the board again as above.

Video Guide

See our video guide below for a walkthrough of this tutorial:

Further Videos & References:

Visual Micro - Remote Transport Setting Reference

https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Ports.html

Code

WifiNINA_UDPVMDebugger.inoArduino
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.inoArduino
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.hArduino
Somewhere to store your wifi credentials outside of main sketch
#pragma once
#define WIFI_SSID "******"
#define WIFI_PASS "******"

Schematics

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

Comments

Similar projects you might like

Arduino Nano 33 IoT Debugging

Project tutorial by arduinocc

  • 9,305 views
  • 3 comments
  • 14 respects

Arduino Uno Debugging

Project tutorial by arduinocc

  • 12,336 views
  • 0 comments
  • 5 respects

Arduino Nano 33 BLE/IoT Custom Debugging

Project tutorial by arduinocc

  • 6,855 views
  • 2 comments
  • 5 respects

Arduino-ESP WiFi Integration

Project in progress by Turai Botond

  • 18,638 views
  • 11 comments
  • 61 respects

Wifi quality tester

by adameliemorin

  • 3,280 views
  • 3 comments
  • 7 respects

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 116,229 views
  • 19 comments
  • 72 respects
Add projectSign up / Login