Home Arduino Nano33 IoT and WiFi example

Nano33 IoT and WiFi example

The Nano33 IoT is a small board which has WiFi and Bluetooth connectivity that combined with its low power architecture makes it a practical and cost-effective solution for your connected projects.

The Wifi and bluetooth chip is from https://www.u-blox.com/en/product/nina-w10-series

 

The Wifi and bluetooth chip is from https://www.u-blox.com/en/product/nina-w10-series

This table highlights some of the features

Product variants
Antenna
Antenna pin
Internal antenna
Short range features
Bluetooth qualification v4.2 (Bluetooth low energy and BR/EDR)
Bluetooth output power EIRP [dBm] 8
Bluetooth low energy output power EIRP [dBm] 8
Wi-Fi output power EIRP [dBm] 19
Throughput [Mbit/s] 150.0
Wi-Fi micro access point [max stations] 4
Maximum Wi-Fi range [m] 500
Bluetooth profiles and services
Bluetooth SPP
Bluetooth DUN
Bluetooth PAN
Bluetooth GATT
Wi-Fi standard
IEEE 802.11b
IEEE 802.11g
IEEE 802.11n

Parts

About $21 for this board

Site Link
Amazon.com Arduino Nano 33 IoT

 

Code

The Wifi module embedded on the Arduino Nano 33 IoT is the NINA W102 ESP32 based module. It provides support of Wifi 802.11 b/g/n in the 2.4 GHz band and Bluetooth v4.2. The module is fully compatible with the official WiFiNINA library.

To install the official library in the Arduino IDE, go in the menu Tools -> Manage Libraries… In the library manager, search for WifiNINA and install the WiFiNINA by Arduino.

There are a large amount of built in examples to try, one of my favorites is the ScanNetworks example

[codesyntax lang=”cpp”]

#include <SPI.h>
#include <WiFiNINA.h>

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

  // print your MAC address:
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  printMacAddress(mac);
}

void loop() {
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
  delay(10000);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  int numSsid = WiFi.scanNetworks();
  if (numSsid == -1) {
    Serial.println("Couldn't get a wifi connection");
    while (true);
  }

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet < numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    printEncryptionType(WiFi.encryptionType(thisNet));
  }
}

void printEncryptionType(int thisType) {
  // read the encryption type and print out the name:
  switch (thisType) {
    case ENC_TYPE_WEP:
      Serial.println("WEP");
      break;
    case ENC_TYPE_TKIP:
      Serial.println("WPA");
      break;
    case ENC_TYPE_CCMP:
      Serial.println("WPA2");
      break;
    case ENC_TYPE_NONE:
      Serial.println("None");
      break;
    case ENC_TYPE_AUTO:
      Serial.println("Auto");
      break;
    case ENC_TYPE_UNKNOWN:
    default:
      Serial.println("Unknown");
      break;
  }
}


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();
}

[/codesyntax]

Open the serial monitor and you should any available networks – I have renamed mine but this is what I saw

Scanning available networks…
** Scan Networks **
number of available networks:2
0) network1 Signal: -72 dBm Encryption: WPA2
1) network2 Signal: -79 dBm Encryption: WPA2

You may also like